Standalone [1.3] tModLoader - A Modding API

If you can't load Terraria because a mod is being loaded which crashes the game, you'll want to manually delete the mod.
If you're on windows, head over to My Documents/My Games/Terraria/ModLoader/Mods and delete the .tmod file which is causing the problems (in your case Hero's mod).
The weird thing is I did delete all the mods there, but it still happened, it's working suddenly for now
The hero mod also wasn't listed
 
The weird thing is I did delete all the mods there, but it still happened, it's working suddenly for now
The hero mod also wasn't listed
Now projectiles aren't working, and if I try to pick up an item my character gets stuck and I have to clear dropped items. I'm wearing chlororphyte armor and the leaf crystal tries to spawn when there's an enemy but never does
 
You can have multiple items ofc :p
It's not only about the filesnames. The namespace of the class and the name of the class itself also play a role.
Say I've got the following:
Code:
namespace MyMod.Items
{
    public class MyItem : ModItem
    {

    }
}
Then tModLoader will look for the texture file using `namespace/className` so `MyMod/Items/MyItem.png'. If the classname is `MyOtherItem` it'll look for `MyMod/Items/MyOtherItem.png` etc.
Lol thank you, i forgot about public class MyItem : ModItem to rewrite to item's name

E1: aaaaaaaah, really thanks! i am working on valentine mod, so i made some things to sell and heart arrows and tommorrow i will make some pet and heart magic weapon ! <3 big like eldrazi <3
<3 for all <3 :D
 
Last edited:
this code is supposed to spawn a movable shield that faces towards the cursor on right click, but the shield doesn't recognise that the item is being channeled, can someone please explain why this is happening and how to fix it?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace elemental.Items
{
    public class IceGauntlet : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Ice Gauntlet";
            item.damage = 100;
            //item.magic = true;
            item.melee = true;
            item.noMelee = false;
            item.noUseGraphic = false;
            item.channel = true;
            item.width = 80;
            item.height = 80;
            item.useTime = 1;
            item.useAnimation = 1;
            item.useStyle = 5;
            item.knockBack = 10;       
            item.value = 10000;
            item.rare = 2;
            item.useStyle = 5;
            item.shoot = 1;
            item.shootSpeed = 1f;
            item.autoReuse = false;
            item.glowMask = 207;
        }

        public override void HoldStyle(Player player)

        {
            if ((!(player.velocity.Y > 0)) || player.sliding)
            {
                int dust3 = Dust.NewDust(player.Center, 0, 0, 92, 0f, 0f, 25, Color.Goldenrod, 1.5f);
                Main.dust[dust3].noGravity = true;
                Main.dust[dust3].velocity = new Vector2(0, 0);
            }
            else
            {
                int dust3 = Dust.NewDust(player.Top + new Vector2(player.direction * -10, 0), 0, 0, 92, 0f, 0f, 25, Color.Goldenrod, 1.5f);
                Main.dust[dust3].noGravity = true;
                Main.dust[dust3].velocity = new Vector2(0, 0);
            }

        }

        public override bool AltFunctionUse(Player player)
        {
            return true;
        }
        public override bool CanUseItem(Player player)
        {
            //ElementalPlayer modPlayer = player.GetModPlayer<ElementalPlayer>(mod);
            if (player.altFunctionUse == 2)     //2 is right click
            {
                item.useTime = 60;
                item.useAnimation = 5;
                //item.melee = true;
                //item.magic = false;
                //item.noMelee = false;
                //item.noUseGraphic = true;
                item.channel = true;
                item.shootSpeed = 2.5f;    //projectile speed when shoot
                item.shoot = mod.ProjectileType("IceShield");
                item.autoReuse = false;
            }
            else
            {

                item.useTime = 2;
                item.useAnimation = 3;
                //item.noMelee = true;
                //item.melee = false;
                //item.magic = true;
                //item.noUseGraphic = false;
                item.channel = true;
                item.shootSpeed = 2.5f;    //projectile speed when shoot
                item.shoot = 128;
                item.autoReuse = true;
            }
            return base.CanUseItem(player);
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.IceBlock, 50);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            if (player.altFunctionUse != 2)
            {

                int numberProjectiles = 3 + Main.rand.Next(2); //This defines how many projectiles to shot. 4 + Main.rand.Next(2)= 4 or 5 shots
                    for (int i = 0; i < numberProjectiles; i++)
                    {
                        Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(30)); // This defines the projectiles random spread . 30 degree spread.
                        int a = Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
                    Main.projectile[a].magic = true;
                    Main.projectile[a].friendly = true;
                    Main.projectile[a].hostile = false;
                    Main.projectile[a].timeLeft = 60;
                    Main.projectile[a].penetrate = -1;
                }
                return false;
            }
            return true;
        }
    }
}
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.Enums;

namespace elemental.Projectiles
{

    public class IceShield : ModProjectile
    {
        private const int maxCharge = 3;
        public override void SetDefaults()
        {
            projectile.name = "Ice Shield";  //projectile name
            projectile.width = 20;       //projectile width
            projectile.height = 20;  //projectile height
            projectile.friendly = true;      //make that the projectile will not damage you
            projectile.magic = true;         //
            projectile.tileCollide = true;   //make that the projectile will be destroed if it hits the terrain
            projectile.penetrate = -1;      //how many npc will penetrate
            projectile.timeLeft = 3600;   //how many time this projectile has before disepire
            projectile.light = 0.75f;    // projectile light
            projectile.extraUpdates = 1;
            projectile.ignoreWater = true;  
            projectile.aiStyle = 0;
        }
        public override void AI()           //this make that the projectile will face the corect way
        {                                                           // |
            Player player = Main.player[projectile.owner];
            Vector2 mousePos = Main.MouseWorld;
            Vector2 unit = (player.Center - mousePos);
            unit.Normalize();
            unit *= -10;
            projectile.position = player.Left + new Vector2(20).RotatedBy((float)Math.Atan2((player.Center - mousePos).Y, (player.Center - mousePos).X) + 1.57f);
            projectile.rotation = (float)Math.Atan2((player.Center - mousePos).Y, (player.Center - mousePos).X) + 101.57f;
            if (!player.channel)
            {
                Vector2 tempzerovector = new Vector2(0, 0);
                //Projectile.NewProjectile(projectile.position, tempzerovector, 624, projectile.damage*3, projectile.knockBack*3, projectile.owner);
                projectile.timeLeft = Math.Min(projectile.timeLeft, 60);
                //projectile.Kill();
            }
        }
    }
}
[doublepost=1487031823,1487031310][/doublepost]
Hi, I'm trying to make my wings glow fullbright. I searched this thread and found someone else had the same problem with projectiles, but the code just isn't working for me.
Ninja edit: Also, while I'm here, is there a way to add hoverboard functionality to my wings?
Later ninja edit: Oh, and can I make their rarity rainbow? -2, -3, 12, and 13 don't work.
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LithoVanities.Items
{
    public class InfinityWings : ModItem
    {
        public override Color? GetAlpha(Color lightColor)
        {
            return Color.White;
        }
    
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Wings);
            return true;
        }
    
        public override void SetDefaults()
        {
            item.name = "Infinity Wings";
            item.width = 30;
            item.height = 28;
            item.toolTip = "These mythic wings grant the wearer the ability to fly forever-";
            item.toolTip2 = "or at least, for 31 years straight.";
            item.value = 1000000;
            item.rare = 12;
            item.accessory = true;
        }
    
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            player.wingTimeMax = 999999999;
        }

        public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
            ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
        {
            ascentWhenFalling = 0.85f;
            ascentWhenRising = 0.10f;
            maxCanAscendMultiplier = 1f;
            maxAscentMultiplier = 2f;
            constantAscend = 0.135f;
        }

        public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
        {
            speed = 10f;
            acceleration *= 2.8f;
        }
    
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.SoulofFlight, 99);
            recipe.AddIngredient(ItemID.LunarBar, 20);
            recipe.AddIngredient(ItemID.FragmentVortex, 7);
            recipe.AddIngredient(ItemID.FragmentNebula, 7);
            recipe.AddIngredient(ItemID.FragmentSolar, 7);
            recipe.AddIngredient(ItemID.FragmentStardust, 7);
            recipe.AddTile(TileID.LunarCraftingStation);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
actually, those wings only allow you to fly for about 193 days
 
actually, those wings only allow you to fly for about 193 days
Realized that after I made them. The time limit doesn't seem to indicate seconds- so, then, what does it indicate?

For anyone else, I still haven't solved that glow issue, though.
 
Realized that after I made them. The time limit doesn't seem to indicate seconds- so, then, what does it indicate?

For anyone else, I still haven't solved that glow issue, though.
Time in Terraria is mainly calculated in what everyone likes to call 'ticks' (or updates).
This basically resembles FPS. Terraria has 60 'ticks' per second.
So to calculate to seconds you basically have to divide all your timers by 60 (flight time counts as a timer).
 
Is there any way to check another mods variables? In my case I'm trying to check if calamity's demon trophy/celestial onion is active.
 
i know this is like my 5th time asking but has anyone found how to fix my problem. Whenever i pickup any item that isnt a coin my game continues but im frozen in place i cant do anything and i cant take any damage. i can still go in my inventory and move stuff i just cant do :red:
 
i know this is like my 5th time asking but has anyone found how to fix my problem. Whenever i pickup any item that isnt a coin my game continues but im frozen in place i cant do anything and i cant take any damage. i can still go in my inventory and move stuff i just cant do :red:
Are you playing with mods? If you are, have you tried disabling them all (and made a new character/world)?
If you do not have any mods enabled have you tried a clean Terraria+tModLoader install?
 
Hi, I am making healing book (no attack, just left click for heal and 10 mana cost), but I tried to do some from dual use weapon tutorial but it wasnt working, so I am asking for help, how can I write to heal my player in this code??

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

namespace BrokenHeartMod.Items
{
public class HealingBook : ModItem
{
public override void SetDefaults()
{
item.name = "Healing Book";
item.width = 24;
item.height = 28;
item.toolTip = "This book heals player, but costs 10 mana.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.value = 100;
item.rare = 3;
item.mana = 10;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.useTurn = true;

}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "PaperHeart", 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}


Thank you :)
 
Hi, I am making healing book (no attack, just left click for heal and 10 mana cost), but I tried to do some from dual use weapon tutorial but it wasnt working, so I am asking for help, how can I write to heal my player in this code??

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

namespace BrokenHeartMod.Items
{
public class HealingBook : ModItem
{
public override void SetDefaults()
{
item.name = "Healing Book";
item.width = 24;
item.height = 28;
item.toolTip = "This book heals player, but costs 10 mana.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.value = 100;
item.rare = 3;
item.mana = 10;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.useTurn = true;

}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "PaperHeart", 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}


Thank you :)
item.healLife = 10; in the SetDefaults method.
 
And, how is possible that my items sometimes stack to 2 or more and sometimes i have 3 of the same item but in 3 slots? :/ And It didnt change value of items I need to craft when I changed it in code :eek: (I reloaded 1261 times)
 
And, how is possible that my items sometimes stack to 2 or more and sometimes i have 3 of the same item but in 3 slots? :/ And It didnt change value of items I need to craft when I changed it in code :eek: (I reloaded 1261 times)
Which item are you talking about in this case? Could you show us the code?
 
I have this with every item I need to stack..

But this one is most buggy:

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

namespace BrokenHeartMod.Items
{
public class PaperHeart : ModItem
{
public override void SetDefaults()
{
item.name = "Paper Heart";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip("Used for crafting! ");
item.value = 1250;
item.rare = 1;
}
}
}
 
I have this with every item I need to stack..

But this one is most buggy:

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

namespace BrokenHeartMod.Items
{
public class PaperHeart : ModItem
{
public override void SetDefaults()
{
item.name = "Paper Heart";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip("Used for crafting! ");
item.value = 1250;
item.rare = 1;
}
}
}
That's strange. Are you able to merge the different stacks? Does this happen with vanilla items too (maybe some other mod interferring)?
 
I have just this one mod... I tried to collect other items, but only mod items are bugging. It happens after I changed name of Mod.. But I completely rewrite all, what I could. Before i renamed mod, i put 10 items to craft 1 other item - and after i renamed i rewrote it to 5 items to craft 1 other item.. But nothing happens, mod is renamed but still 10 items to craft event it isnt in code. And as I said, I am reloading.. I dont know :d

Is it possible that mod duplicated itself? :DD

E1: ahh, good news, I found some old files named YourModName in Mods and I deleted them and now everything works.. :D
 
Last edited:
Back
Top Bottom