tModLoader Official tModLoader Help Thread

Anyone know what the heck this is? It does this every time I click single player. I don't know how to fix it.
1684683828867.png
 
Hey all, does anyone know how to make a sword have a custom swing animation? I want to make a sword that first swings downwards and then upwards, kind of like if someone would be mindlessly swinging it around. My current idea is to try using UseStyle to customize the item's animation, but correct me if I'm not using the code correctly.
 
I've been working on a boss mob, and the boss isn't targeting the player, It's target is nothing near the player. it doesn't fly above the player, and it doesn't update based on the player's position, I feel like it isn't targeting them, how do I set the target to the nearest player?

And for later use, how do I despawn the mob if there are NO living players, or the nearest player is more than 600 blocks away, roughly 2 biomes away?

EDIT:

I figured it out, it's a for loop
C#:
    for (int i = Main.player.Length; i>=0; i--){
 
        if (Distance(Main.players[i].Center, NPC.Center) < distance)
        {
            distance = Vector2.Distance(Main.player[i].Center, NPC.Center);
            target = Main.player[i];
        }
    }




How do I give an npc god mode? I need a phase where my boss goes invulnerable for a while while they turn the game into a bullet hell
 
Last edited:
Hey, I'm trying to make a mod that adds an NPC. It's supposed to shoot bullets from a sniper rifle. The bullets work but the sniper rifle won't show up when the NPC fires. heres the code snippet.
public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = ModContent.Request<Texture2D>("Terraria/tModLoader/ModSources/MeNPC/Content/Items/Weapons" + ItemID.SniperRifle).Value;
itemSize = 40;
}
If anyone could help me I would appreciate it, thank you :)
 
Hey, I'm trying to make a mod that adds an NPC. It's supposed to shoot bullets from a sniper rifle. The bullets work but the sniper rifle won't show up when the NPC fires. heres the code snippet.
public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = ModContent.Request<Texture2D>("Terraria/tModLoader/ModSources/MeNPC/Content/Items/Weapons" + ItemID.SniperRifle).Value;
itemSize = 40;
}
If anyone could help me I would appreciate it, thank you :)
If you want to use the vanilla texture, TextureAssets.Item[ItemID.SniperRifle].Value should work.
If you get an error about TextureAssets, you need using Terraria.GameContent; in your file.
 
If you want to use the vanilla texture, TextureAssets.Item[ItemID.SniperRifle].Value should work.
If you get an error about TextureAssets, you need using Terraria.GameContent; in your file.
I tried it. I didn't get an error code (like last time) But the sniper rifle still doesn't appear when the npc attacks. Heres the new code, maybe I just put it in wrong?

public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = TextureAssets.Item[ItemID.SniperRifle].Value;
itemSize = 40;
}
Also I'm including a video of the attack incase that helps.
 
I tried it. I didn't get an error code (like last time) But the sniper rifle still doesn't appear when the npc attacks. Heres the new code, maybe I just put it in wrong?

public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = TextureAssets.Item[ItemID.SniperRifle].Value;
itemSize = 40;
}
Also I'm including a video of the attack incase that helps.
You need to override `DrawTownAttackGun` instead of `DrawTownAttackSwing`. Apologies for not catching that earlier.
 
You need to override `DrawTownAttackGun` instead of `DrawTownAttackSwing`. Apologies for not catching that earlier.
1686144013656.png

Got this error now.
(new code)
public override void DrawTownAttackGun(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = TextureAssets.Item[ItemID.SniperRifle].Value;
itemSize = 40;
}
 
Hello, I am trying to localize other mods. Please help me, I don't understand the two files with dll and pdb formats. Without them localization is not working and I don't know how to create them

like this(I took this as an example from another localization)

image.png


That's it, I figured it out, these files are created during compilation 🤦‍♂️
 
Last edited:
Hello! I`m trying to make my first mod, and I need some help.
I want to make weapon and armor with growing stats. I made weapon which damage and attack speed is increased with hitting enemies. But i got huge issues with armor. I don't understand how to make it increase it's defense and my max health. So i have a few questions after playing with different stats.
1) Is it possible to transfer value of variable to another item in visual studio? (i.e. transfer exp value from my weapon to armor)
2) How to check if player got damaged, and one-time damage exceed some level?
Thanks!
 
Ok, so I'm trying to make a mod, and it's not my first time, but for some reason I cannot get it to verify my item...

Here is my code:

using Terraria;
using Terraria.ModLoader;
using Terraria.GameContent.Creative;
using Terraria.ID;

namespace ClasslessEndgame.Content.Items.Tools
{
internal class LuminitePickaxe : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Luminite Pickaxe");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void AutoStaticDefaults()
{
Item.width = 38;
Item.height = 38;

Item.useTime = 12;
Item.useAnimation = 6;
Item.autoReuse = true;
Item.useStyle = ItemUseStyleID.Swing;
Item.useTurn = true;

Item.DamageType = DamageClass.Melee;
Item.damage = 80;
Item.knockBack = 5.5f;

Item.value = Item.buyPrice(gold:7);
Item.rare = ItemRarityID.Red;

Item.pick = 225;
Item.tileBoost = 4;
}
public override void AddRecipes()
{
CreateRecipe()
.AddIngredient(ItemID.LunarBar, 10)
.AddIngredient(ItemID.FragmentNebula, 12)
//.addIngredient(ModContent.ItemType<UniverseFragment>(), 12)
.AddTile(TileID.LunarCraftingStation)
.Register();
}
}
}


I don't know what is going on, I can't get the item to show up in game, also if it helps, the error message is this:
Object not set to an instance of an object (See client.log for full details)


NEVERMIND!!!!! I fixed it
 
Last edited:
living wood causing issues when entering hardmode for me ithink it relates to when the asteral infection intersepts with one but idk can anyone pls help i wanted to make a guide and this keeps happening
also happened with demonite bricks
1687364193543.png
 
Hi! I am in a bit of a predictament. I am making a weapon that shoots its normal projectile 96% of the time and shoots its special projectile 4% of the time. I'm not entirely sure how to do that, and I would really appreciate some help. Thanks!

C++:
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Creative;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System;

namespace DealerClass.Content.Items.Weapons
{
    internal class WoodDeck : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Wood Deck");
            Tooltip.SetDefault("4% wild card chance");
            CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
        }
        public override void SetDefaults()
        {
            Item.width = 28;
            Item.height = 36;

            Item.DamageType = DamageClass.Generic;
            Item.damage = 4;
            Item.knockBack = 0.05f;

            Item.useTime = 5;
            Item.useAnimation = 20;
            Item.autoReuse = true;
            Item.useStyle = ItemUseStyleID.Thrust;
            Item.useTurn = true;
            Item.UseSound = SoundID.Item1;

            //  VVV im trying to get these projectiles to do the randomizer thingy VVV

            /*
            Item.shoot = ModContent.ProjectileType<WoodNormalCard>();
            Item.shootSpeed = 1f;
            Item.shoot = ModContent.ProjectileType<WoodWildCard>();
            Item.shootSpeed = 1f;
            */

            Item.value = Item.buyPrice(copper : 20);
            Item.rare = ItemRarityID.White;
        }
        public override void ModifyTooltips(List<TooltipLine> tooltips)
        {
            var lineToChange = tooltips.FirstOrDefault(x => x.Name=="Damage" && x.Mod == "Terraria");
            if (lineToChange != null)
            {
                string[] split = lineToChange.Text.Split(" ");
                lineToChange.Text = split.First() + " dealer " + split.Last();
            }
        }
        public override void ModifyWeaponDamage(Player player, ref StatModifier damage)
        {
            damage += player.GetModPlayer<GlobalPlayer>().dealerDamage;
        }
        public override void AddRecipes()
        {
            CreateRecipe()
                .AddTile(TileID.WorkBenches)
                .AddIngredient(ItemID.Wood, 8)
                .Register();
        }
    }
}
 
My Tmodloader crash on startup. help me plss

native log

Setting breakpad minidump AppID = 1281930
SteamInternal_SetMinidumpSteamID: Caching Steam ID: 76561199081275731 [API loaded no]
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
at Microsoft.Xna.Framework.Graphics.FNA3D_Impl.FNA3D_SwapBuffers(IntPtr, IntPtr, IntPtr, IntPtr)
--------------------------------
at Microsoft.Xna.Framework.Graphics.FNA3D.FNA3D_SwapBuffers(IntPtr, IntPtr, IntPtr, IntPtr)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Present()
at Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.EndDraw()
at Microsoft.Xna.Framework.Game.EndDraw()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.RunLoop()
at Microsoft.Xna.Framework.Game.Run()
at Terraria.Program.LaunchGame_(Boolean)
at Terraria.Program.LaunchGame(System.String[], Boolean)
at MonoLaunch+<>c__DisplayClass1_0.<Main>b__0()
at System.Threading.Thread.StartCallback()
 
For context, I wanted to play an older version of a mod. That called for an old Tmodloader version in order to use it.
I downloaded version 0.10.1 from github and extracted the folder. I then ran the executable and was met with this error:
Screenshot 2023-06-28 112430.png

I then uninstalled terraria vanilla and tried again, being met with the same error.
Due to the terms used in the error, I do not understand what this error means nor how to fix it.
 

Attachments

  • Screenshot 2023-06-28 112430.png
    Screenshot 2023-06-28 112430.png
    87.7 KB · Views: 11
hey, so i need help.. my tmodloader isnt running, i have uninstalled it 2 times, installed it 2 times,and it wont work :eek: im on linux :happy:
 
Everytime an Eidolon Wyrm, a Reaper Shark or a Gulper Eel (Infernum Mode is on so they have their edited behavior) spawns in my world, my game crashes, I'm using Calamity, Infernum and some other QoL mods.
Here's the crash log if someone has a fix.
 

Attachments

  • crash.png
    crash.png
    72.9 KB · Views: 15
I was trying to add more coins to drops for npc who get killed by player and meanwhile the player is wearing an accessory that I created in my mod, so I need a way to find the player who killed the npc.I saw the example code showen in this page and I tried to add the code into my mod, but the game throw exception saying that "index was outside the bound of the array."
 

Attachments

  • QQ截图20230722123117.png
    QQ截图20230722123117.png
    111.2 KB · Views: 11
  • QQ截图20230722123716.png
    QQ截图20230722123716.png
    476 KB · Views: 10
  • QQ截图20230722123852.png
    QQ截图20230722123852.png
    58.8 KB · Views: 9
Back
Top Bottom