tModLoader Official tModLoader Help Thread

tmodloader keeps giving me this error when building or building and reloading my custom mods how do i fix. i heard that you need to reinstall the net framework but when i try it says i already have it installed and i dont know how to uninstall.
1621967273000.png
 
Last edited:
New to this, I get this every time I hop on my friend's server. Help would be appreciated!
 

Attachments

  • image_2021-05-28_143312.png
    image_2021-05-28_143312.png
    44.7 KB · Views: 101
I was wondering how I could change the set bonus of a vanilla armor set. I would be grateful if someone could tell me how to do this.
(I'm pretty new, I can make basic weapons, armor and accessories but not much else)
 
Hello! I don't know how active it is here but I am trying to write some scripts for TCCI, or terraria content creator integration.

I want to make a command that randomly paints the tiles around me when a specific input. I have the input thing down I am just struggling with the actual script. I can't find if there is a tile variable to color anywhere, or what the variable values would be if I found it. If anyone out there knows a what to do this I am all ears, er eyes i guess. Thanks a bunch!!
 
not sure if the 64bit branch has support here but every time i try and load tmod64bit i am stuck on instantiating mods

tmod32bit works fine
 
I'm actually dumb and can't find anywhere but is there a way to make it so that you know if you kill something?
I'm trying to make an accessory that greatly increases your damage after 50 kills that lasts for 5 seconds and adds a second every kill up to a max of 5 seconds (kudos to whoever gets the reference), I know how I'd do it I Just need to know how to read one kill.
 
looking for some help as my game keeps crashing, mostly when going into new biomes and recently while mining sand.

my active mods are:
Dragon ball terraria
alchemist npc
wing slot
thorium
calamity
calamities vanities
terraria overhaul

crashlog:
6/19/2021 1:54:41 PM
System.NullReferenceException: Object reference not set to an instance of an object.
at Terraria.Main.lookForColorTiles()
at Terraria.Main.DoDraw(GameTime gameTime)
at Terraria.Main.Draw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame_()


it also says that the game keeps running out of memory
 
Last edited:
Hi,

I'm on this thread to ask a question, how do you detect if an NPC is touching a block/on the ground? I'm currently making an enemy that only jumps if it is not in the air.
C#:
                    npc.velocity.Y = 20f;
                    npc.velocity.X = 0f;
                    if (Math.Abs(npc.position.Y - player.position.Y) < 5) {
                        AI_RestTimer = 0;
                        AI_State = State_Charging;
                    }
This code I'm using currently detects if the Y position of the NPC is near the Y position of the player. While the current method is efficient in stopping the enemy from continuously jumping in the air, it creates a whole new problem where if the player is a few blocks below or on top of the enemy, the NPC will freeze and never go into the "Charging" state. If you are willing to help, thank you.
 
Hello, I have a problem. I want to change the location from My Games folder to somewhere else but i don't know how. I've tried using savedirectory command but it told me that it was invalid. Is there any other solution? Just dragging from one folder to the other wouldn't work, right? The system is Win x64 and I'm using tmodloader from steam.


EDIT:
I guess I somehow got a solution. Used symbolic links
EDIT2:
Nope, still doesn't work
EDIT3:
Alright, the problem was that the Tmodloader on Steam is 32bit. Downloading the 64bit version solved the issue.
 
Last edited:
Hi,

I'm on this thread to ask a question, how do you detect if an NPC is touching a block/on the ground? I'm currently making an enemy that only jumps if it is not in the air.
C#:
                    npc.velocity.Y = 20f;
                    npc.velocity.X = 0f;
                    if (Math.Abs(npc.position.Y - player.position.Y) < 5) {
                        AI_RestTimer = 0;
                        AI_State = State_Charging;
                    }
This code I'm using currently detects if the Y position of the NPC is near the Y position of the player. While the current method is efficient in stopping the enemy from continuously jumping in the air, it creates a whole new problem where if the player is a few blocks below or on top of the enemy, the NPC will freeze and never go into the "Charging" state. If you are willing to help, thank you.
I'm no expert, but I did something similar on a projectile with the Collision class. Give Collision.SolidCollision(vector2, int, int) your NPC's position, width and height and it will return a bool based on weather or not it's hitting something.

Hope that works.
 
I'm no expert, but I did something similar on a projectile with the Collision class. Give Collision.SolidCollision(vector2, int, int) your NPC's position, width and height and it will return a bool based on weather or not it's hitting something.

Hope that works.
From what I saw, this is apparently a function/method, or a hook, right? If it is not a difficult task, how could I get a variable from one method and use it in another? And thanks for trying to help, I appreciate that.
 
Does anyone know how to detect if an NPC is in water? I thought it was
C#:
if (npc.wet) {
    //insert code here
}
but that doesn't seem to work.


EDIT: I found the issue! My old code was
C#:
if (npc.wet) {
    npc.velocity.Y -= 0.15; //gravity is -0.1, so this should counteract gravity
}

But it turns out that it works if I do
C#:
if (npc.wet) {
    npc.velocity.Y = 0;
    npc.position.Y -= 5;
}
I'm not quite sure why this happens, but it does.
 
Last edited:
I'm having this problem where the projectile spawns like this, when in reality I want it to appear a little bit in front of the character for example like the Lazer from the Prism in which the lazer spawns in the prism itself?
position.PNG


I basically want it to look like this:

fxbH2vqmJ8SGcZ8pFSzKWrZXsN6Ig5jffjqjo0vAZ1Y.png


This is the code of the projectile:
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;

namespace MySword.Projectiles
{
    public class ExProcyonBlast : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ex Procyon Blast");
        }

        public override void SetDefaults()
        {
            projectile.width = 500;
            projectile.height = 500;
            projectile.scale = 1f;
            projectile.timeLeft = 30;
            projectile.penetrate = 10;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.tileCollide = false;
            projectile.alpha = 55;
            projectile.light = 1f;
            projectile.aiStyle = 4;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(mod.BuffType("OnFire!"), 180, false);
        }
    }
}

I also have another question... can i make it so a melee weapon like a sword shoot a projectile that requires mana only when mana is availible?
Ima rephrase it just in case. Can i make a "sword" shoot projectiles when the mana needed is availible but when mana is not availible still be able to be swong/used.

This is the code of the "sword"
C#:
using Terraria;
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;
namespace MySword.Items
{
    public class TrueLizaverde : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("True Lizaverde");
            Tooltip.SetDefault("3000% Water DMG (Magic). Increases own CRI DMG by 30% for 8s. Water units get an extra 30%");
        }

        public override void SetDefaults()
        {
            item.melee = true;
            item.damage = 250;
            item.useStyle = 1;
            item.useTime = 10;
            item.useAnimation = 10;
            item.knockBack = 5;
            item.value = 30000;
            item.rare = -12;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
            item.width = 175;
            item.height = 175;
            item.scale = 0.35f;
            item.mana = 10;
            item.crit = 97;

            item.shoot = mod.ProjectileType("FrostWaveLizaverde");
            item.shootSpeed = 30f;
        }

        public override void HoldItem(Player player)
        {
            player.itemLocation.Y = player.Center.Y;
            player.itemLocation.X = player.Center.X - 18 * player.direction;
        }

        public override void AddRecipes()
        {
            ModRecipe TrueLizaverderecipe = new ModRecipe(mod);
            TrueLizaverderecipe.AddIngredient(173, 10);
            TrueLizaverderecipe.AddIngredient(381, 10);
            TrueLizaverderecipe.AddIngredient(19, 10);
            TrueLizaverderecipe.AddIngredient(177, 1);


            TrueLizaverderecipe.AddTile(17);
            TrueLizaverderecipe.SetResult(this);
            TrueLizaverderecipe.AddRecipe();
        }
    }
}

Sword is like "sword" bcs its a scythe but i wanted to be as clear as posible so anyone who reads can uderstand.
TrueLizaverde.png

that is the sprite in question.
 
Last edited:
I'm having this problem where the projectile spawns like this, when in reality I want it to appear a little bit in front of the character for example like the Lazer from the Prism in which the lazer spawns in the prism itself?
View attachment 329442

I basically want it to look like this:

View attachment 329447

This is the code of the projectile:
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;

namespace MySword.Projectiles
{
    public class ExProcyonBlast : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ex Procyon Blast");
        }

        public override void SetDefaults()
        {
            projectile.width = 500;
            projectile.height = 500;
            projectile.scale = 1f;
            projectile.timeLeft = 30;
            projectile.penetrate = 10;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.tileCollide = false;
            projectile.alpha = 55;
            projectile.light = 1f;
            projectile.aiStyle = 4;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(mod.BuffType("OnFire!"), 180, false);
        }
    }
}

I also have another question... can i make it so a melee weapon like a sword shoot a projectile that requires mana only when mana is availible?
Ima rephrase it just in case. Can i make a "sword" shoot projectiles when the mana needed is availible but when mana is not availible still be able to be swong/used.

This is the code of the "sword"
C#:
using Terraria;
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;
namespace MySword.Items
{
    public class TrueLizaverde : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("True Lizaverde");
            Tooltip.SetDefault("3000% Water DMG (Magic). Increases own CRI DMG by 30% for 8s. Water units get an extra 30%");
        }

        public override void SetDefaults()
        {
            item.melee = true;
            item.damage = 250;
            item.useStyle = 1;
            item.useTime = 10;
            item.useAnimation = 10;
            item.knockBack = 5;
            item.value = 30000;
            item.rare = -12;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
            item.width = 175;
            item.height = 175;
            item.scale = 0.35f;
            item.mana = 10;
            item.crit = 97;

            item.shoot = mod.ProjectileType("FrostWaveLizaverde");
            item.shootSpeed = 30f;
        }

        public override void HoldItem(Player player)
        {
            player.itemLocation.Y = player.Center.Y;
            player.itemLocation.X = player.Center.X - 18 * player.direction;
        }

        public override void AddRecipes()
        {
            ModRecipe TrueLizaverderecipe = new ModRecipe(mod);
            TrueLizaverderecipe.AddIngredient(173, 10);
            TrueLizaverderecipe.AddIngredient(381, 10);
            TrueLizaverderecipe.AddIngredient(19, 10);
            TrueLizaverderecipe.AddIngredient(177, 1);


            TrueLizaverderecipe.AddTile(17);
            TrueLizaverderecipe.SetResult(this);
            TrueLizaverderecipe.AddRecipe();
        }
    }
}

Sword is like "sword" bcs its a scythe but i wanted to be as clear as posible so anyone who reads can uderstand.
View attachment 329445
that is the sprite in question.
You would add in
C#:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) {
    Projectile.NewProjectile(position.x + velocity.x * multiplier, position.y + velocity.y * multiplier, speedX, speedY, type, damage, knockBack, player.whoAmI);
    return false;
}
.

What this does, is it overrides the vanilla projectile shooting AI (by calling "return false;" at the end) and makes a new AI, where it moves the projectile forwards by the velocity vector times a multiplier value (Which you can set to be whatever you want, just make sure they are both the same number)
 
From what I saw, this is apparently a function/method, or a hook, right? If it is not a difficult task, how could I get a variable from one method and use it in another? And thanks for trying to help, I appreciate that.
Collision.SolidCollision is a function. I don't know exactly what you mean by get a variable from one method and use it in another, but what I was suggesting you do is something like the following.
C#:
if (Collision.SolidCollision(npc.position, npc.width, npc.height))
{
    //do the thing
}
That should return true if your NPC is colliding with anything.
 
You would add in
C#:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) {
    Projectile.NewProjectile(position.x + velocity.x * multiplier, position.y + velocity.y * multiplier, speedX, speedY, type, damage, knockBack, player.whoAmI);
    return false;
}
.

What this does, is it overrides the vanilla projectile shooting AI (by calling "return false;" at the end) and makes a new AI, where it moves the projectile forwards by the velocity vector times a multiplier value (Which you can set to be whatever you want, just make sure they are both the same number)
idk wut i did to mess it up(im new to programming) but it didnt work
erroe.PNG


this is the code:
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;

namespace MySword.Projectiles
{
    public class ExProcyonBlast : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ex Procyon Blast");
        }

        public override void SetDefaults()
        {
            projectile.width = 500;
            projectile.height = 500;
            projectile.scale = 1f;
            projectile.timeLeft = 30;
            projectile.penetrate = 10;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.tileCollide = false;
            projectile.alpha = 55;
            projectile.light = 1f;
            projectile.aiStyle = 4;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Projectile.NewProjectile(position.x + velocity.x * multiplier, position.y + velocity.y * multiplier, speedX, speedY, type, damage, knockBack, player.whoAmI);
            return false;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            //The debuff inflicted is the modded debuff Ethereal Flames. 180 is the duration in frames: Terraria runs at 60 FPS, so that's 3 seconds (180/60=3). To change the modded debuff, change EtherealFlames to whatever the buff is called; to add a vanilla debuff, change mod.BuffType("EtherealFlames") to a number based on the terraria buff IDs. Some useful ones are 20 for poison, 24 for On Fire!, 39 for Cursed Flames, 69 for Ichor, and 70 for Venom.
            target.AddBuff(mod.BuffType("OnFire!"), 180, false);
        }
    }
}
 
idk wut i did to mess it up(im new to programming) but it didnt work
View attachment 329456

this is the code:
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;

namespace MySword.Projectiles
{
    public class ExProcyonBlast : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ex Procyon Blast");
        }

        public override void SetDefaults()
        {
            projectile.width = 500;
            projectile.height = 500;
            projectile.scale = 1f;
            projectile.timeLeft = 30;
            projectile.penetrate = 10;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.tileCollide = false;
            projectile.alpha = 55;
            projectile.light = 1f;
            projectile.aiStyle = 4;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Projectile.NewProjectile(position.x + velocity.x * multiplier, position.y + velocity.y * multiplier, speedX, speedY, type, damage, knockBack, player.whoAmI);
            return false;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            //The debuff inflicted is the modded debuff Ethereal Flames. 180 is the duration in frames: Terraria runs at 60 FPS, so that's 3 seconds (180/60=3). To change the modded debuff, change EtherealFlames to whatever the buff is called; to add a vanilla debuff, change mod.BuffType("EtherealFlames") to a number based on the terraria buff IDs. Some useful ones are 20 for poison, 24 for On Fire!, 39 for Cursed Flames, 69 for Ichor, and 70 for Venom.
            target.AddBuff(mod.BuffType("OnFire!"), 180, false);
        }
    }
}
You put it in the weapon code, not the projectile code.

Sorry, probably should have specified that
 
You put it in the weapon code, not the projectile code.

Sorry, probably should have specified that
Now there is another problem after i added it to the weapon(i eliminated it from the projectile)
errorcode.PNG


this is the code of the weapon
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;
namespace MySword.Items
{
    public class TrueFomalhautEx : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("True Fomalhaut");
            Tooltip.SetDefault("7200% Fire DMG (Magic). Increases own DMG by 50% for 2s.");
        }

        public override void SetDefaults()
        {
            item.buffType = 159;
            item.buffTime = 120;
            item.magic = true;
            item.noMelee = true;
            item.damage = 250;
            item.useStyle = 5;
            item.useTime = 5;
            item.useAnimation = 5;
            item.knockBack = 2;
            item.value = 5000;
            item.rare = -12;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
            item.width = 64;
            item.height = 64;
            item.mana = 15;
            item.scale = 0.33f;

            item.shoot = item.shoot = mod.ProjectileType("ExProcyonBlast");
            item.shootSpeed = 1f;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Projectile.NewProjectile(position.x + velocity.x * multiplier, position.y + velocity.y * multiplier, speedX, speedY, type, damage, knockBack, player.whoAmI);
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe TrueFomalhautExrecipe = new ModRecipe(mod);
            TrueFomalhautExrecipe.AddIngredient(2, 1);
            TrueFomalhautExrecipe.AddIngredient(29, 1);
            TrueFomalhautExrecipe.AddIngredient(22, 10);
            TrueFomalhautExrecipe.AddIngredient(65, 3);
            TrueFomalhautExrecipe.AddIngredient(19, 5);

            TrueFomalhautExrecipe.AddTile(17);
            TrueFomalhautExrecipe.SetResult(this);
            TrueFomalhautExrecipe.AddRecipe();
        }
    }
}[/CODE=csharp]
 
Last edited:
In TModLoader when I try to start the Old One's Army, the Eternia Portals won't spawn. When I tried this on the unofficial TModLoader 64-bit version it crashed with no error screen. Any advice on how to fix this?
Details: my pc is Windows 7, when I start the OOA on the official 32-bit version the portals just won't spawn. when I do this on the unofficial 64-bit version, the portals spawn, the goblins spawn and after like 1 or 2 seconds it crashes. I was messing with the DLL libraries before to fix Terraria not launching, and after I messed around with things, Terraria launched with no sound. TModLoader 32-bit doesn't launch with sound as well, and the unofficial 64-bit version does output the sound, it's made on FNA and not XNA. Any advice on how do I fix this?

P.S. Sorry for my probably bad grammar, English is not my native language
 
Back
Top Bottom