tModLoader Official tModLoader Help Thread

I have encountered a reoccurring bug. Sorry if somebody already said something about it.

So whenever I launch terraria with tModloader, it always crashes when it tries to load a particular mod (Calamity Mod). The only way I have found to prevent this is to disable the mod before shutting down terraria. Is the crashing issue a problem with the mod, or tModloader? If the problem is with tModloader, is there anything I can do to stop terraria from crashing on launch, besides disabling the mod? I play on Mac, if this makes a difference.
 
I have encountered a reoccurring bug. Sorry if somebody already said something about it.

So whenever I launch terraria with tModloader, it always crashes when it tries to load a particular mod (Calamity Mod). The only way I have found to prevent this is to disable the mod before shutting down terraria. Is the crashing issue a problem with the mod, or tModloader? If the problem is with tModloader, is there anything I can do to stop terraria from crashing on launch, besides disabling the mod? I play on Mac, if this makes a difference.
How much RAM does your computer have? Calamity is a huge mod, and I had this exact problem loading it until I upgraded my computer's RAM. Just a possibility.
 
I'm having a bit of a problem building a new mod. Every time it gives me this error:
error : ERROR: ld.so: object '/home/rachel/.steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
 
So i have a problem with tmodloader server steam friends like how do i do it ? i launch it and then how do i join it or if i do it, do i need to port forward? bc i cant port forward.
 
Need help.
I have been trying to code a NPC, the NPC shows up and works as intended but the head dosen't show up on the map or in the NPC housing menu therefore making it so i cant assign it a house, if anyone knows it would be a great help.

Here is the head image (placeholder until I can make one):
upload_2019-6-14_15-51-20.png

Here is the code:
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;[ATTACH=full]222813[/ATTACH] [ATTACH=full]222813[/ATTACH] [ATTACH=full]222813[/ATTACH] [ATTACH=full]222813[/ATTACH]

namespace Enraged.NPCs
{
    [AutoloadHead]
    public class Ranger : ModNPC
    {
        public override string Texture
        {
            get
            {
                return "Enraged/NPCs/Ranger";
            }
        }
        public override bool Autoload(ref string name)
        {
            name = "Ranger"; return mod.Properties.Autoload;
        }
        public override void SetDefaults()
        {
            npc.townNPC = true;
            npc.friendly = true;
            npc.width = 18;
            npc.height = 46;
            npc.aiStyle = 7;
            npc.damage = 10;
            npc.defense = 15;
            npc.lifeMax = 250;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.knockBackResist = 0.5f;
            Main.npcFrameCount[npc.type] = 16;
            animationType = NPCID.Guide;
        }
        public override bool CanTownNPCSpawn(int numTownNPCs, int money)
        {
          
            return false;// this make that he will spawn when a house is available
        }
        public override bool CheckConditions(int left, int right, int top, int bottom)    //Allows you to define special conditions required for this town NPC's house
        {
            return true;  //so when a house is available the npc will  spawn
        }


        public override string TownNPCName()
        {                                       //NPC names
            switch (WorldGen.genRand.Next(4))
            {
                case 0:
                    return "Clent";
                case 1:
                    return "Hunter";
                case 2:
                    return "Kevin";
                default:
                    return "Tom";
            }
        }




        public override string GetChat()
        {                                           //npc chat

            switch (Main.rand.Next(3))
            {
                case 0:
                    return "What do you want?";
                case 1:
                    return "Are ya gonna buy something?";
                default:
                    return "Up for a challange?";
            }
        }

        public override void SetChatButtons(ref string button, ref string button2)
        {
            button = "Buy Summons";
        }

        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            if (firstButton)
            {
                shop = true;
            }
        }
        public override void SetupShop(Chest shop, ref int nextSlot)       //Allows you to add items to this town NPC's shop. Add an item by setting the defaults of shop.item[nextSlot] then incrementing nextSlot.
        {
            if (NPC.downedSlimeKing)   //this make so when the king slime is killed the town npc will sell this
            {
                shop.item[nextSlot].SetDefaults(ItemID.SlimeCrown); 
                nextSlot++;
            }
        }
    }
}
 
I have a laser projectile that should make a explosion when it hits something but it keeps telling me this error
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria.Enums;
namespace Duck.Projectiles
{
public class CustomBeamProj : ModProjectile
{
public virtual bool CanDamage() {
return true;
}
private Vector2 _targetPos; //Ending position of the laser beam
private int _charge = 100; //The charge level of the weapon
private float _moveDist = 45f; //The distance charge particle from the player center
public override void SetDefaults()
{
// projectile.name = "Custom Laser Beam"; //this is the projectile name
projectile.width = 10;
projectile.height = 10;
projectile.friendly = true; //this defines if the projectile is frendly
projectile.penetrate = 1; //this defines the projectile penetration, -1 = infinity
projectile.tileCollide = true; //this defines if the tile can colide with walls
projectile.magic = true;
projectile.hide = false;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (_charge == 100)
{
Vector2 unit = _targetPos - Main.player[projectile.owner].Center;
unit.Normalize();
DrawLaser(spriteBatch, Main.projectileTexture[projectile.type], Main.player[projectile.owner].Center, unit, 5, projectile.damage, 1.57f, 1, 1000, Color.Red, 20);
}
return false;
}
/// <summary>
/// The core function of drawing a laser
/// </summary>
public void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 200f, Color color = default(Color), int transDist = 50)
{
Vector2 origin = start;
float r = unit.ToRotation() + rotation;
#region Draw laser body
for (float i = transDist; i <= _moveDist; i += step)
{
Color c = Color.White;
origin = start + i * unit;
spriteBatch.Draw(texture, origin - Main.screenPosition,
new Rectangle(0, 26, 28, 26), i < transDist ? Color.Yellow : c, r,
new Vector2(28 / 2, 26 / 2), scale, 0, 0);
}
#endregion
#region Draw laser head
spriteBatch.Draw(texture, start + unit * (transDist - step) - Main.screenPosition,
new Rectangle(0, 0, 28, 26), Color.Red, r, new Vector2(28 / 2, 26 / 2), scale, 0, 0);
#endregion
#region Draw laser tail
spriteBatch.Draw(texture, start + (_moveDist + step) * unit - Main.screenPosition,
new Rectangle(0, 52, 28, 26), Color.Red, r, new Vector2(28 / 2, 26 / 2), scale, 0, 0);
#endregion
}
/// <summary>
/// Change the way of collision check of the projectile
/// </summary>
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
if (_charge == 100)
{
Player p = Main.player[projectile.owner];
Vector2 unit = (Main.player[projectile.owner].Center - _targetPos);
unit.Normalize();
float point = 0f;
if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), p.Center - 45f * unit, p.Center - unit * _moveDist, 22, ref point))
{
return true;
}
}
return false;
}
/// <summary>
/// Change the behavior after hit a NPC
/// </summary>
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.immune[projectile.owner] = 5;
}
/// <summary>
/// The AI of the projectile
/// </summary>
public override void AI()
{
Vector2 mousePos = Main.MouseWorld;
Player player = Main.player[projectile.owner];
#region Set projectile position
if (projectile.owner == Main.myPlayer) // Multiplayer support
{
Vector2 diff = mousePos - player.Center;
diff.Normalize();
projectile.position = player.Center + diff * _moveDist;
projectile.timeLeft = 2;
int dir = projectile.position.X > player.position.X ? 1 : -1;
player.ChangeDir(dir);
player.heldProj = projectile.whoAmI;
player.itemTime = 2;
player.itemAnimation = 2;
player.itemRotation = (float)Math.Atan2(diff.Y * dir, diff.X * dir);
projectile.soundDelay--;
#endregion
}
#region Charging process
// Kill the projectile if the player stops channeling
if (!player.channel)
{
projectile.Kill();
}
else
{
if (Main.time % 10 < 1 && !player.CheckMana(player.inventory[player.selectedItem].mana, true))
{
projectile.Kill();
}
Vector2 offset = mousePos - player.Center;
offset.Normalize();
offset *= _moveDist - 20;
Vector2 dustPos = player.Center + offset - new Vector2(10, 10);
if (_charge < 100)
{
_charge++;
}
int chargeFact = _charge / 20;
Vector2 dustVelocity = Vector2.UnitX * 18f;
dustVelocity = dustVelocity.RotatedBy(projectile.rotation - 1.57f, default(Vector2));
Vector2 spawnPos = projectile.Center + dustVelocity;
for (int k = 0; k < chargeFact + 1; k++)
{
Vector2 spawn = spawnPos + ((float)Main.rand.NextDouble() * 6.28f).ToRotationVector2() * (12f - (chargeFact * 2));

Dust dust = Main.dust[Dust.NewDust(dustPos, 30, 30, 235, projectile.velocity.X / 2f, projectile.velocity.Y / 5f, projectile.damage * 9]);

dust.velocity = Vector2.Normalize(spawnPos - spawn) * 1.5f * (10f - chargeFact * 2f) / 10f;
dust.noGravity = true;
dust.scale = Main.rand.Next(20, 20) * 0.05f;
}
}
#endregion
#region Set laser tail position and dusts
if (_charge < 100) return;
Vector2 start = player.Center;
Vector2 unit = (player.Center - mousePos);
unit.Normalize();
unit *= -1;
for (_moveDist = 45f; _moveDist <= 1600; _moveDist += 5) //this 1600 is the dsitance of the beam
{
start = player.Center + unit * _moveDist;
if (!Collision.CanHit(player.Center, 1, 1, start, 1, 1))
{
_moveDist -= 5f;
break;
}
if (projectile.soundDelay <= 0)//this is the proper sound delay for this type of weapon
{
Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 15); //this is the sound when the weapon is used cheange 15 for diferent sound
projectile.soundDelay = 40; //this is the proper sound delay for this type of weapon
}
}
_targetPos = player.Center + unit * _moveDist;
//dust
for (int i = 0; i < 15; ++i)
{
float num1 = projectile.velocity.ToRotation() + (Main.rand.Next(2) == 1 ? -1.0f : 1.0f) * 1.57f;
float num2 = (float)(Main.rand.NextDouble() * 0.8f + 1.0f);
Vector2 dustVel = new Vector2((float)Math.Cos(num1) * num2, (float)Math.Sin(num1) * num2);
Projectile.NewProjectile(_targetPos, 0, 0, 296, (int) (projectile.damage * 1.5), Main.myPlayer); // 296 is the explosion from the Inferno Fork
Dust dust = Main.dust[Dust.NewDust(_targetPos, 0, 0, 285, dustVel.X, dustVel.Y, 0, new Color(), 1f)]; //this is the head dust
Dust dust2 = Main.dust[Dust.NewDust(_targetPos, 0, 0, 235, dustVel.X, dustVel.Y, 0, new Color(), 1f)]; //this is the head dust 2
dust.noGravity = true;
dust.scale = 1.7f;
}
#endregion
}

public override bool ShouldUpdatePosition()
{
return false;
}
}
}
and i get this error
c:\Users\Mumuji\Documents\My Games\Terraria\ModLoader\Mod Sources\Duck\Projectiles\CustomBeamProj.cs(163,54) : error CS1026: must be )
c:\Users\Mumuji\Documents\My Games\Terraria\ModLoader\Mod Sources\Duck\Projectiles\CustomBeamProj.cs(163,55) : error CS1002: must be ;
c:\Users\Mumuji\Documents\My Games\Terraria\ModLoader\Mod Sources\Duck\Projectiles\CustomBeamProj.cs(163,55) : error CS1525:
Invalid arithmetic vocabulary
')'
c:\Users\Mumuji\Documents\My Games\Terraria\ModLoader\Mod Sources\Duck\Projectiles\CustomBeamProj.cs(163,56) : error CS1002: must be;
 
I am a attempting to make a worm boss and it works, but it doesn't share health with it's segments, and it's segments move on their own. Here's the code for the 3 classes
 

Attachments

  • Sand_Tyrant_Head.cs
    14.4 KB · Views: 95
  • Sand_Tyrant_Body.cs
    14.4 KB · Views: 119
  • Sand_Tyrant_Tail.cs
    14.4 KB · Views: 100
im making a mod. its saying the defintion 'name' is not part of 'Terraria.NPC' this is what im talking about:
Terraria_ Cult of Cenx 7_2_2019 5_39_44 PM.png
 
Can I get some help, I'm trying to get back into modding for the first time in forever. Can I get a link to the example weapon mod download. Also does anyone know the code to spawn the horseman's blade projectiles for a weapon?
 
Can I get some help, I'm trying to get back into modding for the first time in forever. Can I get a link to the example weapon mod download. Also does anyone know the code to spawn the horseman's blade projectiles for a weapon?
look it up i think its item.CloneDefaults(ItemID.HorsemenBlade); or something

and your welcome
 
Testing out my code, but it says there's no definition for name and tooltip in Terraria.Item.

[doublepost=1562378051,1562377899][/doublepost]
look it up i think its item.CloneDefaults(ItemID.HorsemenBlade); or something

and your welcome

But I want three Flaming Jacks, not just one.
 
Last edited:
Now I'm getting these errors:

The name 'items' does not exist in the current context

'HarvestReaper.Items.Weapons.HarvestReaper' is a 'type' but is used like a 'variable'

Edit: Found the silly problems
 
Last edited:
I am unable to use the smart cursor to auto switch to the correct tool since using modloader. I hold shift and i can see the cursor increase in size but it doesent switch to the correct tool when hovering over a tree or rock etc.
 
Last edited:
I am unable to use the smart cursor to auto switch to the correct tool since using modloader. I hold shift and i can see the cursor increase in size but it doesent switch to the correct tool when hovering over a tree or rock etc.
You might have the controls mixed up in your key bindings. There are 2 things, Smart Cursor and Auto Select. Auto Select changes the selected item automatically based on hovered tile, Smart Cursor makes the cursor fat and automatically targets the closest tile instead of exactly where your cursor is. Make sure you have are using them both in the correct manner.
 
Me and a friend are currently working on a weapon in a mod, but we have a sound-related issue. When the gun is used, it chooses a random sound from 5 separate files and plays it which works fine. However, upon firing the weapon again, the previous sound doesn't stop. This means that, especially with a fast use time, the sounds begin to overlap. How could i make it so the previous sound stops before a new one is played? Code is this:

public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Terraria.Audio.LegacySoundStyle[] sounds = new Terraria.Audio.LegacySoundStyle[]
{
mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Weapons/Kitchen_Gun_Sound_Byte_1").WithVolume(.7f),
mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Weapons/Kitchen_Gun_Sound_Byte_2").WithVolume(.7f),
mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Weapons/Kitchen_Gun_Sound_Byte_3").WithVolume(.7f),
mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Weapons/Kitchen_Gun_Sound_Byte_4").WithVolume(.7f),
mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Weapons/Kitchen_Gun_Sound_Byte_5").WithVolume(.7f)
};
int choice = Main.rand.Next(sounds.Length);
//this is where it should stop the last sound
Main.PlaySound(sounds[choice], player.position);//where it plays the new sound

return base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
}
 
I need help. So I installed this since I just got the game, it worked at first, I started downloading a few mods then all of a sudden it crashed. But when I went to go back on the game it kept me in a black screen. So I deleted this tmodloader and all the game files, then I shutdown my computer reloaded and installed and download this and the game. But now it keeps putting me in a black screen and I tried everything. PLEASE help!

Side note: the game works when the tmodloader is not installed
 
Back
Top Bottom