tModLoader [FIXED] Error: Object Reference Not Set To An Instance Of An Object

heemebeeme

Terrarian
when i load into the game and hover over one of my items i cant see the tooltip or name of the item. When i throw it on the ground and hover over it i still cant see it, but the worst part is that when i go to pick it up again it fills my inventory full of them and then makes it so i cant move at all (no lag i just straight up cant move)


Script of the item:

using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria.GameContent.Creative;
using modname.Content.Items.MobDrops;

namespace modname.Content.Items.Weapons
{
internal class StarStriker : ModItem
{

public override void SetStaticDefaults(2)
{
DisplayName.SetDefault("StarStriker");
Tooltip.SetDefault("One of the longest blades to be created in the Surforian Forge");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void SetDefaults()
{
Item.width = 32;
Item.height = 32;

Item.value = Item.buyPrice(gold: 5);
Item.maxStack = 1;

Item.damage = 52;
Item.crit = 60;
Item.DamageType = DamageClass.Melee;
Item.noMelee = false;

Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.useAnimation = 17;
Item.useTime = 17;
Item.consumable = false;
Item.useStyle = ItemUseStyleID.Swing;
Item.isAShopItem = true;

Item.lifeRegen = 10;
Item.value = Item.sellPrice(gold: 3);
Item.ArmorPenetration = 4;
Item.knockBack = 6f;
Item.rare = ItemRarityID.Count;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ModContent.ItemType<Gunk>(), 25);
recipe.AddTile(TileID.MythrilAnvil);
recipe.Register();
}

}

}

Images:

image_2022-06-25_230448784.png

image_2022-06-25_230635334.png






If anyone has any tips on how i could fix this error that would be greatly appreciated.
 
Last edited:
The one thing that jumps out as an error, you have public override void SetStaticDefaults(2)
Remove the 2 from within the parenthesis.
 
Hmm, do you have any other mods enabled other than the one you are building?

The only thing I can think of is that you have another item with the same namespace / class name, and you're having a conflict, or there is some other conflicting code you have written. Does this error happen with any other item you have made?
 
C#:
Item.rare = ItemRarityID.Count;
If you're trying to get a vanilla rarity color, change this to some other value in ItemRarityID. Otherwise, you'll need to use ModContent.RarityType<YourRarityClassHere>().
 
Back
Top Bottom