tModLoader Official tModLoader Help Thread

Hehe of course the code surely did help, about 2 and 4, I asked because I wanted my block to act as of a tree, if first block is removed, so as everything on top of it. :p
5 I was just assuming if anyone can tell me the projectile AI of it, I remember using it before (the Bee, Bat, Flairon Bubbles, etc AIs).
6-7 I know this already however it this error shows "No Suitable Method found to override"... I have done it to tapi before but won't work on tML now... Can you tell me why please? ;(
8-9 Aww... Men... Do I really need to do the thing Red does not want people to do? I mean.. You know why not tell? XP
10 err I don't really get things much, unless it's coded.. Or oh well i'll just go check the tAPI template. :)P

Either ways, I am very glad you responded. Thank you very much! :)

Just in case if you know how, can you tell me how to animate a tile consisting of 15 frames with 4 tiles (16 x16) per frame (chest like) ? Because I'm kinda having a hard time doing so... :(
Can you show me what your code is with 6&7?
As for 5, this will also be easy if you just look up the chlorophyte bullet AI with IlSpy!

As for your last question, I'll have to have access to my PC to answer this, so give me an hour or 2! :p
 
Can you show me what your code is with 6&7?
As for 5, this will also be easy if you just look up the chlorophyte bullet AI with IlSpy!

As for your last question, I'll have to have access to my PC to answer this, so give me an hour or 2! :p

Well Basically I just inserted the code from this thread then removed it afterwards (since it didn't work). :p
But anyways, here's the code I wish it to work with:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace NaChMod.Items.Weapons
{
    public class Bhoghron : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Gron";
            item.damage = 70;
            item.melee = true;
            item.width = 40;
            item.height = 40;
            item.toolTip = "Shoots Nanite Clusters which splits twice upon hitting enemies.";
            item.toolTip2 = "May Confuse enemies.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 6;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 1;
            item.autoReuse = true;
            item.shoot = mod.ProjectileType("BhoghronBeam");
            item.shootSpeed = 5f;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Wood);                    
            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("Nanos"));
            }
        }

        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            int ConTrue = 0;
            if (Main.rand.Next(1) == 0)
            {
                ConTrue = Main.rand.Next(1, 5);  
            }

            if (ConTrue == 1)
            {
                target.AddBuff(BuffID.Confused, 120);
            }
        }
    }
}
 
Last edited:
Well Basically I just inserted the code from this thread then removed it afterwards (since it didn't work). :p
But anyways, here's the code I wish it to work with:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace NaChMod.Items.Weapons
{
    public class Bhoghron : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Gron";
            item.damage = 70;
            item.melee = true;
            item.width = 40;
            item.height = 40;
            item.toolTip = "Shoots Nanite Clusters which splits twice upon hitting enemies.";
            item.toolTip2 = "May Confuse enemies.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 6;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 1;
            item.autoReuse = true;
            item.shoot = mod.ProjectileType("BhoghronBeam");
            item.shootSpeed = 5f;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Wood);                   
            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("Nanos"));
            }
        }

        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            int ConTrue = 0;
            if (Main.rand.Next(1) == 0)
            {
                ConTrue = Main.rand.Next(1, 5); 
            }

            if (ConTrue == 1)
            {
                target.AddBuff(BuffID.Confused, 120);
            }
        }
    }
}
Allright, can you add in the overriden Shoot code so that I can take a look at what you do exactly?
 
Allright, can you add in the overriden Shoot code so that I can take a look at what you do exactly?

I currently do not have internet connection on my pc and I'm in mobile, soo... I just pasted the vampire knives code from this thread between the setDefault and the addRecipe and that is all. :/
 
Hello.
How to use 2 ingredient in crafting?
What exactly do you mean? Do you mean using 2 different ingredients? If so, just call 'recipe.AddIngredient' again with another ingredient.
If you mean you want to use... Say 10 Dirt Blocks, you can do the following:
Code:
recipe.AddIngredient(ItemID.DirtBlock, 10);
Where '10' is the amount needed of the specified item.
 
What exactly do you mean? Do you mean using 2 different ingredients? If so, just call 'recipe.AddIngredient' again with another ingredient.
If you mean you want to use... Say 10 Dirt Blocks, you can do the following:
Code:
recipe.AddIngredient(ItemID.DirtBlock, 10);
Where '10' is the amount needed of the specified item.
Oh,no.
Example : 10 Copper Bar and 1 Bladed Glove
 
Oh,no.
Example : 10 Copper Bar and 1 Bladed Glove
For me (or anyone else) to be able to help you, you need to specify what specific part you're having trouble with.
Is it the use of multiple ingredients in a recipe, or setting the amount you need of one ingredient?

Also, my earlier answer probably answers both possibilities, so if you can tell me what part of it you didn't understand, that'd also help a lot.
 
For me (or anyone else) to be able to help you, you need to specify what specific part you're having trouble with.
Is it the use of multiple ingredients in a recipe, or setting the amount you need of one ingredient?

Also, my earlier answer probably answers both possibilities, so if you can tell me what part of it you didn't understand, that'd also help a lot.
I don't know how two different ingredients to make the thing.

{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "Bladed Glove", 1, "Copper Bar", 5);
recipe.AddTile(null, "Workbench");
recipe.SetResult(this);
recipe.AddRecipe();
}
 
I don't know how two different ingredients to make the thing.

{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "Bladed Glove", 1, "Copper Bar", 5);
recipe.AddTile(null, "Workbench");
recipe.SetResult(this);
recipe.AddRecipe();
}
Like I said, you'll have to call recipe.AddIngredient a second time ;)
The following code is probably the result you're looking for:
Code:
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.BladedGlove);
recipe.AddIngredient(ItemID.CopperBar, 5);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();

Also, you did a lot wrong in your example, let me explain why ;)
There are two ways to add an ingredient and/or tile to your recipe.
One is for vanilla items, for which I'd advice you to use ItemID or TileID and get the correct integer value.
In the case of vanilla items, the first parameter is the ID of the item you want to add, where the second parameter (which can also be left out) is the amount you need of that one specific item.
The other method is for mod items and/or tiles.
For this, the first parameter has to be the mod reference (which can also be set to 'null' to simplify things). The second parameter would be the internal name of the ModItem and the third (which can be left out and is only for items) is the amount you need of the specified item.

So, the thing you did wrong is you used the 'Mod' way of adding ingredients and a tile, but all the items and the tile are vanilla items, so that would not have worked out.
 
Like I said, you'll have to call recipe.AddIngredient a second time ;)
The following code is probably the result you're looking for:
Code:
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.BladedGlove);
recipe.AddIngredient(ItemID.CopperBar, 5);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();

Also, you did a lot wrong in your example, let me explain why ;)
There are two ways to add an ingredient and/or tile to your recipe.
One is for vanilla items, for which I'd advice you to use ItemID or TileID and get the correct integer value.
In the case of vanilla items, the first parameter is the ID of the item you want to add, where the second parameter (which can also be left out) is the amount you need of that one specific item.
The other method is for mod items and/or tiles.
For this, the first parameter has to be the mod reference (which can also be set to 'null' to simplify things). The second parameter would be the internal name of the ModItem and the third (which can be left out and is only for items) is the amount you need of the specified item.

So, the thing you did wrong is you used the 'Mod' way of adding ingredients and a tile, but all the items and the tile are vanilla items, so that would not have worked out.
Thanks you :)
 
I have a problem with my mod, i can build it but i can't craft it in game

using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SwordsMod.Items {
public class SwordOfCthulhu : ModItem
{
public override void SetDefaults()
{
item.name = "SwordOfCthulhu";
item.damage = 700;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "Can you control this sword?";
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 10;
item.value = 100;
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();
}


}
}
 
I have a problem with my mod, i can build it but i can't craft it in game

using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SwordsMod.Items {
public class SwordOfCthulhu : ModItem
{
public override void SetDefaults()
{
item.name = "SwordOfCthulhu";
item.damage = 700;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "Can you control this sword?";
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 10;
item.value = 100;
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();
}


}
}
Are you standing near a workbench and do you have 10 dirt blocks in your inventory when you try to craft it?
I just practically copied and pasted your code over into my project and it worked fine.
 
yes i rebuilded it and reloaded it and enabled it but still dont work
I'm afraid I can't help you any further then, since it's working for me... There must (obviously) be something wrong on your end, but I can't really figure that out from my PC...
 
Back
Top Bottom