tModLoader Official tModLoader Help Thread

i really need help with my code please help. i keep getting the error " An object reference is required for the non-static field, method, or property 'Mod.ItemType(string)' "
Here is the code
Code:
using System;

using Terraria.ID;

using Terraria.ModLoader;



namespace Test.Items

{

    public class FlamefrostBlade : ModItem

    {

        public override void SetStaticDefaults()

        {

            Tooltip.SetDefault("The perfect blend of Ice and Magma.");

        }



        public override void SetDefaults()

        {

            item.damage = 35;

            item.melee = true;

            item.width = 40;

            item.height = 40;

            item.useTime = 10;

            item.useAnimation = 10;

            item.useStyle = 1;

            item.knockBack = 4;

            item.value = 10000;

            item.rare = 2;

            item.UseSound = SoundID.Item1;

            item.autoReuse = true;

        }



        public override void AddRecipes()

        {

            ModRecipe recipe = new ModRecipe(mod);

            recipe.AddIngredient(ItemID.Shiverthorn, 15);

            recipe.AddIngredient(ItemID.Fireblossom, 15);

            recipe.AddIngredient(ItemID.AshBlock, 150);

            recipe.AddIngredient(Mod.ItemType("Magma Bar"), 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }

    }

}
 
Last edited:
i really need help with my code please help. i keep getting the error " An object reference is required for the non-static field, method, or property 'Mod.ItemType(string)' "
Here is the code
<snip>
Assuming you have an item with the class "MagmaBar", change this line:
recipe.AddIngredient(Mod.ItemType("Magma Bar"), 10);
to this:
recipe.AddIngredient(ModContent.ItemType<MagmaBar>(), 10);
 
what do you put in this line to make it crafted at a demon altar?
Code:
recipe.AddTile(TileID.DemonAltar);
i also tried EvilAltar and EvilAltars and i cant figure it out
Edit: I didn't change anything in the recipe but for some reason it's working now.
 
Last edited:
what do you put in this line to make it crafted at a demon altar?
Code:
recipe.AddTile(TileID.DemonAltar);
i also tried EvilAltar and EvilAltars and i cant figure it out
You could use their number ID, because demon altars are corruption only. The IDs are 26, and for crimson 26 (2)
 
You could use their number ID, because demon altars are corruption only. The IDs are 26, and for crimson 26 (2)
It works now and i didnt even change it, I don't know how that makes sense, but whatever. Thanks for reminding me to make a crimson one, because i would definitely forget it otherwise.
 
Assuming you have an item with the class "MagmaBar", change this line:
recipe.AddIngredient(Mod.ItemType("Magma Bar"), 10);
to this:
recipe.AddIngredient(ModContent.ItemType<MagmaBar>(), 10);
Thanks, but now i get the error "Mod is a namespace but is used like a type"
Code:
using Terraria.ModLoader;

namespace Test
{
    public class Test : Mod
    {


    }
}
 
It works now and i didnt even change it, I don't know how that makes sense, but whatever. Thanks for reminding me to make a crimson one, because i would definitely forget it otherwise.
Your welcome. I’m new to modding but from what I’ve seen number IDs work, and words or numbers in parenthesis are usually not spaced from the actual ID.
 
I am trying to make a projectile for my arrow but they always come out looking like wooden arrows and don't pierce like I want them to.

using Terraria.ID;
using Terraria.ModLoader;

namespace ZephyrMod.Items
{
public class ZephyrArrow : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("ZephyrArrow"); // 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("Zephyr's Revenge.");
}

public override void SetDefaults()
{
item.value = 10000;
item.rare = 11;
item.consumable = true;
item.maxStack = 999;
item.ranged = true;
item.damage = 60;
item.knockBack = 2;
item.shootSpeed = 25f;
item.ammo = AmmoID.Arrow;
item.shoot = mod.ProjectileType("/Users/seth/Library/Application Support/Terraria/ModLoader/Mod Sources/ZephyrMod/Projectiles/ZephyrArrowProjectile.cs");
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(mod.ItemType("ZephyrFragment"), 1);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.SetResult(this, 999);
recipe.AddRecipe();
}
}
}

using Terraria.ID;
using Terraria.ModLoader;

namespace ZephyrMod.Projectiles
{
public class ZephyrArrow : ModProjectile
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("ZephyrArrowProjectile"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
}

public override void SetDefaults()
{
projectile.width = 8;
projectile.height = 12;
projectile.aiStyle = 1;
projectile.friendly = true;
projectile.penetrate = 10000;
projectile.ranged = true;
projectile.arrow = true;
}
}
}

The arrow code is in the items folder and the projectile code is in the projectiles folder.
 
How do you change the properties of a vanilla tile? For instance, make it produce light? And is it the same for fluids, like water or lava?
If you look up tile “bools” you can see that light is Shine, or Shine2, since I have not coded I do not know how to make it shine, but you could most likely find a tutorial or use example mod. I’m not sure if liquid is the same or different.
 
I'm new to this world of mods, so someone could tell me how to put a glow effect on a weapon (sword, sickle, bow, etc.) and where to put it
 
I was able to make my tmodloader work and i also downloaded a few mods. But for some reason when im making a world with thorium mod enabled, it crashes. And when i initialize calamity mod, it also crashes. Maybe it was because of my 2gb ram, is there any good mod you can recommend that doesnt take much memory
Oh, and enable only one at a time (I eventually realized that) they don't work well together
 
I don't think the pictures worked.
Screen Shot 2020-06-22 at 9.32.42 AM.png
(bubble gun)
Screen Shot 2020-06-22 at 9.32.48 AM.png
(upgrade)
 
'sup guys
got a problem with terraria and tmodloader since 1.4 , the games dont launch and a there's a crash report.
I tried to uninstall then reinstall and now terraria don't launch at all and tmodloader keep crashing with this message :
1592848975261.png

I can share the logs folder if it can help too.
 
Back
Top Bottom