tModLoader Official tModLoader Help Thread

I am trying to make a custom potion called Titanium Skin Potion. the potion works but the problem is that when i use the potion it gives me the buff but doesn't remove any of the potions from my inventory. any ideas on how to fix it?

nvm i fixed it
 
Last edited:
Hi, I need help with TModLoader
When I start TModLoader I get this message:
TModLoader Help.png

Please help :c
 
Hi, I'm trying to make a mod item and it says that I have 2 errors
Here's the code:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace KarlsonMod.Content.Items.Materials.Tech_Plate_Folder
{
    public class Tech_Plate : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Tech Plate";
            item.width = 22;
            item.height = 20;
            item.maxStack = 999;
            item.value = 500;
            item.rare = 1;
            AddTooltip("A plate equiped with tech stuff");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.CopperBar, 5);
            recipe.AddIngredient(ItemID.SilverBar, 3);
            recipe.AddIngredient(ItemID.GoldBar, 1);
            recipe.AddIngredient(ItemID.IronBar, 10);
            recipe.AddIngredient(ItemID.Wire, 15);
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this, 3);
        }
    }
}
Hope you can help me
 
Hi, I'm trying to make a mod item and it says that I have 2 errors
Here's the code:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace KarlsonMod.Content.Items.Materials.Tech_Plate_Folder
{
    public class Tech_Plate : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Tech Plate";
            item.width = 22;
            item.height = 20;
            item.maxStack = 999;
            item.value = 500;
            item.rare = 1;
            AddTooltip("A plate equiped with tech stuff");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.CopperBar, 5);
            recipe.AddIngredient(ItemID.SilverBar, 3);
            recipe.AddIngredient(ItemID.GoldBar, 1);
            recipe.AddIngredient(ItemID.IronBar, 10);
            recipe.AddIngredient(ItemID.Wire, 15);
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this, 3);
        }
    }
}
Hope you can help me
item.name is not a thing - there is no 'name' variable in Item. Also, there is no AddTooltip method in ModItem.
Delete those and do this:
Code:
public override void SetStaticDefaults()
{
    DisplayName.SetDefault("Tech Plate");
    Tooltip.SetDefault("A plate equipped with tech stuff");
}
 
Sure:
Code:
// Override UseItem in ModItem
public override bool UseItem(Player player)
{
    player.AddBuff(Terraria.ID.BuffID.Hunter, 360); // Add the Hunter buff to the player for 6 seconds
    player.AddBuff(Terraria.ID.BuffID.Horrified, 360); // Add the Horrified buff the the player for 6 seconds
    return true; // Yes, this item does something when used
}
Thanks a lot!



now how about an accessory that permanently gives you a buff when its equipped? i dont even know how to make accessories at all, so im gonna need some help with that.
 
Tmodloader doesnt let me build or build + reload mods any more and shows this error every time i try to.
Screenshot (10).png
Does anybody know how to fix it? Is it because i installed 64 bit Tmodloader? Please help as soon as possible.
 
Sorry for the dumb question...I'm very new to coding. I'm having an issue with my modded sword, originally the problem was that it was way too large, but I fixed that by changing the scale property. However, now it has another issue. The sword is the right size now, however there are two of them, one of each side of the player, and held very far away from the player's hand. Both the swords seem to have separate functional hitboxes.

I've tried using this statement here and trying out all sorts of different combinations of numbers within the parentheses, but no matter what I do it doesn't change anything at all:

public override Vector2? HoldoutOffset()
{
return new Vector2(0, 0);
}

Does anyone know how to fix this? I have a video of the sword in action and I'll paste my current code for reference. The sprite I'm using will be attached as well if that's useful.

Video: sworderror.mp4

My code:

using Terraria;
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;

namespace ZephyrMod.Items
{
public class KrakenSplitter : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("KrakenSplitter"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Summons homing water shards from the sky");
}

public override void SetDefaults()
{
item.damage = 45;
item.melee = true;
item.width = 4;
item.height = 4;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 2;
item.scale = 0.1f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}

public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 180);
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(mod.GetItem("HydraflameBar"), 10);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

Edit: Solved, the problem was I needed to resize the png to be much smaller
 

Attachments

  • KrakenSplitter.png
    KrakenSplitter.png
    9.7 KB · Views: 98
Last edited:
Does anyone know how to make a slime in code, I looked in example mod and other places but it either was a boss slime, or some other slime with new mechanics, I just want a normal slime that will spawn in the surface. I’m very new to coding and have not made anything yet.
 
Does anyone know how to make a slime in code, I looked in example mod and other places but it either was a boss slime, or some other slime with new mechanics, I just want a normal slime that will spawn in the surface. I’m very new to coding and have not made anything yet.

This one is actually pretty easy!

C#:
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace ModName.NPCs
{
    public class ModSlime : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Slime"); // Replace Slime with a name you want, such as "Orange Slime."
        }

        public override void SetDefaults()
        {
            //npc.width = 30; // Hitbox width
            //npc.height = 24; // Hitbox height
            npc.damage = 6;
            npc.defense = 0;
            npc.lifeMax = 14;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 3f;
            npc.noGravity = false;
            npc.aiStyle = 1;
            Main.npcFrameCount[npc.type] = 2; // 2 is the frame count for most slimes.
            aiType = 1;
            animationType = 1;
            //npc.knockBackResist = 0f; // This is optional
        }
    }
}
 
Back
Top Bottom