tModLoader Official tModLoader Help Thread

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: 94
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: 102
cant load tmodloader 1.4.3
 

Attachments

  • Screenshot 2023-07-08 000736.png
    Screenshot 2023-07-08 000736.png
    72.7 KB · Views: 103
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: 91
  • QQ截图20230722123716.png
    QQ截图20230722123716.png
    476 KB · Views: 87
  • QQ截图20230722123852.png
    QQ截图20230722123852.png
    58.8 KB · Views: 95
Yo so basically I've done this multiple times and it still hasn't worked someone please tell me if there is something wrong. Basically I have to separate PC's one at my mum and one at my dads, at my dads for the past week or so I've been playing DBZ terraria with my friends and today I had to go up to my mums so I uploaded both my character and my world onto the cloud at my dads just by clicking the little button ingame, I then traveled up to my mums house and hopped on my pc, I switched the tmod loader to the same version as the one at my dads house, loaded in and saw no character or world, I looked at the migrate section and nothing still. I changed the version back and fourth but no changes, I checked my folders to find nothing. Someone please help, it's difficult enough to play with my friends since there already on the other side of the world but not being to play at all is even worse.
 
Yo so basically I've done this multiple times and it still hasn't worked someone please tell me if there is something wrong. Basically I have to separate PC's one at my mum and one at my dads, at my dads for the past week or so I've been playing DBZ terraria with my friends and today I had to go up to my mums so I uploaded both my character and my world onto the cloud at my dads just by clicking the little button ingame, I then traveled up to my mums house and hopped on my pc, I switched the tmod loader to the same version as the one at my dads house, loaded in and saw no character or world, I looked at the migrate section and nothing still. I changed the version back and fourth but no changes, I checked my folders to find nothing. Someone please help, it's difficult enough to play with my friends since there already on the other side of the world but not being to play at all is even worse.
If you have a USB drive, I would recommend copying the player and world files onto that instead, it's more reliable and also means you have a backup should something cause the files to be corrupted.
 
Hello guys, i don't know where to post my issue, so sorry if it's the wrong place.

I launched Tmod (gog) my log showed that mod started and logged but when i got to my workshop -> manage mod, no mod was there, so i tried to install the mods but it says "it or it was already installed, try restarting your instance" and i also tried to look into the mod directory but nothing is there. I got some file to share, the first is the said instance and the second is the next one, when i closed and reopened Tmod.

I'm seeking help because i don't have a clue of what happened and i don't want to unistall it ;-;
 

Attachments

Back
Top Bottom