tModLoader Official tModLoader Help Thread

Alright, I got another problem. I got the item drop to function properly, but when I pick up the item it doesn't appear in my inventory.

This is what I got so far:

P.S. Sorry that it isn't indexed, but I promise it is in my actual code.

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using AccessoryExpansionMod.Items;
using AccessoryExpansionMod.NPCs;

namespace AccessoryExpansionMod.NPCs
{
public class KhaelisItemMagnetDrop : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
if (npc.type == Terraria.ID.NPCID.GraniteGolem)
{
if (Main.rand.Next(3) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("KhaelisItemMagnet"), Main.rand.Next(1));
}
}
}
}
}

using Terraria;
using System.Collections.Generic;
using Terraria.ID;
using Terraria.ModLoader;

namespace AccessoryExpansionMod.Items
{
public class KhaelisItemMagnet : ModItem
{
public override void SetDefaults()
{
item.name = "Item Magnet";
item.width = 34;
item.height = 32;
item.toolTip = "Increases item pickup range";
item.value = 50000;
item.rare = 3;
item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.rangedCrit += 5; //Placeholder
}
}
}

Am I missing something?
 
Alright, I got another problem. I got the item drop to function properly, but when I pick up the item it doesn't appear in my inventory.

This is what I got so far:

P.S. Sorry that it isn't indexed, but I promise it is in my actual code.

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using AccessoryExpansionMod.Items;
using AccessoryExpansionMod.NPCs;

namespace AccessoryExpansionMod.NPCs
{
public class KhaelisItemMagnetDrop : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
if (npc.type == Terraria.ID.NPCID.GraniteGolem)
{
if (Main.rand.Next(3) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("KhaelisItemMagnet"), Main.rand.Next(1));
}
}
}
}
}

using Terraria;
using System.Collections.Generic;
using Terraria.ID;
using Terraria.ModLoader;

namespace AccessoryExpansionMod.Items
{
public class KhaelisItemMagnet : ModItem
{
public override void SetDefaults()
{
item.name = "Item Magnet";
item.width = 34;
item.height = 32;
item.toolTip = "Increases item pickup range";
item.value = 50000;
item.rare = 3;
item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.rangedCrit += 5; //Placeholder
}
}
}

Am I missing something?
Main. Rand.next(1) will always be 0. The upper limit is an exclusive limit
 
How about plain tModLoader (without Tremor ever being installed)?
Could you also describe the situation when you're getting the spikes?
That is what I am saying. I uninstalled tremor so it was just tmodloader and still the fps spikes after 5 minutes of playing or so.I am back to vanilla with no fps issues. Just now reinstalled tmodloader no mods at all and the fps spikes returned
[doublepost=1465768803,1465768754][/doublepost]
I've never had a single problem with my FPS.

But maybe that's because I've got a $3000 computer that I built myself, who knows?

What type of computer are you using? The specs, etc.
An old msi potato. Has trouble running anything newer and graphically intensive but never any problems with terraria
 
That is what I am saying. I uninstalled tremor so it was just tmodloader and still the fps spikes after 5 minutes of playing or so.I am back to vanilla with no fps issues. Just now reinstalled tmodloader no mods at all and the fps spikes returned
[doublepost=1465768803,1465768754][/doublepost]
An old msi potato. Has trouble running anything newer and graphically intensive but never any problems with terraria
Allright, so plain tModLoader without any mods results in you getting FPS drops after about 5 minutes, correct?
I agree with you that in this case, the FPS difference between the tModLoader and vanilla version should be unnotice-able.
Anyway sorry to do this, but could you elaborate more? Do you have a new character and world? Are you wearing any armor (I remember there were issues with FPS and armor at one point)?
 
You can't say that if you've just tested it with Tremor.
[doublepost=1465772668,1465772591][/doublepost]
It should work fine if you just replace it with 1. As jopo said, Main.rand.Next(1) will only return 0.

OOOOOH, I see what I did wrong now. Main.rand.Next(1) was unnecessary in the one line of code. Removed it completely and now it functions as intended.

Now to figure out how to code this accessory. XD

I'm learning slowly! XD
 
Allright, so plain tModLoader without any mods results in you getting FPS drops after about 5 minutes, correct?
I agree with you that in this case, the FPS difference between the tModLoader and vanilla version should be unnotice-able.
Anyway sorry to do this, but could you elaborate more? Do you have a new character and world? Are you wearing any armor (I remember there were issues with FPS and armor at one point)?
I have tested with both a fresh character and a geared character both resulting in lag. Same with fresh world and an already existing.
 
Does anyone know how to fix the inventory breaking problem with 2 items in my mod(and thing is its not the items themselves it seems since it didnt affect someone else with the cs files up) And I tried multiple things to try to fix it :(
 
Does anyone know how to fix the inventory breaking problem with 2 items in my mod(and thing is its not the items themselves it seems since it didnt affect someone else with the cs files up) And I tried multiple things to try to fix it :(
The items are fine, but those while loops look very suspect. You can narrow it down by using vanilla projectiles, seeing that the items themselves do work.
 
The items are fine, but those while loops look very suspect. You can narrow it down by using vanilla projectiles, seeing that the items themselves do work.
The weird thing is: He gave me his project so I could have a look at it in person. Now with the 'problematic' items added, it worked fine for me...
 
The weird thing is: He gave me his project so I could have a look at it in person. Now with the 'problematic' items added, it worked fine for me...
yeah which im trying to fix it for myself too(and it explained why the meteor yoyo worked before but was suddenly later a inv breaker)
 
Testing out a little sword-like weapon. Tried to build it, it didn't crash. Then I tried to reload the mods, to make it work, and got this message:
Code:
Items/Balisong
  at Terraria.ModLoader.Mod.GetTexture(String name)
  at Terraria.ModLoader.ModLoader.GetTexture(String name)
  at Terraria.ModLoader.Mod.SetupContent()
  at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
 
Testing out a little sword-like weapon. Tried to build it, it didn't crash. Then I tried to reload the mods, to make it work, and got this message:
Code:
Items/Balisong
  at Terraria.ModLoader.Mod.GetTexture(String name)
  at Terraria.ModLoader.ModLoader.GetTexture(String name)
  at Terraria.ModLoader.Mod.SetupContent()
  at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
Which means that in the 'Items' folder in your mod, there is no texture present called 'Balisong.png'.
hi i need help can anyone tell me how i can make a accessory with debuffs like the Brain Of Confusion ? :brain:
In the UpdateAccessory method of your ModItem, you can just set
Code:
player.brainOfConfusion = true;
 
Back
Top Bottom