tModLoader Tutorial: [3] Items

so i have a sprite for the delta ore i will be using for my mod, how do i put it into a tile?
There are two parts into creating a custom tile. The first being a ModItem. This is the ore that you have in your inventory. This item can be part of recipes, and when used it places a custom tile. The second part being a ModTile. This part is more difficult, and requires a lot more spriting. I suggest you look into ExampleBlock in ExampleMod/Items and ExampleMod/Tiles to see how it's done.
 
How do you put custom sounds on any of your items?
For example, I want to use a custom staff which when used, a certain sound plays.
How do i do that?
 
upload_2017-1-2_14-4-29.png Err..... HELP?
 
Hey, I'm new here, and am trying to create a placeable item, like a stone block of some sort. How do I do that?
 
Is there a specific way to make a bar/ingot? I couldn't seem to find anything around these tutorials or across the internet, I was hoping to make a bar/ingot from vanilla resources and then make into armour and weapons. So far I've got all this typed into the bars .cs file, am I typing it wrong or am I missing something?
using Terraria.ID;
using Terraria.ModLoader;

namespace Ingot.Items
{
public class Ingot : ModItem
{
public override void SetDefaults()
{
item.name = "Ingot";
item.width = 30;
item.height = 30;
item.maxStack = 999;
AddTooltip("An ingot.");
item.value = 1000;
item.rare = 1;​
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 5);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();​
}​
}​
}
 
Is there a specific way to make a bar/ingot? I couldn't seem to find anything around these tutorials or across the internet, I was hoping to make a bar/ingot from vanilla resources and then make into armour and weapons. So far I've got all this typed into the bars .cs file, am I typing it wrong or am I missing something?
using Terraria.ID;
using Terraria.ModLoader;

namespace Ingot.Items
{
public class Ingot : ModItem
{
public override void SetDefaults()
{
item.name = "Ingot";
item.width = 30;
item.height = 30;
item.maxStack = 999;
AddTooltip("An ingot.");
item.value = 1000;
item.rare = 1;​
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 5);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();​
}​
}​
}
That depends. Which functionality are you missing? It looks like a totally regular item file to me.
 
That depends. Which functionality are you missing? It looks like a totally regular item file to me.
I have changed the code a little bit since I posted that message, to add in the item's name and made the ingredients to what I wanted. Here is the code as it is now:
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace CelestialMod.Items
{
    public class CelestialIngot : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Celestial Ingot";
            item.width = 30;
            item.height = 30;
            item.maxStack = 999;
            AddTooltip("An ingot imbued with celestial powers.");
            item.value = 100;
            item.rare = 1;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.HallowedBar, 2)
            recipe.AddIngredient(ItemID.FragmentVortex, 3)
            recipe.AddIngredient(ItemID.FragmentNebula, 3)
            recipe.AddIngredient(ItemID.FragmentSolar, 3)
            recipe.AddIngredient(ItemID.FragmentStardust, 3)
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this, 2);
            recipe.AddRecipe();
        }
    }
}
When I used the old code it wouldn't properly load into Terraria and would say it was invalid, but with the code updated and what seems to be more understandable come up with an error code while it is compiling:
iDEq5BG.png

It seems like there's a problem not with the items .cs file but the actual mod's .cs file, I haven't really been too sure what to put in the as this is what I've currently got:
Code:
using Terraria.ID;

public override void AddRecipes()
{
    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.HallowedBar, 2)
    recipe.AddIngredient(ItemID.FragmentVortex, 3)
    recipe.AddIngredient(ItemID.FragmentNebula, 3)
    recipe.AddIngredient(ItemID.FragmentSolar, 3)
    recipe.AddIngredient(ItemID.FragmentStardust, 3)
    recipe.AddTile(TileID.WorkBenches);
    recipe.SetResult(this, 2);
    recipe.AddRecipe();
}
It does seem a little empty, If there's anything missing could you possibly give me a heads up and maybe help me fill in the blanks?

Thanks in advance :guidehappy:

*Edit: The image doesn't seem to be working, I was using the BBCode link from imgur.
No worries, fixed it now.

 
Means you're missing an image for your item, this most likely means that you've named your image file of your item different from your item file or you actually don't have an image for your item.
Odd. I Definitely all the files. Using Placeholder images ATM to make sure I have them.
 
Last edited:
error CS0117: 'Terraria.Item' does not contain a definition for 'useSound'
i cant add any sound to my weapons bosses and other stuff. help me. what am i doing wrong? when i delete the item.useSound = 1; it works, but when i add it, it just gives the error i gave at the top. HELP before i go crazy. thanks
 
error CS0117: 'Terraria.Item' does not contain a definition for 'useSound'
i cant add any sound to my weapons bosses and other stuff. help me. what am i doing wrong? when i delete the item.useSound = 1; it works, but when i add it, it just gives the error i gave at the top. HELP before i go crazy. thanks
You are using pre 0.9 code: https://docs.google.com/document/d/1pytx2sCLq56qXZLIQ_mKzv0_-Nf6E3hncExL8Mf9OJ8/edit?usp=sharing
Also, come to the discord for quicker help.
 
So, slight error, this is the logs:

Code:
c:\Users\TheGeckoGamer\Documents\My Games\Terraria\ModLoader\Mod Sources\VarietyMod\VarietyMod\Items\SplitterAxe.cs(35,39) : error CS0246: The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)

c:\Users\TheGeckoGamer\Documents\My Games\Terraria\ModLoader\Mod Sources\VarietyMod\VarietyMod\Items\SplitterAxe.cs(35,54) : error CS0246: The type or namespace name 'NPC' could not be found (are you missing a using directive or an assembly reference?)

and this is my code:

Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace VarietyMod.Items
{
    public class SplitterAxe : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Armor Splitter";
            item.damage = 50;
            item.melee = true;
            item.width = 40;
            item.height = 40;
            item.toolTip = "An axe that can break even the toughest of armor.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 6;
            item.value = 100000;
            item.rare = 2;
            item.useSound = 1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {

            target.AddBuff(BuffID.BrokenArmor, 30);

        }
    }
}

I don't know what this issue is, I'm just trying to make the axe give the broken armor debuff.
 
Back
Top Bottom