tModLoader Official tModLoader Help Thread

can any one help me to install tModLoader on PC, i have GOG version and i keep get this error message "View attachment 280443" and i also tried to rename the exe file to "Terraria_1.4.0.5.exe", i was getting the same error message then i changed it to "Terraria_1.4.0.5.exe" and the error message was saying this "
[14:09:26] [1/INFO] [tML]: Starting tModLoader v0.11.7.4 Windows client (6/24/2020)
[14:09:27] [1/INFO] [tML]: Running on NetFramework 4.8
[14:09:27] [1/INFO] [tML]: Executable: C:\GOG Games\tModLoader\tModLoader.exe
[14:09:27] [1/INFO] [tML]: Working Directory: C:\GOG Games\tModLoader
[14:09:27] [1/INFO] [tML]: Launch Parameters:
[14:09:27] [1/DEBUG] [tML]: Assembly Resolve: -> MonoMod.RuntimeDetour, Version=20.5.14.1, Culture=neutral, PublicKeyToken=null
[14:09:27] [1/DEBUG] [tML]: Assembly Resolve: MonoMod.RuntimeDetour, Version=20.5.14.1, Culture=neutral, PublicKeyToken=null -> MonoMod.Utils, Version=20.5.14.1, Culture=neutral, PublicKeyToken=null
[14:09:27] [1/DEBUG] [tML]: Assembly Resolve: MonoMod.RuntimeDetour, Version=20.5.14.1, Culture=neutral, PublicKeyToken=null -> Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e
[14:09:27] [1/DEBUG] [tML]: Assembly Resolve: -> Ionic.Zip.Reduced, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c
[14:09:27] [1/DEBUG] [tML]: Assembly Resolve: -> Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
[14:09:27] [1/INFO] [tML]: Checking GOG or manual installation...
[14:09:27] [1/FATAL] [tML]: ..\Terraria\Terraria_1.4.0.4.exe is not the unmodified Terraria executable.

GOG installs must have the unmodified Terraria executable to function.

If you patched the .exe, you can create a copy of the original exe and name it "Terraria_v<VERSION>.exe" so on all methods i did i am keep getting this error message that is say "Terraria_1.4.0.4.exe is not the unmodified Terraria executable" or "Terraria.exe is not the unmodified Terraria executable" so how i can make it works can any one help me.
Try to downgrade 1 version in GOG and see if it works. TML is not always compatible with all of them
 
I have a problem with the block that, when it breaks, leaves dirt particles when I break it. how do I change it, maybe for something from the game or something personalized?
 
I'm trying to implement a boss in the game, but for some reason, whenever he appears, he disappears immediately, I checked everything and I can't solve the problem (I'm new to mod, programming)


using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Private. NPCs
{

[AutoloadBossHead]
public class Private : ModNPC
{


public override void SetDefaults()
{
npc.aiStyle = 5;
npc.lifeMax = 7000;
npc.damage = 15;
npc.defense = 20;
npc.knockBackResist = 0.5f;
npc.width = 130;
npc.height = 264;
animationType = NPCID.DemonEye;
Main.npcFrameCount[npc.type] = 2;
npc.value = Item.buyPrice(0, 40, 75, 45);
npc.npcSlots = 1f;
npc.boss = true;
npc.lavaImmune = true;
npc.noGravity = true;
npc.noTileCollide = true;
npc.HitSound = SoundID.NPCHit9;
npc.DeathSound = SoundID.NPCDeath1;
npc.buffImmune[24] = true;
music = MusicID.Boss2;
npc.netAlways = true;
}
public override void BossLoot(ref string name, ref int potionType)
{
potionType = ItemID.LesserHealingPotion;
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Private"));
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.700f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.20f);
}
}
}
Ai type, Add that
 
Hey I'm having a very odd issue.
Recently I moved over to Linux for several reason and I have been trying to get TModLoader setup and working.
It launches fine but there is no sound or music! This is really kinda annoying. Is there some way to fix this?
Using the Steam version, and everything seems fine. No errors in the logs or anything.
 
is there any way to make a sword that does multiple (preferribly 3) times the damage when the player holding it is dashing/going really fast?
The player has a velocity variable, so in the swords code you could override ModifyHitNPC and do this code:
C#:
public override void ModifyHitNPC (Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
{
    // Multiply the damage of the sword by 3x when the players velocity is above 1.2f
    if (player.velocity > 1.2f)
    {
        damage *= 3;
    }
}
You can change the 1.2f to whatever
 
I’m working on a flower that will replace the corruption Deathweed, it only spawns in crimson, and I can make the flower, I just need to know how to get the Deathweed to stop spawning it the world is crimson, and spawn if it’s corruption.
 
I'm trying to make a projectile that does lifesteal, but it says no suitable method found to override, if I remove the player player and the statlife line it works fine and the projectile inflicts ichor, but how can i make it do lifesteal as well?

Code:
  public override void OnHitNPC(Player Player, NPC target, int damage, float knockBack, bool crit)
        {
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
 
The player has a velocity variable, so in the swords code you could override ModifyHitNPC and do this code:
C#:
public override void ModifyHitNPC (Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
{
    // Multiply the damage of the sword by 3x when the players velocity is above 1.2f
    if (player.velocity > 1.2f)
    {
        damage *= 3;
    }
}
You can change the 1.2f to whatever
im curious, could you make it increase mana cost for a weapon? Could you increase knockback?Could you make a weapon only usable while motionless?
 
I'm trying to make a projectile that does lifesteal, but it says no suitable method found to override, if I remove the player player and the statlife line it works fine and the projectile inflicts ichor, but how can i make it do lifesteal as well?

Code:
  public override void OnHitNPC(Player Player, NPC target, int damage, float knockBack, bool crit)
        {
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
The "no suitable method found to override" happened to me to when I added player to any overrides. Simply change 'Override' to 'Virtual'.
So Instead of this:
Code:
  public override void OnHitNPC(Player Player, NPC target, int damage, float knockBack, bool crit)
        {
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
It is now this:
Code:
  public virtual void OnHitNPC(Player Player, NPC target, int damage, float knockBack, bool crit)
        {
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
Alternatively / If that doesn't work, you can establish Player as the owner of the projectile: Player player = Main.player[projectile.owner];

So It would be like this:
Code:
  public override void OnHitNPC(NPC target, int damage, float knockBack, bool crit)
        {
            Player player = Main.player[projectile.owner];
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
Hope that helps! :)
 
Last edited:
The "no suitable method found to override" happened to me to when I added player to any overrides. Simply change 'Override' to 'Virtual'.
So Instead of this:
Code:
  public override void OnHitNPC(Player Player, NPC target, int damage, float knockBack, bool crit)
        {
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
It is now this:
Code:
  public virtual void OnHitNPC(Player Player, NPC target, int damage, float knockBack, bool crit)
        {
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
Alternatively / If that doesn't work, you can establish Player as the owner of the projectile: Player player = Main.player[projectile.owner];

So It would be like this:
Code:
  public override void OnHitNPC(NPC target, int damage, float knockBack, bool crit)
        {
            Player player = Main.player[projectile.owner];
            Player.statLife += damage / 100;
            target.AddBuff(BuffID.Ichor, 1000);
        }
Hope that helps! :)
Tysm it worked!
now the next thing I'm trying to make is an accessory that gives life steal on all your damages when equipped, like the spectre hood set bonus, but I want it to work on all damage types and I want to customize the percentage of lifesteal, I tried ghostheal but idk if there are any ways to modify it so it works with all damage types and different lifesteal percentage?
part of code:
Code:
  public override void UpdateAccessory(Player player, bool hideVisual)
        {
            player.statLifeMax2 += 100;
            player.statManaMax += 100;
            player.allDamage += 2;
            player.lifeRegen += 0;
            player.lifeSteal += 9999999999999;
            player.AddBuff(Terraria.ID.BuffID.Ichor, 1);
            player.ghostHeal = true;
            player.ghostDmg = 999f;
        }
 
*** edit *** I fixed it by switching the stage it uses to "tunnels" *** edit ***
*** edit edit *** this means it doesn't crash, but it has no effect on the world *** edit edit ***
*** edit edit edit *** I've got the tile generation to work, but not detecting the size of the world or creating air blocks *** edit edit edit ***

I'm createing a terrain generator to replace the "terrain" step in world generation.

I get this error when I try to generate a new world:
Code:
[17:15:51] [8/INFO] [StatusText]: Resetting game objects
[17:15:52] [8/INFO] [Terraria]: Generating World: 3
[17:15:52] [8/WARN] [tML]: Silently Caught Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Terraria.WorldGen.<>c.<generateWorld>b__260_2(GenerationProgress <p0>)
   at Terraria.GameContent.Generation.PassLegacy.Apply(GenerationProgress progress)
   at Terraria.World.Generation.WorldGenerator.GenerateWorld(GenerationProgress progress)
   at Terraria.WorldGen.generateWorld(Int32 seed, GenerationProgress customProgressObject)
   at Terraria.WorldGen.do_worldGenCallBack(Object threadContext)
   at Terraria.WorldGen.worldGenCallBack(Object threadContext)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

[17:15:52] [8/ERROR] [tML]: A problem was encountered during world generation
Tunnels
System.NullReferenceException: Object reference not set to an instance of an object.
   at Terraria.WorldGen.<>c.<generateWorld>b__260_2(GenerationProgress <p0>)
   at Terraria.GameContent.Generation.PassLegacy.Apply(GenerationProgress progress)
   at Terraria.World.Generation.WorldGenerator.GenerateWorld(GenerationProgress progress)
[17:15:52] [8/ERROR] [Terraria]: A problem was encountered during world generation
System.NullReferenceException: Object reference not set to an instance of an object.
   at Terraria.World.Generation.WorldGenerator.GenerateWorld(GenerationProgress progress)
   at Terraria.WorldGen.generateWorld(Int32 seed, GenerationProgress customProgressObject)
   at Terraria.WorldGen.do_worldGenCallBack(Object threadContext)
   at Terraria.WorldGen.worldGenCallBack(Object threadContext)
[17:16:47] [1/DEBUG] [tML]: Process.Start (UseShellExecute = True): "C:\Users\jaspe\Documents\My Games\Terraria\ModLoader\Logs\client.log"

My code looks like this:

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using Terraria.Map;
using On.Terraria.IO;
using System.Security.Cryptography.X509Certificates;

namespace JasperMod.worldgen
{
    class worldgen2 : ModWorld
    {
        private const int saveVersion = 0;
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int TerrainGen = tasks.FindIndex(genpass => genpass.Name.Equals("Tunnels"));
            tasks[TerrainGen] = new PassLegacy("My Terrain", delegate (GenerationProgress progress) {
                int seed = 10; //Main.ActiveWorldFileData.Seed;
                Random randomNumber = new System.Random(seed.GetHashCode());

                int GridWidth = 4200; //Main.ActiveWorldFileData.WorldSizeX;
                int GridHeight = 1200; //Main.ActiveWorldFileData.WorldSizeY;

                float angleVariation = 10f;
                double height;
                double lastHeight = GridHeight / 2;
                double gradient = 0;
                double randomChange;
                
                for (int x = 1; x < GridWidth; x++)
                {
                    randomChange = randomNumber.Next((int)(-angleVariation * 5), (int)((angleVariation * 5) + 1)) / 10;
                    gradient += randomChange;
                    if (gradient > 10 || gradient < -10)
                    {
                        gradient -= randomChange;
                    }
                    height = gradient + lastHeight;
                    if (height < 5) { gradient += 1; }
                    if (height < 1) { height = 1; gradient = 1; }
                    if (height > GridHeight - 12) { gradient -= 1; }
                    if (height > GridHeight) { height = GridHeight; gradient = -1; }

                    for (int y = 1; y < (int)height; y++)
                    {
                        if (y <= (int)height)
                        {
                            if (y <= (int)height - 10) // block
                            { WorldGen.TileRunner(x, (y * -1) + GridHeight, 2, 3, TileID.Titanium, true); }
                            else
                            { WorldGen.TileRunner(x, (y * -1) + GridHeight, 2, 3, TileID.Adamantite, true); }
                        }
                        else
                        {
                            WorldUtils.ClearTile(x, (y * -1) + GridHeight, false); // air
                        }
                    }
                }
            });
        }
    }
}
 
Last edited:
anybody know how to make a stackable boomerang? also, is there a way to make it do extra damage if you have a full stack?
 
Ok so i want to make an equipment that will heal you for a tenth of the damage dealt. Here's the code:

Code:
     public override void OnHitNPC(Player player, int damage, float knockback, bool crit)
        {
              int amountToHeal = damage / 10; // Heal tenth of damage
                if(amountToHeal + player.statLife > player.statLifeMax2)
                    amountToHeal = player.statLifeMax2 - player.statLife; // If healing is larger than health currently missing.
                player.statLife += amountToHeal;
        }

It keeps saying that there was no suitable methods to override... Anyone knows how to fix it?
[edit]: When i remove override there's no compiling error but doesn't run the code or something... I really should take C# classes lol
 
I was wondering on how to make a custom NPC inflict a custom buff. I'm making an acid biome and I already made a debuff that makes you lose health and I already have a couple NPCs for the biome so I'm wondering what I can do that makes the NPCs inflict the debuff on contact.
 
Back
Top Bottom