tModLoader Official tModLoader Help Thread

Hey there!

I'm currently working on a mod which requires that I replace the floating damage text with custom text that has a specified color. I created a GlobalNPC class to override the StrikeNPC() method so that I can load the custom text correctly upon damaging an NPC. However, the vanilla damage text also loads in front of it.

I am not quite sure how I could disable the vanilla text. After scouring the vanilla source code, I believe I have to make use of the clearAll() function inside of the CombatText class, but my efforts have proven to be fruitless thus far.

My apologies if I've overlooked any obvious details, but reading over the wiki a few times doesn't seem to have much information pertaining to this specific issue.

I would greatly appreciate any help on the matter! Thank you!
 
Hey there!

I'm currently working on a mod which requires that I replace the floating damage text with custom text that has a specified color. I created a GlobalNPC class to override the StrikeNPC() method so that I can load the custom text correctly upon damaging an NPC. However, the vanilla damage text also loads in front of it.

I am not quite sure how I could disable the vanilla text. After scouring the vanilla source code, I believe I have to make use of the clearAll() function inside of the CombatText class, but my efforts have proven to be fruitless thus far.

My apologies if I've overlooked any obvious details, but reading over the wiki a few times doesn't seem to have much information pertaining to this specific issue.

I would greatly appreciate any help on the matter! Thank you!

Perhaps if you simply override the combat text colour? Would that work for what you want to do? Perhaps you could clearAll() and use the CombatText.NewText function? Sorry if this isn't very helpful
 
Perhaps if you simply override the combat text colour? Would that work for what you want to do? Perhaps you could clearAll() and use the CombatText.NewText function? Sorry if this isn't very helpful

Unfortunately, I checked the source code for the CombatText class and the colors all have the readonly modifier, preventing any changes to the colors. I couldn't find any classes or methods that allow one to override the colors, I only located the overrideColor() method which is for tooltips.

In the StrikeNPC() method, the sequence in which I called the methods was as follows:

Code:
StrikeNPC(...)
{
    ...
    CombatText.clearAll();
    CombatText.NewText(...);
    return true;
}

This code results in no changes to the original behavior; I simply get two copies of the damage text, one drawn using the vanilla color, the other in the custom color.

I also tried to clearAll() after drawing the text for good measure, but that simply clears the text which I draw, not the vanilla text, as expected.

Thanks for the advice though!
 
Unfortunately, I checked the source code for the CombatText class and the colors all have the readonly modifier, preventing any changes to the colors. I couldn't find any classes or methods that allow one to override the colors, I only located the overrideColor() method which is for tooltips.

In the StrikeNPC() method, the sequence in which I called the methods was as follows:

Code:
StrikeNPC(...)
{
    ...
    CombatText.clearAll();
    CombatText.NewText(...);
    return true;
}

This code results in no changes to the original behavior; I simply get two copies of the damage text, one drawn using the vanilla color, the other in the custom color.

I also tried to clearAll() after drawing the text for good measure, but that simply clears the text which I draw, not the vanilla text, as expected.

Thanks for the advice though!
That is strange, when I used CombatText.clearAll() in game, it cleared all text including vanilla text.
Ok, another suggestion: In the OnHitNPC hook in your ModPlayer file, you could CombatText.clearAll() and then do CombatText.NewText(..)? Idk if that would work any better though.
Actually It's probably not a good idea to use CombatText.clearAll() as it clears all combat text, including already existing text, and just created text, which is probably not so good.

Another idea: You make it so that you cannot actually hit enemies, but detect when your weapon hitboxes intersect with npc hitboxes, and you use a custom method for hitting npc's that makes it how you want. This would allow more flexibility but would probably be very difficult/time consuming to do.

Another idea: CombatText.clearAll() text and use an alternative method for spawning text (not CombatText.NewText(...)
I hope this helped :), sorry if not
 
I was making a sword that shoots a projectile out. When I run the code in game I get this error message;
Silently Caught Exception: Object reference not set to an instance of an object. at MiniBiomesGalore.Projectiles.SakuraPetal.SetDefaults() at Terraria.ModLoader.ModCompile.<>c.<ActivateExceptionReporting>b__14_0(Object sender, FirstChanceExceptionEventArgs exceptionArgs)
at MiniBiomesGalore.Projectiles.SakuraPetal.SetDefaults()
at Terraria.ModLoader.ProjectileLoader.SetDefaults(Projectile projectile, Boolean createModProjectile)
at Terraria.Projectile.SetDefaults(Int32 Type)
at Terraria.Projectile.NewProjectile(Single X, Single Y, Single SpeedX, Single SpeedY, Int32 Type, Int32 Damage, Single KnockBack, Int32 Owner, Single ai0, Single ai1)
at Terraria.Player.ItemCheck(Int32 i)
at Terraria.Player.ItemCheckWrapped(Int32 i)
at Terraria.Player.Update(Int32 i)
at Terraria.Main.DoUpdate(GameTime gameTime)
at Terraria.Main.Update(GameTime gameTime)
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(String[] args, Boolean monoArgs)
at Terraria.WindowsLaunch.Main(String[] args)
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Terraria;
using Terraria.ModLoader;

namespace MiniBiomesGalore.Projectiles
{

public class SakuraPetal : ModProjectile
{
public override void SetDefaults()
{
DisplayName.SetDefault("Sakura Petal");
projectile.width = 9;
projectile.height = 7;
projectile.timeLeft = 180;
projectile.penetrate = 3;
projectile.friendly = true;
projectile.hostile = false;
projectile.tileCollide = false;
projectile.melee = true;
projectile.ignoreWater = true;
projectile.light = 1f;
projectile.aiStyle = 0;
projectile.stepSpeed = 3;
}
}
}
using Terraria.ID;
using Terraria.ModLoader;

namespace MiniBiomesGalore.Items
{
public class Sakura : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Sakura");
Tooltip.SetDefault("Holds the power of 1000 cherry blossoms");
}
public override void SetDefaults()
{
item.damage = 45;
item.melee = true;
item.width = 48;
item.height = 52;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = mod.ProjectileType("SakuraPetal");
item.shootSpeed = 10;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
Hello people, I've found a solution to my previous question "How can I make projectiles behave like shadowflame hex doll tentacles?"

But now I am trying to create my own custom grass, and I have run into problems. I have managed to make my grass spread, and otherwise behave like grass (I may add plants and trees at some point), but in game the grass blocks look wrong. I have noticed that grass blocks have a different tile spritesheet to most blocks in Terraria, and that it contained all frames that were necessary to make grass look right. I copied the spritesheet (changing the grass colour), but it didn't act the same for my grass. Is there a variable, method or function that would help? Because I've had to resort to manually drawing the tile, and creating different tiles to take textures from to make my tile look right. I've looked at the source code for Terraria and can't find anything. Help would be apreciated :)
Sorry for the essay

Argh I had another look, and I decided to try setting Main.tileMoss[Type] = true; and it worked! I have been trying to do this for ages...

Edit: No it doesn't work
Back to drawing them manually, but at least Main.tileMoss[Type] = true; helps a little, as I only have to account for how the tile interacts with dirt now. I'll probably uncover more problems later though.

It'd be nice if there was support for custom grass in the next Tmodloader update
 
Last edited:
upload_2018-8-17_8-13-28.png



I keep getting this almost everytime i try and use the mod browser can yall give me a fix im on 1.3.5.2 and using tmodloader version 0.10.1.5.

its not always like sometimes if i make the game a small window and use the mod browser i can get through with no issues but this is usually random.
 
Hello. I played singleplayer tmodloader Terraria.İts no problem but multiplayer server is problem. İf I opened the chest my pc is freeze for 1 second. Help me please. Sorry bad English.
 
Hello. I played singleplayer tmodloader Terraria.İts no problem but multiplayer server is problem. İf I opened the chest my pc is freeze for 1 second. Help me please. Sorry bad English.
If your pc freezes for a second, and there are no other errors, then perhaps your pc is just lagging?
 
I've tried everything to get terraria to load with tModloader but all i have to go off of is these logs:
Error Logging Enabled.
================
8/17/2018 11:10:07 PM: First-Chance Exception
Culture: en-US
Exception: System.IO.IOException: The handle is invalid.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
================
Resolution changed to: 800x600.
 
uhhwhat.png

i was just opening golem treasure bags and i got dinidini's head, dinidini's body, dinidini's legs, and dinidini's wings. using 'which mod is this from' tells me its just from tmodloader and i couldnt find any info about it soo im asking here lol
 
View attachment 207730
i was just opening golem treasure bags and i got dinidini's head, dinidini's body, dinidini's legs, and dinidini's wings. using 'which mod is this from' tells me its just from tmodloader and i couldnt find any info about it soo im asking here lol
Those are, in fact, from tModLoader; dinidini is one of the few Patreons for tModLoader that pledges enough to earn a vanity set in tModLoader.
 
I am currently trying to make a modded armor set that has a set bonus which lets you shoot projectiles when taking damage, but I don't know how to make the set bonus do that.
 
Alright, so I am making a mod, and I need to know if this... works? The problem is that at the bottom, it says vector two, and I need that fixed.
Can anyone help me? (Yes I'm a nub at this kind of stuff)
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace FuryMod.Projectiles
{
    public class FireBolt : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("FireBolt");     //The English name of the projectile
            ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;    //The length of old position to be recorded
            ProjectileID.Sets.TrailingMode[projectile.type] = 0;        //The recording mode
        }

        public override void SetDefaults()
        {
            projectile.width = 8;               //The width of projectile hitbox
            projectile.height = 8;              //The height of projectile hitbox
            projectile.aiStyle = 1;             //The ai style of the projectile, please reference the source code of Terraria
            projectile.friendly = true;         //Can the projectile deal damage to enemies?
            projectile.hostile = false;         //Can the projectile deal damage to the player?
            projectile.magic = true;           //Is the projectile shoot by a ranged weapon?
            projectile.penetrate = 5;           //How many monsters the projectile can penetrate. (OnTileCollide below also decrements penetrate for bounces as well)
            projectile.timeLeft = 6000;          //The live time for the projectile (60 = 1 second, so 600 is 10 seconds)
            projectile.alpha = 255;             //The transparency of the projectile, 255 for completely transparent. (aiStyle 1 quickly fades the projectile in)
            projectile.light = 0.5f;            //How much light emit around the projectile
            projectile.ignoreWater = false;          //Does the projectile's speed be influenced by water?
            projectile.tileCollide = true;          //Can the projectile collide with tiles?
            projectile.extraUpdates = 20;            //Set to above 0 if you want the projectile to update multiple time in a frame
            aiType = ProjectileID.WaterBolt;           //Act exactly like default Bullet
        }

        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            //If collide with tile, reduce the penetrate.
            //So the projectile can reflect at most 5 times
            projectile.penetrate--;
            if (projectile.penetrate <= 0)
            {
                projectile.Kill();
            }
            else
            {
                if (projectile.velocity.X != oldVelocity.X)
                {
                    projectile.velocity.X = -oldVelocity.X;
                }
                if (projectile.velocity.Y != oldVelocity.Y)
                {
                    projectile.velocity.Y = -oldVelocity.Y;
                }
                Main.PlaySound(SoundID.Item10, projectile.position);
            }
            return false;
        }
    }
}
[doublepost=1534989664,1534989600][/doublepost]
Alright, so I am making a mod, and I need to know if this... works? The problem is that at the bottom, it says vector two, and I need that fixed.
Can anyone help me? (Yes I'm a nub at this kind of stuff)
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace FuryMod.Projectiles
{
    public class FireBolt : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("FireBolt");     //The English name of the projectile
            ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;    //The length of old position to be recorded
            ProjectileID.Sets.TrailingMode[projectile.type] = 0;        //The recording mode
        }

        public override void SetDefaults()
        {
            projectile.width = 8;               //The width of projectile hitbox
            projectile.height = 8;              //The height of projectile hitbox
            projectile.aiStyle = 1;             //The ai style of the projectile, please reference the source code of Terraria
            projectile.friendly = true;         //Can the projectile deal damage to enemies?
            projectile.hostile = false;         //Can the projectile deal damage to the player?
            projectile.magic = true;           //Is the projectile shoot by a ranged weapon?
            projectile.penetrate = 5;           //How many monsters the projectile can penetrate. (OnTileCollide below also decrements penetrate for bounces as well)
            projectile.timeLeft = 6000;          //The live time for the projectile (60 = 1 second, so 600 is 10 seconds)
            projectile.alpha = 255;             //The transparency of the projectile, 255 for completely transparent. (aiStyle 1 quickly fades the projectile in)
            projectile.light = 0.5f;            //How much light emit around the projectile
            projectile.ignoreWater = false;          //Does the projectile's speed be influenced by water?
            projectile.tileCollide = true;          //Can the projectile collide with tiles?
            projectile.extraUpdates = 20;            //Set to above 0 if you want the projectile to update multiple time in a frame
            aiType = ProjectileID.WaterBolt;           //Act exactly like default Bullet
        }

        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            //If collide with tile, reduce the penetrate.
            //So the projectile can reflect at most 5 times
            projectile.penetrate--;
            if (projectile.penetrate <= 0)
            {
                projectile.Kill();
            }
            else
            {
                if (projectile.velocity.X != oldVelocity.X)
                {
                    projectile.velocity.X = -oldVelocity.X;
                }
                if (projectile.velocity.Y != oldVelocity.Y)
                {
                    projectile.velocity.Y = -oldVelocity.Y;
                }
                Main.PlaySound(SoundID.Item10, projectile.position);
            }
            return false;
        }
    }
}
Oh yeah, also this is the last thing, please somebody help me (I really need it)
 
I've been having this issue for the past few hours where every projectile i shot dealt at least 3000 damage, this includes enchanted sword projectiles, all forms of arrows, snowballs everything, however actual melee like directly hitting an enemy with a sword will do it's regular damage.i do really wanna finish my playthrough however i already illegitimately beat the perforator hive by doing like 270000 damage in one arrow shot, and in case you think im joking by now im not im not the type of person who just wants to put their damage up to a million, complete the playthrough and get bragging rights or anything this is a serious issue, but more importantly im probably the only person in the world who has this glitch so i doubt anyone can fix it or even do anything about it, well if anyone has had this glitch please tell me how you fixed it if you did
 
If i can upload this video, then i will, but i probably cant because its about five minutes if i cant, then i cant, it was just a video of me showing how the 100000+ damage glitch works, its only projectile its uncontrollable, and i can't simply ask one mod creator because i have north of 25-30 mods installed on that playthrough , i just dont know how to fix this stupid glitch anymore and i dont know where to ask for help or post my problem because nobody else has probably ever had it, maybe i can just wait it out or copy my character, or delete the modloader library and re install everything, i just dont think there is a fix, it simply doesn't exist sadly
 
Back
Top Bottom