Standalone [1.3] tModLoader - A Modding API

Show me your globalnpc so far.
Ok, While getting together the code and the error messages I found the "Show potential fixes" link in the error message in VS and I no longer have any errors. I was missing a using System.Collections.Generic; at the top of my code. Now I just flat out don't know how to use this function. What do I put in the EditSpawnPool function to remove any hostile creatures from the Spawn Pool?

Here's the code:
Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;

namespace AerlockMod.NPCs
{
    public class MyGlobalNPC : GlobalNPC
    {

        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            spawnRate = 999999;
            maxSpawns = 0;
        }

        public override void EditSpawnRange(Player player, ref int spawnRangeX, ref int spawnRangeY, ref int safeRangeX, ref int safeRangeY)
        {
            safeRangeX = 9999999;
            safeRangeY = 9999999;
        }

        public override void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)
        {
            ----------> What goes here????? <----------
        }

    }
}

- Aerlock
 
Ok now I have changed the name to "Sup" (Idk why ;p Why not?), and I am to add a nuclear sword with nuclear bar, unsuccesfully.... It keeps giving me this error:
LOG START
c:\Users\Jerry\Documents\My Games\Terraria\ModLoader\Mod Sources\Sup\Items\Nuclear.cs(29,25) : error CS0119: 'Sup.Items.NuclearBar' is a 'type', which is not valid in the given context
LOG END... Hehehehe
Well, line 29 is where it is complaining. Show us the code, since I can't guess the problem just from the error. (Well, sometimes I can)

Quick question: Is it possible to "resize" an item? Like, if I wanted to make a sword appear slightly bigger when swinging?
Or just set item.scale in setdefaults.

Code:
        private const int saveVersion = 0;
        public int DurabilitySave = 0;
        int durability = 999;

        public override void SetDefaults()
        {
            item.name = "Ichor Throwing Knife";
            item.toolTip = "Decreases target's defense";
            item.autoReuse = true;
            item.useStyle = 1;
            item.shootSpeed = 12f;
            item.damage = 29;
            item.width = 18;
            item.height = 20;
            item.useSound = 39;
            item.useAnimation = 16;
            item.useTime = 2;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.value = Item.sellPrice(0, 20, 0, 0);
            item.knockBack = 2.75f;
            item.thrown = true;
            item.melee = false;
            item.rare = 8;
            item.shoot = mod.ProjectileType("IchorThrowingKnifeProjectile");
        }

        public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), 0.7f, SpriteEffects.None, 0f);
            return true;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            durability--;
            DurabilitySave = durability;
            return true;
        }

        public override bool CanUseItem(Player player)
        {
            return durability > 0;
        }

        public override bool OnPickup(Player player)
        {
            durability++;

            return false;
        }

        public override void SaveCustomData(BinaryWriter writer)
        {
            writer.Write(saveVersion);
            writer.Write(DurabilitySave);
        }

        public override void LoadCustomData(BinaryReader reader)
        {
            int loadVersion = reader.ReadInt32();
            if (loadVersion == 0)
            {
                DurabilitySave = reader.ReadInt32();
                durability = DurabilitySave;
            }
        }
After infinite hours of searching and struggling in the source codes, I managed to make my throwing knife like this.
So now it does possess "durability". And the durability has indicated on the item.
However, a few details and bugs still remain here.
  1. The weapon can be crafted with 999 durability, guess it has something to do with the statement of durability. And this durability can get reduced, 'cause of the operator in Shoot hook. But it can't get increase nicely when it is picked up. Is there anything wrong with On Pickup? And I conjectured that there may be bugs when multiple throwing knives are in play. Won't they get messed up with each other's durability? I dunno. I just did it like this, but I got totally no idea how the codes work out and how the data system is arranged.
  2. As for the indication, it's fine. But it seems how hard I tried, I can't make it exactly like how the ammo appears to be. How should I set those parameters to get the durability look like the ammo? The position is quiet OK now. Maybe the color and font need to be specified. Another thing is that the numerical durability won't be zoomed when the item is chosen. I could see the ammo are zoomed normally.
  3. Prefix still sucks.... It just does't want to have prefixes till I turn the item.melee on!!! How am I gonna fix this. Run out of mind.
This is tricky anyways.

1. on pickup is called on the item you pick up, so you are increasing the durability of the picked up item to 1000 and then throwing it away. You'll have to check the inventory for your item, increase it if it is there, or allow the item to be pick up is it's not. You'll want to make sure it's not 999 though.

The durabilities should stay consistent per instance.

2. Zooming the text: use the scale passed in.

3. I forget, what's the point of making it thrown? you just want the damage calculations of thrown, but you also want prefixes?

Ok, While getting together the code and the error messages I found the "Show potential fixes" link in the error message in VS and I no longer have any errors. I was missing a using System.Collections.Generic; at the top of my code. Now I just flat out don't know how to use this function. What do I put in the EditSpawnPool function to remove any hostile creatures from the Spawn Pool?

Here's the code:
Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;

namespace AerlockMod.NPCs
{
    public class MyGlobalNPC : GlobalNPC
    {

        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            spawnRate = 999999;
            maxSpawns = 0;
        }

        public override void EditSpawnRange(Player player, ref int spawnRangeX, ref int spawnRangeY, ref int safeRangeX, ref int safeRangeY)
        {
            safeRangeX = 9999999;
            safeRangeY = 9999999;
        }

        public override void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)
        {
            ----------> What goes here????? <----------
        }

    }
}

- Aerlock

That spawn rate will basically prevent any spawns, I think.

Anyway,
Code:
public virtual void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)

Allows you to control which NPCs can spawn and how likely each one is to spawn. The pool parameter maps NPC types to their spawning weights (likelihood to spawn compared to other NPCs). A type of 0 in the pool represents the default vanilla NPC spawning.
...so as Blue told you earlier, remove 0 from the pool and add back in the vanilla npc you want to spawn.
Code:
        public override void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)
        {
            pool.Remove(0);
            pool.Add(NPCID.Squirrel,.1f);
            pool.Add(NPCID.Bird,.1f);
            pool.Add(NPCID.GoldBird,.1f);
            pool.Add(NPCID.GoldBunny,.1f);
            pool.Add(NPCID.GoldButterfly,.1f);
            pool.Add(NPCID.GoldWorm,.1f);
        }

Of course, I don't expect anything to spawn with the other methods you have there.
 
I forget, what's the point of making it thrown? you just want the damage calculations of thrown, but you also want prefixes?
Yeah, prefixes are in need. Since I'm making this whole new class of weapons... So I'd love to add prefixes to them, which will make them more look like a formal weapon or something...
And as for the check for the inventory... I actually tried that one. But it seems the compiler is not happy with my arbitrary item.durability, and it says my missing "using"?

EDIT: BTW, what's the right color should I use to make the indication look like ammo?
EDIT: And, if I define "scale", what bool should I use to make sure whether the item is chosen or not?
EDIT: Okay, guess I always forgot something here and there. One more question here: where am I supposed to find the IDs of all the sounds? Like which number refers to hurt, and which number refers to picking items?
 
Last edited:
That spawn rate will basically prevent any spawns, I think.

Anyway,
Code:
public virtual void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)

Allows you to control which NPCs can spawn and how likely each one is to spawn. The pool parameter maps NPC types to their spawning weights (likelihood to spawn compared to other NPCs). A type of 0 in the pool represents the default vanilla NPC spawning.
...so as Blue told you earlier, remove 0 from the pool and add back in the vanilla npc you want to spawn.
Code:
        public override void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)
        {
            pool.Remove(0);
            pool.Add(NPCID.Squirrel,.1f);
            pool.Add(NPCID.Bird,.1f);
            pool.Add(NPCID.GoldBird,.1f);
            pool.Add(NPCID.GoldBunny,.1f);
            pool.Add(NPCID.GoldButterfly,.1f);
            pool.Add(NPCID.GoldWorm,.1f);
        }

Of course, I don't expect anything to spawn with the other methods you have there.
THANK YOU! The pool.<action> was the code/call I was missing. I couldn't find any examples of what to put in there. And yes with the spawnrate as it is I get nothing to spawn and that's what I'm trying to fix. I want the bunnies and birds and bugs and the Town NPCs to spawn, but not the hostile NPCs. Once I get my Spawn Pool together I'll put that spawn rate back to a reasonable number and hopefully not get flooded in bunnies.

Now for a couple questions:

In the pool.Add(NPCID.GoldButterfly,.1f) call I'm assuming the .1f is the weight of the NPC in the pool, correct?
Is there a default total weight or just the total of whatever I have in the Add list?
Looking at the NPC list in the documentation on the Github site I see several NPCs that have the same Name but different IDs (Duck, Worm, Scorpion, etc.). If I add those using the pool.Add(NPCID.<Name>,.1f); call will it add all the squirrels, ducks, worms, etc.? Or do I need to add all of those by ID?

- Aerlock
 
Yeah, prefixes are in need. Since I'm making this whole new class of weapons... So I'd love to add prefixes to them, which will make them more look like a formal weapon or something...
And as for the check for the inventory... I actually tried that one. But it seems the compiler is not happy with my arbitrary item.durability, and it says my missing "using"?

EDIT: BTW, what's the right color should I use to make the indication look like ammo?
EDIT: And, if I define "scale", what bool should I use to make sure whether the item is chosen or not?
EDIT: Okay, guess I always forgot something here and there. One more question here: where am I supposed to find the IDs of all the sounds? Like which number refers to hurt, and which number refers to picking items?
well, you can't access durability on Item, since Item doesn't have durability. You need to access the field on your ModItem, but not just ModItem, but the
IchorThrowingKnife. so, something like if item.type == mod.ItemType("IchorThrowingKnife"){ (IchorThrowingKnife)(item.modItem).durability++}

Yeah, you'll want to read up on inheritance and casting.

Are you talking about PreDrawInInventory and scale? why would you define it? Just use the one passed in.

There is a mod called "Dust and Sound Catalogue tModLoader", look in the forum for it, it should help you figure out sounds.

I don't know the color.
THANK YOU! The pool.<action> was the code/call I was missing. I couldn't find any examples of what to put in there. And yes with the spawnrate as it is I get nothing to spawn and that's what I'm trying to fix. I want the bunnies and birds and bugs and the Town NPCs to spawn, but not the hostile NPCs. Once I get my Spawn Pool together I'll put that spawn rate back to a reasonable number and hopefully not get flooded in bunnies.

Now for a couple questions:

In the pool.Add(NPCID.GoldButterfly,.1f) call I'm assuming the .1f is the weight of the NPC in the pool, correct?
Is there a default total weight or just the total of whatever I have in the Add list?
Looking at the NPC list in the documentation on the Github site I see several NPCs that have the same Name but different IDs (Duck, Worm, Scorpion, etc.). If I add those using the pool.Add(NPCID.<Name>,.1f); call will it add all the squirrels, ducks, worms, etc.? Or do I need to add all of those by ID?

- Aerlock
K, just make sure you read the documentation on those methods. They might be backwards from what you expect.

Each NPCID is a different NPC, so you'll want to add red, gold, and regular squirrel, etc.

The default total weight of vanilla npc is 1. So you'll need to worry about mod npc and whatever npc you add back in. Their totals will be the total.
 
well, you can't access durability on Item, since Item doesn't have durability. You need to access the field on your ModItem, but not just ModItem, but the
IchorThrowingKnife. so, something like if item.type == mod.ItemType("IchorThrowingKnife"){ (IchorThrowingKnife)(item.modItem).durability++}

Yeah, you'll want to read up on inheritance and casting.

Are you talking about PreDrawInInventory and scale? why would you define it? Just use the one passed in.
I got it like this, compiler is not happy again:
Code:
        public override bool OnPickup(Player player)
        {
            Main.PlaySound(0, (int)player.position.X, (int)player.position.Y, 7);
            for (int i = 0; i < 50; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorThrowingKnife"))
                {
                    (IchorThrowingKnife)(item2).durability++
                    break;
                }
            }
            return false;
        }

And I'm still not clear about your brilliant " Just use the one passed in." idea... sorry for that.
But what I'm tryna do is to indicate this durability on the item. As for now, I'm kinda realizing most parts of it. Question is that the numerical durability won't get zoomed (which the ammo of gun and bow will).
This is what I write for the indication:
Code:
            Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), 0.7f, SpriteEffects.None, 0f);
And after you said I should use a scale pass in, I figured I should do something like:
Code:
float scale;
if(The item is chosen currently)
scale = 1f;
else scale = 0.7f;

Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), 0.7f, SpriteEffects.None, 0f);
And, specifically, how should the "The item is chosen currently" part be written?
 
I got it like this, compiler is not happy again:
Code:
        public override bool OnPickup(Player player)
        {
            Main.PlaySound(0, (int)player.position.X, (int)player.position.Y, 7);
            for (int i = 0; i < 50; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorThrowingKnife"))
                {
                    (IchorThrowingKnife)(item2).durability++
                    break;
                }
            }
            return false;
        }

And I'm still not clear about your brilliant " Just use the one passed in." idea... sorry for that.
But what I'm tryna do is to indicate this durability on the item. As for now, I'm kinda realizing most parts of it. Question is that the numerical durability won't get zoomed (which the ammo of gun and bow will).
This is what I write for the indication:
Code:
            Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), 0.7f, SpriteEffects.None, 0f);
And after you said I should use a scale pass in, I figured I should do something like:
Code:
float scale;
if(The item is chosen currently)
scale = 1f;
else scale = 0.7f;

Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), 0.7f, SpriteEffects.None, 0f);
And, specifically, how should the "The item is chosen currently" part be written?
No, just replace the 0.7f with scale. It is one of the parameters of PreDrawInInventory. The scale will change automatically if it is chosen.

(IchorThrowingKnife)(item2).durability++ won't work because you cant cast Item to IchorThrowingKnife. IchorThrowingKnife inherits from ModItem, and item.modItem is what you want.

Try: (IchorThrowingKnife)(item2.modItem).durability++
 
No, just replace the 0.7f with scale. It is one of the parameters of PreDrawInInventory. The scale will change automatically if it is chosen.

(IchorThrowingKnife)(item2).durability++ won't work because you cant cast Item to IchorThrowingKnife. IchorThrowingKnife inherits from ModItem, and item.modItem is what you want.

Try: (IchorThrowingKnife)(item2.modItem).durability++
Get ya. But It still says "only assignment,call,increment,decrement,await and new can be used"... Any idea about this?
 
Okay, so I just updated my mod to 0.8, changed all the stuff I should change and then this happens when trying to add recipes:
Code:
The item radiantingot does not exist in the mod MokkelMod.
If you are trying to use a vanilla item, try removing the first argument.
   at Terraria.ModLoader.ModRecipe.AddIngredient(Mod mod, String itemName, Int32 stack)
   at MokkelMod.Items.Accessories.elementalboots.AddRecipes() i c:\Users\maste\Documents\My Games\Terraria\ModLoader\Mod Sources\MokkelMod\Items\Accessories\elementalboots.cs:linje 39
   at Terraria.ModLoader.ModLoader.AddRecipes()
   at Terraria.Recipe.SetupRecipes()
   at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
I am 100% sure that radiantingot exists and is called that.
[doublepost=1461413906,1461413459][/doublepost]Please can someone help me??
 
I don't know without the line number it tells you and the new code.
It indicates line 67, which is exactly this line...
Here is the code when it compiles.
Code:
using System.IO;
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;


namespace wch.Weapons.Knives
{
    public class IchorThrowingKnife : ModItem
    {
        public int DurabilitySave = 0;
        int durability = 999;

        public override void SetDefaults()
        {
            item.name = "Ichor Throwing Knife";
            item.toolTip = "Decreases target's defense";
            item.autoReuse = true;
            item.useStyle = 1;
            item.shootSpeed = 12f;
            item.damage = 29;
            item.width = 18;
            item.height = 20;
            item.useSound = 39;
            item.useAnimation = 16;
            item.useTime = 1;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.value = Item.sellPrice(0, 20, 0, 0);
            item.knockBack = 2.75f;
            item.thrown = true;
            item.melee = false;
            item.rare = 8;
            item.shoot = mod.ProjectileType("IchorThrowingKnifeProjectile");
        }

        public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), scale, SpriteEffects.None, 0f);
            return true;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            durability--;
            DurabilitySave = durability;
            return true;
        }

        public override bool CanUseItem(Player player)
        {
            return durability > 0;
        }

        public override bool OnPickup(Player player)
        {
            Main.PlaySound(0, (int)player.position.X, (int)player.position.Y, 7);
            for (int i = 0; i < 50; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorThrowingKnife"))
                {
                    (IchorThrowingKnife)(item2.modItem).durability++;
                    break;
                }
            }
            return false;
        }

        public override void SaveCustomData(BinaryWriter writer)
        {
            writer.Write(DurabilitySave);
        }

        public override void LoadCustomData(BinaryReader reader)
        {
            DurabilitySave = reader.ReadInt32();
            durability = DurabilitySave;
        }

        public override void OnCraft(Recipe recipe)
        {

        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "TestBlockItem");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

    }
}
 
Okay, so I just updated my mod to 0.8, changed all the stuff I should change and then this happens when trying to add recipes:
Code:
The item radiantingot does not exist in the mod MokkelMod.
If you are trying to use a vanilla item, try removing the first argument.
   at Terraria.ModLoader.ModRecipe.AddIngredient(Mod mod, String itemName, Int32 stack)
   at MokkelMod.Items.Accessories.elementalboots.AddRecipes() i c:\Users\maste\Documents\My Games\Terraria\ModLoader\Mod Sources\MokkelMod\Items\Accessories\elementalboots.cs:linje 39
   at Terraria.ModLoader.ModLoader.AddRecipes()
   at Terraria.Recipe.SetupRecipes()
   at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
I am 100% sure that radiantingot exists and is called that.
[doublepost=1461413906,1461413459][/doublepost]Please can someone help me??
The error says the problem is on line 39. Think you could post your elementalboots.cs code so we can take a look?

- Aerlock
 
The error says the problem is on line 39. Think you could post your elementalboots.cs code so we can take a look?

- Aerlock
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MokkelMod.Items.Accessories
{
    public class elementalboots : ModItem
    {   
        public override void SetDefaults()
        {
            item.name = "Elemental Boots";
            item.width = 32;
            item.height = 32;
            AddTooltip("They shake from the elemental powers within");
            item.value = Item.sellPrice(0, 5);
            item.rare = 4;
            item.accessory = true;
        }
       
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            player.magmaStone = true;
            player.waterWalk = true;
            player.fireWalk = true;
            player.lavaMax += 420;
            player.accRunSpeed = 6.75f;
            player.rocketBoots = 1;
            player.moveSpeed += 0.10f;
            player.iceSkate = true;
        }
       
        public override void AddRecipes()
        {
            var recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "phoenixboots");
            recipe.AddIngredient(ItemID.FrostsparkBoots);
            recipe.AddIngredient(null, "radiantingot", 15);
            recipe.AddTile(TileID.TinkerersWorkbench);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
       
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Shoes);
            return true;
        }
    }
}
 
Could anyone help me with making a bow shoot 2 arrows at once? :)
This piece of code is from the tModloader help thread:
Code:
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            float spread = 45f * 0.0174f; //Replace 45 with whatever spread you want
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = Math.Atan2(speedX, speedY)- spread/2;
            double deltaAngle = spread/8f;
            double offsetAngle;
            int i;
            for (i = 0; i < 2;i++ ) //Replace 2 with number of projectiles
            {
                offsetAngle = startAngle + deltaAngle * i;
                Terraria.Projectile.NewProjectile(position.X, position.Y, baseSpeed*(float)Math.Sin(offsetAngle), baseSpeed*(float)Math.Cos(offsetAngle), item.shoot, damage, knockBack, item.owner);
            }
            return false;
        }
 
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MokkelMod.Items.Accessories
{
    public class elementalboots : ModItem
    {  
        public override void SetDefaults()
        {
            item.name = "Elemental Boots";
            item.width = 32;
            item.height = 32;
            AddTooltip("They shake from the elemental powers within");
            item.value = Item.sellPrice(0, 5);
            item.rare = 4;
            item.accessory = true;
        }
      
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            player.magmaStone = true;
            player.waterWalk = true;
            player.fireWalk = true;
            player.lavaMax += 420;
            player.accRunSpeed = 6.75f;
            player.rocketBoots = 1;
            player.moveSpeed += 0.10f;
            player.iceSkate = true;
        }
      
        public override void AddRecipes()
        {
            var recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "phoenixboots");
            recipe.AddIngredient(ItemID.FrostsparkBoots);
            recipe.AddIngredient(null, "radiantingot", 15);
            recipe.AddTile(TileID.TinkerersWorkbench);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
      
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Shoes);
            return true;
        }
    }
}
Post your radiantingot class too
 
Post your radiantingot class too
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MokkelMod.Items
{
    public class radiantingot : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Radiant Ingot";
            item.width = 30;
            item.height = 24;
            item.maxStack = 999;
            AddTooltip("It seems to glow and shine in your hand");
            item.value = 5000;
            item.rare = 4;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "radiantoreitem", 5);
            recipe.AddTile(TileID.AdamantiteForge);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
 
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MokkelMod.Items
{
    public class radiantingot : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Radiant Ingot";
            item.width = 30;
            item.height = 24;
            item.maxStack = 999;
            AddTooltip("It seems to glow and shine in your hand");
            item.value = 5000;
            item.rare = 4;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "radiantoreitem", 5);
            recipe.AddTile(TileID.AdamantiteForge);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
Hmm, everything looks right, unless you didn't set autoload in your mod properties.
 
It indicates line 67, which is exactly this line...
Here is the code when it compiles.
Code:
using System.IO;
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;


namespace wch.Weapons.Knives
{
    public class IchorThrowingKnife : ModItem
    {
        public int DurabilitySave = 0;
        int durability = 999;

        public override void SetDefaults()
        {
            item.name = "Ichor Throwing Knife";
            item.toolTip = "Decreases target's defense";
            item.autoReuse = true;
            item.useStyle = 1;
            item.shootSpeed = 12f;
            item.damage = 29;
            item.width = 18;
            item.height = 20;
            item.useSound = 39;
            item.useAnimation = 16;
            item.useTime = 1;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.value = Item.sellPrice(0, 20, 0, 0);
            item.knockBack = 2.75f;
            item.thrown = true;
            item.melee = false;
            item.rare = 8;
            item.shoot = mod.ProjectileType("IchorThrowingKnifeProjectile");
        }

        public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 10f), Color.Black, 0f, default(Vector2), scale, SpriteEffects.None, 0f);
            return true;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            durability--;
            DurabilitySave = durability;
            return true;
        }

        public override bool CanUseItem(Player player)
        {
            return durability > 0;
        }

        public override bool OnPickup(Player player)
        {
            Main.PlaySound(0, (int)player.position.X, (int)player.position.Y, 7);
            for (int i = 0; i < 50; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorThrowingKnife"))
                {
                    (IchorThrowingKnife)(item2.modItem).durability++;
                    break;
                }
            }
            return false;
        }

        public override void SaveCustomData(BinaryWriter writer)
        {
            writer.Write(DurabilitySave);
        }

        public override void LoadCustomData(BinaryReader reader)
        {
            DurabilitySave = reader.ReadInt32();
            durability = DurabilitySave;
        }

        public override void OnCraft(Recipe recipe)
        {

        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "TestBlockItem");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

    }
}
I got the parenthesis wrong: ((IchorThrowingKnife)item2.modItem).durability++;

Also, there's no point in having both DurabilitySave and durability
 
Back
Top Bottom