tModLoader Official tModLoader Help Thread

Another problem I am running into is that now I want to make an item with multiple recipes possible. I am attempting to make an accessory that can be crafted in many different ways. I used TModReader to extract code from another mod to try and get a good frame of reference, but it was for an outdated version of TModLoader. When I try to do the same thing, I get the error pasted below the code.

How does one go about getting multiple crafting recipes on one accessory? I have multiple items in my mod I need to know how to do this for.

Code:
public override void AddRecipes()
{
    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.BundleofBalloons);
    recipe.AddIngredient(ItemID.LuckyHorseshoe);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();

    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.BlueHorseshoeBalloon);
    recipe.AddIngredient(ItemID.BlizzardinaBalloon);
    recipe.AddIngredient(ItemID.SandstorminaBalloon);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();

    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.CloudinaBalloon);
    recipe.AddIngredient(ItemID.WhiteHorseshoeBalloon);
    recipe.AddIngredient(ItemID.SandstorminaBalloon);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();

    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.CloudinaBalloon);
    recipe.AddIngredient(ItemID.BlizzardinaBalloon);
    recipe.AddIngredient(ItemID.YellowHorseshoeBalloon);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();
}
Code:
...TheTrueBrawler\Items\Accessories\BundleOfHorseshoeBalloons.cs(42,23) : error CS0128: A local variable named 'recipe' is already defined in this scope
 
Another problem I am running into is that now I want to make an item with multiple recipes possible. I am attempting to make an accessory that can be crafted in many different ways. I used TModReader to extract code from another mod to try and get a good frame of reference, but it was for an outdated version of TModLoader. When I try to do the same thing, I get the error pasted below the code.

How does one go about getting multiple crafting recipes on one accessory? I have multiple items in my mod I need to know how to do this for.

Code:
public override void AddRecipes()
{
    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.BundleofBalloons);
    recipe.AddIngredient(ItemID.LuckyHorseshoe);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();

    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.BlueHorseshoeBalloon);
    recipe.AddIngredient(ItemID.BlizzardinaBalloon);
    recipe.AddIngredient(ItemID.SandstorminaBalloon);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();

    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.CloudinaBalloon);
    recipe.AddIngredient(ItemID.WhiteHorseshoeBalloon);
    recipe.AddIngredient(ItemID.SandstorminaBalloon);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();

    ModRecipe recipe = new ModRecipe(mod);
    recipe.AddIngredient(ItemID.CloudinaBalloon);
    recipe.AddIngredient(ItemID.BlizzardinaBalloon);
    recipe.AddIngredient(ItemID.YellowHorseshoeBalloon);
    recipe.AddTile(TileID.TinkerersWorkbench);
    recipe.SetResult(this);
    recipe.AddRecipe();
}
Code:
...TheTrueBrawler\Items\Accessories\BundleOfHorseshoeBalloons.cs(42,23) : error CS0128: A local variable named 'recipe' is already defined in this scope
Read this: https://github.com/blushiemagic/tModLoader/wiki/Basic-Recipes#multiple-recipes
Hope that helps.
 
I trying make a treasure bag but it dint work, this appears

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

namespace Apocalypse.Items
{
    class TresureBag1 : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Z.Slime King TREASURE BAG";
            item.maxStack = 999;
            item.consumable = true;
            item.width = 24;
            item.height = 24;
            item.toolTip = "Right click to open";
            item.rare = 11;
            bossBagNPC = mod.NPCType("ZombieSlimeKing"); //add this if the tresure bag is droped from a boss
            item.expert = true; //add this if it's expert mode only
        }
        public override bool CanRightClick()
        {
            return true;
        }

        public override void OpenBossBag(Player player)
        {
            player.QuickSpawnItem(mod.ItemType("IceDagger"));
            player.QuickSpawnItem(mod.ItemType("ManaDagger"));
            //and this is the items that will 100% drop from the treasure bag
            player.QuickSpawnItem(mod.ItemType("BloodPowder"));
            player.QuickSpawnItem(ItemID.SuperHealingPotion, 3);
        }
    }
}


c:\Users\***\Documents\My Games\Terraria\ModLoader\Mod Sources\Apocalypse\Items\TresureBag1.cs(15,18) : error CS1061: 'Terraria.Item' não contém uma definição para 'name' e nenhum método de extensão 'name' aceita que um primeiro argumento de tipo 'Terraria.Item' seja encontrado (você não está usando uma diretriz ou referência de assembly?)

c:\Users\***\Documents\My Games\Terraria\ModLoader\Mod Sources\Apocalypse\Items\TresureBag1.cs(20,18) : error CS1061: 'Terraria.Item' não contém uma definição para 'toolTip' e nenhum método de extensão 'toolTip' aceita que um primeiro argumento de tipo 'Terraria.Item' seja encontrado (você não está usando uma diretriz ou referência de assembly?)

(Sorry Portuguese PT-BR Language.)
(Sorry bad english.)
 
Last edited:
I trying make a treasure bag but it dint work, this appears

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

namespace Apocalypse.Items
{
    class TresureBag1 : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Z.Slime King TREASURE BAG";
            item.maxStack = 999;
            item.consumable = true;
            item.width = 24;
            item.height = 24;
            item.toolTip = "Right click to open";
            item.rare = 11;
            bossBagNPC = mod.NPCType("ZombieSlimeKing"); //add this if the tresure bag is droped from a boss
            item.expert = true; //add this if it's expert mode only
        }
        public override bool CanRightClick()
        {
            return true;
        }

        public override void OpenBossBag(Player player)
        {
            player.QuickSpawnItem(mod.ItemType("IceDagger"));
            player.QuickSpawnItem(mod.ItemType("ManaDagger"));
            //and this is the items that will 100% drop from the treasure bag
            player.QuickSpawnItem(mod.ItemType("BloodPowder"));
            player.QuickSpawnItem(ItemID.SuperHealingPotion, 3);
        }
    }
}


c:\Users\***\Documents\My Games\Terraria\ModLoader\Mod Sources\Apocalypse\Items\TresureBag1.cs(15,18) : error CS1061: 'Terraria.Item' não contém uma definição para 'name' e nenhum método de extensão 'name' aceita que um primeiro argumento de tipo 'Terraria.Item' seja encontrado (você não está usando uma diretriz ou referência de assembly?)

c:\Users\***\Documents\My Games\Terraria\ModLoader\Mod Sources\Apocalypse\Items\TresureBag1.cs(20,18) : error CS1061: 'Terraria.Item' não contém uma definição para 'toolTip' e nenhum método de extensão 'toolTip' aceita que um primeiro argumento de tipo 'Terraria.Item' seja encontrado (você não está usando uma diretriz ou referência de assembly?)

(Sorry Portuguese PT-BR Language.)
(Sorry bad english.)
Item name and toolTips aren't being used in the SetDefaults hook anymore,

Code:
public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Copper Fishermen Token");
            Tooltip.SetDefault("Throwing this into the water might grant you useful items\nUsing the token in a respective biome can cause that biome's item to drop\nYou can get multiple drops at once");
        }

Here is an example from my source
 
I am not a coder, I'm trying to get back into playing terraria after a couple months of break and can't seem to get it to start after updating tmodloader.

This is the client crashlog, can somebody help?

12-Sep-17 12:50:20 AM
System.EntryPointNotFoundException: Unable to find an entry point named 'InitSafe' in DLL 'CSteamworks'.
at Steamworks.NativeMethods.SteamAPI_InitSafe()
at Steamworks.SteamAPI.Init()
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args)

does this help? any other information i can provide?

EDIT*
I have found my mod directory and deleted all mods to a clean slate, and terraria is working as usual. hope this helps someone else.
 
Hi, I'm trying to add dusts to a few weapons. This worked for one sword, and suddenly it doesn't. To make this even weirder, the dust only appears after the item is pulled from an item frame and the dust only appears above the frame where the weapon used to be. Could someone look at this code for me?

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

namespace RapierMod.Items
{
    public class IchorRapier : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ichor Rapier");
            Tooltip.SetDefault("High chance for critical hits.");
        }

        public override void SetDefaults()
        {
            item.damage = 36;
            item.melee = true;
            item.width = 52;
            item.height = 54;
            item.useTime = 18;
            item.useAnimation = 18;
            item.useStyle = 1;
            item.knockBack = 7;  
            item.crit = 35;
            item.shoot = ProjectileID.IchorSplash;
            item.shootSpeed = 2;
            item.value = 20000;      
            item.rare = 5;          
            item.UseSound = SoundID.Item21;      
            item.autoReuse = true;      
        }

        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;
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = Math.Atan2(speedX, speedY)- spread/2;
            double deltaAngle = spread/3f;
            double offsetAngle;
            int i;
            for (i = 0; i < 3;i++ )
            
            return false;
        }
      
        public override void MeleeEffects(Terraria.Player player, Rectangle hitbox)
        {  
        Dust.NewDust(new Vector2((int)(item.position.X), (int)(item.position.Y)), item.width / 1, item.height / 1, 228);
        }
      

      
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "BloodyRapier");
            recipe.AddIngredient(ItemID.SoulofFright, 5);
            recipe.AddIngredient(ItemID.Ichor, 25);
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(BuffID.Ichor, 600);      
    }
}
 
I am not a coder, I'm trying to get back into playing terraria after a couple months of break and can't seem to get it to start after updating tmodloader.

This is the client crashlog, can somebody help?

12-Sep-17 12:50:20 AM
System.EntryPointNotFoundException: Unable to find an entry point named 'InitSafe' in DLL 'CSteamworks'.
at Steamworks.NativeMethods.SteamAPI_InitSafe()
at Steamworks.SteamAPI.Init()
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args)

does this help? any other information i can provide?

EDIT*
I have found my mod directory and deleted all mods to a clean slate, and terraria is working as usual. hope this helps someone else.
Sounds like you either need to verify Terraria's cache or get the latest version of tModLoader, or both.
 
I can't make a world when I'm using modded Terraria. I can't make any world with Thorium and Calamity enabled, and I can't even make a world with all mods disabled. The game just crashes. I thought the errors I encountered in 10.0.2 (usually mp3 errors when trying to reload a mod) would have been fixed in the new update. They were, but they were replaced with even more problems. Am I doing something wrong? I tried reinstalling tmodloader 0.10.1 multiple times, but nothing changed. I'm starting to think that tModloader is a piece of crap because I've never been able to get it to work.
 
I have a few questions concerning other mods:
1) Is it possible to make a tile (TileA, for example) act as another mod's crafting station? Ex: TileA, when Elemental Unleash is loaded, acts as a Purium Anvil.
2) How do I add other mods' items to my custom recipe group? Ex: Adding Celestial Fragments (Thorium) to a Recipe Group that includes other Pillar Fragments.
3) How do I use another mod's item as a result of a recipe?
 
Two big questions:
1. How do I make a certain world generation occur ONLY in hardmode? I.e. how the Crimson/Corruption and Hallow appear after Wall of Flesh is defeated, but with custom block(s)?

2. How could I make a block (e.g., 'deathstone') convert adjacent or nearby blocks (or only some adjacent blocks, e.g. DirtBlock or StoneBlock) into 'deathstone'? Sort of how corruption spreads to blocks; but instead of only some blocks, it converts any block into 'deathstone'.

Thanks in prelude. :D
 
Hello. I recently started modding Terraria and have run into quite a fundamental issue, which I'll try to explain. Basing off ExampleMod, I created an accessory that, when equipped, places a debuff on the player which makes the player unable to regenerate HP normally. The thing is, to do that, I had to override a void called "UpdateBadHealthRegen()" - And I wouldn't have known such a void exists if not for Example Mod. My question is: Is there a way to see all the functions present in the original Terraria code? In other words: How did example mods creator know to override a void called "UpdateBadHealthRegen()"? How did he find the name? Let's say I want the debuff to also prevent healing through potions and other items. How do I know how to word the function?
 
Hello. I recently started modding Terraria and have run into quite a fundamental issue, which I'll try to explain. Basing off ExampleMod, I created an accessory that, when equipped, places a debuff on the player which makes the player unable to regenerate HP normally. The thing is, to do that, I had to override a void called "UpdateBadHealthRegen()" - And I wouldn't have known such a void exists if not for Example Mod. My question is: Is there a way to see all the functions present in the original Terraria code? In other words: How did example mods creator know to override a void called "UpdateBadHealthRegen()"? How did he find the name? Let's say I want the debuff to also prevent healing through potions and other items. How do I know how to word the function?
For the most part, people use an IDE like Visual Studio ("VS") or check the tModLoader documentation: http://blushiemagic.github.io/tModLoader/html/index.html

VS will allow you to easily override hooks provided by the tModLoader API:

It'll also autocomplete other things:

One thing not in the documentation is vanilla Terraria methods and their descriptions, those you have to learn through experience or experimentation, or study of the decompiled source code. Some useful methods are listed here: https://github.com/blushiemagic/tModLoader/wiki/Useful-Vanilla-Methods
 
Code:
                if (npc.boss)
                {
                    npc.lifeRegen -= (npc.lifeMax * 0.9) / (npc.defense * 0.5);
                }
                else
                {
                    npc.lifeRegen -= (npc.lifeMax * 1.5) / (npc.defense * 0.25);
                }
error CS0266: Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
PLEASE HELP!
Basically npc.lifeRegen -= (int)((npc.lifeMax * 0.9) / (npc.defense * 0.5)); Google it though, something like this is part of the basics and you should learn.
 
Please help i'm Trying to make a mod but every time i click build+reload it comes up with this

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(5,10) : error CS1001: Identifier expected

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(5,23) : error CS1519: Invalid token ':' in class, struct, or interface member declaration

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(5,33) : error CS1519: Invalid token '}' in class, struct, or interface member declaration

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(7,10) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(9,21) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(16,2) : error CS1022: Type or namespace definition, or end-of-file expected

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(17,1) : error CS1022: Type or namespace definition, or end-of-file expected
 
Please help i'm Trying to make a mod but every time i click build+reload it comes up with this

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(5,10) : error CS1001: Identifier expected

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(5,23) : error CS1519: Invalid token ':' in class, struct, or interface member declaration

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(5,33) : error CS1519: Invalid token '}' in class, struct, or interface member declaration

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(7,10) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(9,21) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(16,2) : error CS1022: Type or namespace definition, or end-of-file expected

c:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\Snaparia\Snaparia\Snaparia.cs(17,1) : error CS1022: Type or namespace definition, or end-of-file expected
There is nothing we can do with this other than tell you that you messed up on line 5 and to familiarize yourself with how the computer expects your file to look.

oDfE6d6.png
 
Okay Thanks. I will try and fix that :)(Oh but i don't use mircosoft .xna framework i use mircosoft visual studio
 
Last edited:
New to coding guys. I am making a Pet and I have the actual pet coded correctly, but the summon item and buff codes keep giving me an error and I can't figure it out.
It keeps telling me the tooltip, bufftip and name definitions don't exist. If anyone knows what I'm am doing wrong , I'd appreciate the help.

Screenshot (20).png
Screenshot (21).png
 
Back
Top Bottom