tModLoader Official tModLoader Help Thread

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:
Any ETA for this for 1.4.2?
 
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
 
Now there is another problem after i added it to the weapon(i eliminated it from the projectile)
View attachment 329464

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]
Set it to "position.X" and "velocity.X" and "position.Y" and "velocity.Y" instead of ".x" and ".y"

my mistake, sorry
 
Hey everyone, I'm fairly new to Terraria modding and today I ran into an issue I couldn't find a forum or answer for. The issue was not a visible code error, but it occured when I clicked "build and reload" on my mod.

C#:
[Thread Pool Worker/ERROR] [tML]: Value cannot be null.
Parameter name: document
System.ArgumentNullException: Value cannot be null.
Parameter name: document
  at Mono.Cecil.Cil.SequencePoint..ctor (Int32 offset, Document document) [0x00009] in data-0x7fa7d235e000
  at Mono.Cecil.SignatureReader.ReadSequencePoints (Document document) [0x000f9] in data-0x7fa7d235e000
  at Mono.Cecil.MetadataReader.ReadSequencePoints (MethodDefinition method) [0x0004e] in data-0x7fa7d235e000
  at Mono.Cecil.Cil.PortablePdbReader.ReadSequencePoints (MethodDebugInformation method_info) [0x00000] in data-0x7fa7d235e000
  at Mono.Cecil.Cil.PortablePdbReader.Read (MethodDefinition method) [0x00007] in data-0x7fa7d235e000
  at Mono.Cecil.ImmediateModuleReader.ReadMethodsSymbols (TypeDefinition type, ISymbolReader symbol_reader) [0x0003d] in data-0x7fa7d235e000
  at Mono.Cecil.ImmediateModuleReader.ReadTypesSymbols (Collection[T] types, ISymbolReader symbol_reader) [0x00029] in data-0x7fa7d235e000
  at Mono.Cecil.ImmediateModuleReader.ReadTypesSymbols (Collection[T] types, ISymbolReader symbol_reader) [0x0001b] in data-0x7fa7d235e000
  at Mono.Cecil.ImmediateModuleReader.ReadSymbols (ModuleDefinition module) [0x00010] in data-0x7fa7d235e000
  at Mono.Cecil.ModuleWriter.Write (ModuleDefinition module, Disposable[T] stream, WriterParameters parameters) [0x00039] in data-0x7fa7d235e000
  at Mono.Cecil.ModuleWriter.WriteModule (ModuleDefinition module, Disposable[T] stream, WriterParameters parameters) [0x00002] in data-0x7fa7d235e000
  at Mono.Cecil.ModuleDefinition.Write (String fileName, WriterParameters parameters) [0x00017] in data-0x7fa7d235e000
  at Mono.Cecil.AssemblyDefinition.Write (String fileName, WriterParameters parameters) [0x00000] in data-0x7fa7d235e000
  at Terraria.ModLoader.Core.ModCompile.BuildModForPlatform (BuildingMod mod, Boolean xna) [0x0025d] in tModLoader.exe
  at Terraria.ModLoader.Core.ModCompile.Build (BuildingMod mod) [0x000d0] in tModLoader.exe
  at Terraria.ModLoader.Core.ModCompile.Build (String modFolder) [0x00008] in tModLoader.exe
  at Terraria.ModLoader.UI.UIBuildMod+<>c__DisplayClass5_0.<Build>b__0 (ModCompile mc) [0x00000] in tModLoader.exe
  at Terraria.ModLoader.UI.UIBuildMod.BuildMod (Action[T] buildAction, Boolean reload) [0x0003a] in tModLoader.exe

The code itself is:

C#:
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using System.Collections.Generic;
using System.IO;

namespace HollowKnightContent
{

    public class HallownestWorld : ModWorld
    {

        #region Generation

        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int shiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if(shiniesIndex != -1)
            {
                tasks.Insert(shiniesIndex + 1, new PassLegacy("Pale Ore Spawn", GeneratePaleOre));
            }
        }

        private void GeneratePaleOre(GenerationProgress progress)
        {
            progress.Message = "Conjuring Pale Ore";
            for (var i = 0; i < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); i++)
            {
                int x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
                int y = WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY - 500);

                WorldGen.TileRunner(x, y, WorldGen.genRand.Next(1, 3), WorldGen.genRand.Next(3, 6),
                    ModContent.TileType<Tiles.PaleOre.PaleOre>());
            }
        }

        #endregion
    }
}

Thanks in advance :D
 
Hi Terraria forums,

After hours of trying to self-diagnose to no avail, I'm coming here with a couple glaring issues running tModLoader:

1. tModLoader suffers from abnormally low framerates.

I run a GTX 1070 and an i5-11400. Running Terraria 1.4 at 1440p fullscreen, I don't dip below 144 fps. However, running tModLoader at 1440p fullscreen, I'm sitting around 60-70 fps without ANY mods. These numbers are coming after a fresh reinstall of Windows so I don't believe there's any external conflict there.

The one significant difference between the two is that running Task Manager in the background, I've noticed that Terraria utilizes only 20% of my GPU / 15 - 20% CPU while in-game and tModLoader utilizes 80% of the GPU / <10% CPU. If I had to guess this is very much related to the framerate issue, but I don't have the expertise to figure out how or why. I've tried changing the priority of the executable in Task Manager with no change in performance. The framerate in tModLoader increases when switching to 1080p but it still does not reach 144hz in any scene, so framerate does scale based on resolution as it should. If I had to make any guesses it has something to do with the tModLoader code and *potentially* compatibility with my brand new 11400 CPU, but that's all I can think of. Any help there?

2. tModLoader running with Calamity - No Music, Calamity - Music, Cataclysm, Magic Storage, and Boss Checklist (all to-date) CTDs at random at every stage of the game:

I've supplied the client.log from the most recent crash. I crashed three times in short succession just after joining my friend's server.

Playing with two friends in a multiplayer server hosted by one of them, since we have started playing I have crashed at random with increasing frequency especially after entering Hardmode. It happens no matter what I'm doing but is especially problematic during boss battles. When tModLoader crashes like this it's always 1. the screen freezes, 2. the audio cuts out/glitches and repeats, 3. the entire screen turns black (even if I'm playing in a small window), and 4. the screen returns and the executable has either closed or continues functioning, only to eventually CTD, returning no crash log. If a YouTube video is playing in the background I've noticed that the video there sometimes turns a blank green, like my entire computer briefly crashes. To note, neither of my friends have crashed a single time, leading me to believe that my issue is entirely unique to my computer and could possibly be related to the framerate issue.

I've supplied all the info I can think of but if requested I can try to supply more. If anyone out there can help me out that would be greatly appreciated!
 

Attachments

Last edited:
Back
Top Bottom