tModLoader Official tModLoader Help Thread

Hello, I am all new to this but I made a mod with a sword being crafted from an Ore I made, and I know that I cant just type the name of the item there but I dont what to type there.

Code of my sword

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace Adirinksmod_test.Items.Weapons   //where is located
{
    public class EctoplasmSword : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Ectoplasm Sword";     //Sword name
            item.damage = 69;            //Sword damage
            item.melee = true;            //if it's melee
            item.width = 70;              //Sword width
            item.height = 70;             //Sword height
            item.toolTip = "It shoots swords.";  //Item Description
            item.useTime = 50;          //how fast
            item.useAnimation = 45;    
            item.useStyle = 1;        //Style is how this item is used, 1 is the style of the sword
            item.knockBack = 8;      //Sword knockback
            item.value = 500000;       
            item.rare = 7;
            item.useSound = 1;       //1 is the sound of the sword
            item.autoReuse = true;   //if it's capable of autoswing.
            item.useTurn = true;
            item.shoot = mod.ProjectileType("EctoplasmSword_Pro");
            item.shootSpeed = 10.7f;                //projectile speed     

        }
        public override void AddRecipes()  //How to craft this sword
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.ChlorophyteSaber, 1);
            recipe.AddIngredient(OriciliumBar, 15);
            recipe.AddTile(TileID.WorkBenches);   //at work bench
            recipe.SetResult(this);
            recipe.AddRecipe();

        public override void MeleeEffects(Player player, Rectangle hitbox)
        {
            if (Main.rand.Next(1) == 0)
            {
                int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, mod.DustType("EctoplasmSword_dust"));
            }
        }
    }
}

Code of my item

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

namespace Adirinksmod_test.Items
{
    public class OriciliumBar : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Oricilium Bar";
            item.width = 30;
            item.height = 24;
            item.maxStack = 999;
            AddTooltip("Bar made from Oricilium ore");
            item.value = 100;
            item.rare = 6;
        }
    }
}
 
Hello, I am all new to this but I made a mod with a sword being crafted from an Ore I made, and I know that I cant just type the name of the item there but I dont what to type there.

Code of my sword

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace Adirinksmod_test.Items.Weapons   //where is located
{
    public class EctoplasmSword : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Ectoplasm Sword";     //Sword name
            item.damage = 69;            //Sword damage
            item.melee = true;            //if it's melee
            item.width = 70;              //Sword width
            item.height = 70;             //Sword height
            item.toolTip = "It shoots swords.";  //Item Description
            item.useTime = 50;          //how fast
            item.useAnimation = 45;   
            item.useStyle = 1;        //Style is how this item is used, 1 is the style of the sword
            item.knockBack = 8;      //Sword knockback
            item.value = 500000;      
            item.rare = 7;
            item.useSound = 1;       //1 is the sound of the sword
            item.autoReuse = true;   //if it's capable of autoswing.
            item.useTurn = true;
            item.shoot = mod.ProjectileType("EctoplasmSword_Pro");
            item.shootSpeed = 10.7f;                //projectile speed    

        }
        public override void AddRecipes()  //How to craft this sword
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.ChlorophyteSaber, 1);
            recipe.AddIngredient(OriciliumBar, 15);
            recipe.AddTile(TileID.WorkBenches);   //at work bench
            recipe.SetResult(this);
            recipe.AddRecipe();

        public override void MeleeEffects(Player player, Rectangle hitbox)
        {
            if (Main.rand.Next(1) == 0)
            {
                int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, mod.DustType("EctoplasmSword_dust"));
            }
        }
    }
}

Code of my item

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

namespace Adirinksmod_test.Items
{
    public class OriciliumBar : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Oricilium Bar";
            item.width = 30;
            item.height = 24;
            item.maxStack = 999;
            AddTooltip("Bar made from Oricilium ore");
            item.value = 100;
            item.rare = 6;
        }
    }
}
I'm not completely sure if this is the problem you mean, but I assume you mean this:
Code:
recipe.AddIngredient(OriciliumBar, 15);
That will not work. The correct format is this:
Code:
recipe.AddIngredient(mod.ItemType("OriciliumBar"), 15);
 
I'm not completely sure if this is the problem you mean, but I assume you mean this:
Code:
recipe.AddIngredient(OriciliumBar, 15);
That will not work. The correct format is this:
Code:
recipe.AddIngredient(mod.ItemType("OriciliumBar"), 15);
Thanks! I didint know it was so easy :D I looked everywhere and I couldnot find it. Thank you once more!
 
Ok I got a major issue. My mod in general is failing to work, and I don't see what it is. I know for a fact that it is not my items because I tested them over in another mod changing the mod name in each item on the following line.
Code:
namespace (mod name).Items
Why is my mod not working?
 
Ok I got a major issue. My mod in general is failing to work, and I don't see what it is. I know for a fact that it is not my items because I tested them over in another mod changing the mod name in each item on the following line.
Code:
namespace (mod name).Items
Why is my mod not working?
Are you getting an error when trying to build/reload your mod? Is your mod loaded, but it doesn't show anything in game?
 
How to Change color of this

Code:
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MarcinMod.NPCs
{
    public class ForestMage : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "ForestMage";
            npc.displayName = "Forest Mage";
            npc.soundHit = 1;
            npc.soundKilled = 1;
            npc.aiStyle = 8;
            npc.lifeMax = 125;
            npc.damage = 20;
            npc.defense = 70;
            npc.knockBackResist = 0.5f;
            npc.width = 50; //22
            npc.height = 75; //18
            aiType = NPCID.Tim;
            animationType = NPCID.Tim;
            Main.npcFrameCount[npc.type] = 3;
            npc.value = Item.buyPrice(0, 0, 5, 45);
            npc.npcSlots = 1f;
            npc.netAlways = true;
        }
    }
}

20160619094355_1.jpg
 
Are you getting an error when trying to build/reload your mod? Is your mod loaded, but it doesn't show anything in game?
Nope. What happens is that there is no error message, I can turn it on and off like any other mod, but the items seize to exist. I can't craft them, or get them from the creative inventory from Hero's Mod which is compatible with other mods.
 
Nope. What happens is that there is no error message, I can turn it on and off like any other mod, but the items seize to exist. I can't craft them, or get them from the creative inventory from Hero's Mod which is compatible with other mods.
Do you have a class that derives from Mod in your mods rootfolder and does it set Autoload to true?
 
How to Change color of this

Code:
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MarcinMod.NPCs
{
    public class ForestMage : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "ForestMage";
            npc.displayName = "Forest Mage";
            npc.soundHit = 1;
            npc.soundKilled = 1;
            npc.aiStyle = 8;
            npc.lifeMax = 125;
            npc.damage = 20;
            npc.defense = 70;
            npc.knockBackResist = 0.5f;
            npc.width = 50; //22
            npc.height = 75; //18
            aiType = NPCID.Tim;
            animationType = NPCID.Tim;
            Main.npcFrameCount[npc.type] = 3;
            npc.value = Item.buyPrice(0, 0, 5, 45);
            npc.npcSlots = 1f;
            npc.netAlways = true;
        }
    }
}

20160619094355_1.jpg

You can't, those colours are hard coded into the AI you're using.
 
I got no idea what you mean, but if you need to know here's a download link to my folder on the mod.
Look at the ExampleMod. In the root folder of the ExampleMod (called ExampleMod) is a file that is called ExampleMod.cs. This is the file I'm referring to. You'll want to copy this class over to your mod, change every instance of ExampleMod to your own mod name and remove all code inside the class, exept the one that is now named the same as your mod.
 
I don't exactly have a problem with my code but I'm not sure what all the 'zones' are in Terraria. I have certain items which I want to be dropped in certain biomes or 'zones' but there are two which I don't know the name for, well I do but not for the code.

Hell / Underworld - I tried .ZoneUnderworld and I also tried .ZoneHell neither work
and
Forest - I tried .ZoneForest which doesn't work so I'm using .ZoneJungle
 
I don't exactly have a problem with my code but I'm not sure what all the 'zones' are in Terraria. I have certain items which I want to be dropped in certain biomes or 'zones' but there are two which I don't know the name for, well I do but not for the code.

Hell / Underworld - I tried .ZoneUnderworld and I also tried .ZoneHell neither work
and
Forest - I tried .ZoneForest which doesn't work so I'm using .ZoneJungle
Forest, Underworld and Ocean all don't have flags in Terrarias Code. Instead there's other things you need to check.

Forest - The player is in a forest, when no other biome flag is set and if they are overground, but still below sky height.
Underworld - The player is in the Underworld, if they are near the bottom of the world. The exact y-Coordinate differs depending on world size.
Ocean - The player is in the Ocean, if they are close to the eastern/western edge of the map and are neither underground nor in the sky.
 
Forest, Underworld and Ocean all don't have flags in Terrarias Code. Instead there's other things you need to check.

Forest - The player is in a forest, when no other biome flag is set and if they are overground, but still below sky height.
Underworld - The player is in the Underworld, if they are near the bottom of the world. The exact y-Coordinate differs depending on world size.
Ocean - The player is in the Ocean, if they are close to the eastern/western edge of the map and are neither underground nor in the sky.
So what should I put if Forest and Underworld don't have flags?
 
Hey, i have a small problem:

I have a rocket launcher, a rocket launched modded and a modded rocket.

So, with modded weapon where:
item.shoot = mod.ProjectileType("ArmoredRocket");
item.useAmmo = mod.ProjectileType("ArmoredRocket");
and same style for modded rocket.
item.shoot = mod.ProjectileType("ArmoredRocket");
item.ammo = mod.ProjectileType("ArmoredRocket");
I have a correctly rocket(explosion, same aistyle, aitype, etc ). But i want than this rocket can be shoot per vanilla rocket launcher.
So i put
item.shoot = mod.ProjectileType("ArmoredRocket");
item.ammo = 771; (< id of the type rocket)
But here, if vanilla rocket launcher detect ammo, he do not shoot projectile... so, question: I have missed where?


Thank you
 
Back
Top Bottom