tModLoader Official tModLoader Help Thread

Basically what Jopojelly wants you to do is make a new file with the code he gave you previously inside your mod file. This file will act as he said, "The Heart of your Mod". You can't have a mod without this file because the file tells tModLoader that that folder is a mod. Without that file, you cannot compile the folder with tModLoader since it isn't recognized as a mod. If this is not the case, then I suggest you give us a screenshot of inside your mod location (the folder for your mod).

Also you shouldn't post empty posts with just a quote.

Oh, and i meant i didn't know what keywords that i needed to change were
 
Oh, and i meant i didn't know what keywords that i needed to change were
What you posted is an item file, the one he's talking about is the uhh... "heart file" I guess. You just need to make a new file with the code he posted and change it all to whatever your mod is, so, this is what your new file within your mod folder.

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

namespace WormholeCoins
{
   public class WormholeCoins : Mod
   {
       public WormholeCoins()
      {
          Properties = new ModProperties()
          {
             Autoload = true,
          };
      }
   }
}

If you already do have a file like this, then it must be a different problem.

If you are missing this, you should check what the folder structure of your mod should probably look like. What your WormholeCoins.cs is basically my MMod.cs. Everything else that isn't in a subfolder can mostly be ignored as they aren't necessary.
 
What you posted is an item file, the one he's talking about is the uhh... "heart file" I guess. You just need to make a new file with the code he posted and change it all to whatever your mod is, so, this is what your new file within your mod folder.

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

namespace WormholeCoins
{
   public class WormholeCoins : Mod
   {
       public WormholeCoins()
      {
          Properties = new ModProperties()
          {
             Autoload = true,
          };
      }
   }
}

If you already do have a file like this, then it must be a different problem.

If you are missing this, you should check what the folder structure of your mod should probably look like. What your WormholeCoins.cs is basically my MMod.cs. Everything else that isn't in a subfolder can mostly be ignored as they aren't necessary.

Fixed that issue, now Mod Sources\WormholeCoins\Items\WormholeAnvil.cs(28,42) : error CS0117: 'Terraria.ModLoader.ModItem' does not contain a definition for 'WormholeCoin'

Code:
using Terraria.ID;
using Terraria.ModLoader;
namespace WormholeCoins.Items
{
    public class WormholeAnvil : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Wormhole Anvil";
            item.width = 28;
            item.height = 14;
            item.maxStack = 99;
            AddTooltip("Used to make wormholes...");
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.value = 150;
            item.createTile = mod.TileType("WormholeAnvil");
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ModItem.WormholeCoin, 5);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
Fixed that issue, now Mod Sources\WormholeCoins\Items\WormholeAnvil.cs(28,42) : error CS0117: 'Terraria.ModLoader.ModItem' does not contain a definition for 'WormholeCoin'

Code:
using Terraria.ID;
using Terraria.ModLoader;
namespace WormholeCoins.Items
{
    public class WormholeAnvil : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Wormhole Anvil";
            item.width = 28;
            item.height = 14;
            item.maxStack = 99;
            AddTooltip("Used to make wormholes...");
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.value = 150;
            item.createTile = mod.TileType("WormholeAnvil");
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ModItem.WormholeCoin, 5);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
It isn't "ModItem.WormholeCoin", it should be
Code:
ItemType("WormholeCoin")
 
WOW, sat here forever for a response, and decided to look up the error, and found if i put
Code:
using Terraria.ID;
using Terraria.ModLoader;
namespace WormholeCoins.Items
{
    public class WormholeAnvil : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Wormhole Anvil";
            item.width = 28;
            item.height = 14;
            item.maxStack = 99;
            AddTooltip("Used to make wormholes...");
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.value = 150;
            item.createTile = mod.TileType("WormholeAnvil");
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(mod.ItemType("WormholeCoin"), 5);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
It works

EDIT: what i changed was recipe.AddIngredient(mod.ItemType("WormholeCoin"), 5);
 
So, now i am making a sword, but the only issue i got is the fact that the sword doesn't have a swing animation, i went through animations 1-5, the only one that actually was working is the short sword animation... but i want a animation like a wood sword/broadsword. Pls help, i know I've asked for help alot, but im just a noob,
 
So if i want to make just a sword mod, How do i start out? I read the forums and help thread but it still gives no direction on where to start, I made the .cs and the .png texture for it, so how do i build it to make the mod file? I understand that you need some sort of "build and description file", as well as a loading code? Can anyone help me out here.
 
I had an issue, I had the mods enabled and reloaded but when i made a world and entered, NONE were on. Not even ones I KNOW are working, such as Tremor and Calamity. Can I get help from this? I have it downloaded, put in the right place, etc.
 
So if i want to make just a sword mod, How do i start out? I read the forums and help thread but it still gives no direction on where to start, I made the .cs and the .png texture for it, so how do i build it to make the mod file? I understand that you need some sort of "build and description file", as well as a loading code? Can anyone help me out here.
Try this out, it'll help you get started.: http://javid.ddns.net/tModLoader/generator/ModSkeletonGenerator.html
 
Okay, i got my mod to work, How can i make the sword use a custom sound when i swing it? I saw the usesound but how can i add a custom sound and use it? i saw nothing about it on the forums
 
So, now i am making a sword, but the only issue i got is the fact that the sword doesn't have a swing animation, i went through animations 1-5, the only one that actually was working is the short sword animation... but i want a animation like a wood sword/broadsword. Pls help, i know I've asked for help alot, but im just a noob,

Fixed it
[doublepost=1483988758,1483988233][/doublepost]So, how do i make it so i can turn while still swinging a sword or any type of melee weapon?
 
Any reason why my code isn't working?
Code:
       public virtual void OnHitAnything(float x, float y, Player victim)
        {
            victim.AddBuff(BuffID.Venom, 100);
        }

I wanted to add that to a weapon, to that when you hit someone on pvp it applies the venom effect. I got it working on monsters/npcs using:

Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(BuffID.Venom, 100);
        }
but I'm really struggling making it work with players.
 
Any reason why my code isn't working?
Code:
       public virtual void OnHitAnything(float x, float y, Player victim)
        {
            victim.AddBuff(BuffID.Venom, 100);
        }

I wanted to add that to a weapon, to that when you hit someone on pvp it applies the venom effect. I got it working on monsters/npcs using:

You want to use
Code:
  public override void OnHitPvp(Player player, Player target, int damage, bool crit)
  {
  base.OnHitPvp(player, target, damage, crit);
  }
for hitting players, you will need a separate one for NPC's
 
You want to use
Code:
  public override void OnHitPvp(Player player, Player target, int damage, bool crit)
  {
  base.OnHitPvp(player, target, damage, crit);
  }
for hitting players, you will need a separate one for NPC's

I've already changed my code to this
Code:
        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(BuffID.Blackout, 600);
            target.AddBuff(BuffID.CursedInferno, 600);
            target.AddBuff(BuffID.Frostburn, 600);
            int healingAmount = Convert.ToInt32 (damage * 0.2);
            player.statLife += healingAmount;
            player.HealEffect(healingAmount, true);
        }


        public override void ModifyHitPvp(Player player, Player target, ref int damage, ref bool crit)
        {
            target.AddBuff(BuffID.Blackout, 600);
            target.AddBuff(BuffID.CursedInferno, 600);
            target.AddBuff(BuffID.Frostburn, 600);
        }

the weird there here is, it only applies on my screen when I'm holding the weapon, my friend gets the debuffs on my screen, but he's completely fine on his.
 
So, my issues are done for now, but a question i have is, is it possible to make a pickaxe that doubles the amount of ores/blocks you get from mining them?
 
How would I make Plantera drop a range of items at 2.5% chance each, but only allowing one to be dropped on each kill?
I think that the best way would be to use a switch statement. Generate a random number that can be as 39, then use that as your case for the switch statement and put each item drop into a different switch segment. Here's a little bit about switch statements.

Fixed it
[doublepost=1483988758,1483988233][/doublepost]So, how do i make it so i can turn while still swinging a sword or any type of melee weapon?
I believe that you want to set item.useTurn to true.
 
Back
Top Bottom