tModLoader Official tModLoader Help Thread

Hi everyone. Just joined as need advice with a problem. Everytime my son plays Terraria on his PC everyone else in our home loses internet as we are unable to get on. His Dad thinks the TModloader is corrupted or virused. He has the Calamity and Tremor mod. Any help is welcome. My son does not want to delete anything. He is only 9 so please be gentle. :)
 
Hi everyone. Just joined as need advice with a problem. Everytime my son plays Terraria on his PC everyone else in our home loses internet as we are unable to get on. His Dad thinks the TModloader is corrupted or virused. He has the Calamity and Tremor mod. Any help is welcome. My son does not want to delete anything. He is only 9 so please be gentle. :)
His Dad is paranoid, but I suggest you run a virus scan on all the computers anyway. It is also possible that if your son uses multiplayer and you have terrible internet he might be using all the bandwidth.
 
How would you make an accessory that makes you immune to a modded debuff?
(Also, how do you change a buff into a debuff?)
 
I'm trying to make a custom crate item that can drop 1 of 3 items when opened, however whenever I try it out in game all it does is consume the crate without producing any items. This is the code I have in the crate's item file:

Code:
Random rnd = new System.Random();
public virtual void RightClick(Item item, Player player)
{
   switch (rnd.Next(1, 3))
   {
   case 1:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Berserker Helmet"));
      break;
   case 2:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Berserker Breastplate"));
      break;
   case 3:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Berserker Tassets"));
     break;
   default:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Mechanite_Bar"));
      break;
   }
}

I also suspect that my code for making Plantera drop this crate is faulty as well, although I have not tested it much yet. This is in the GlobalNPC file:
Code:
Random rnd = new System.Random();

public override void NPCLoot(NPC npc)
{
   if (npc.type == NPCID.Plantera)
   {
      if (rnd.Next(1, 100) <= 5)
      {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BerserkerCrate"));
      }
   }
}
 
Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.Blackout, 600);
target.AddBuff(BuffID.CursedInferno, 600);
target.AddBuff(BuffID.Frostburn, 600);
int healingAmount = Convert.ToInt32 (damage * 0.2);
player.statLife += healingAmount;
player.HealEffect(healingAmount, true);
}


public override void ModifyHitPvp(Player player, Player target, ref int damage, ref bool crit)
{
target.AddBuff(BuffID.Blackout, 600);
target.AddBuff(BuffID.CursedInferno, 600);
target.AddBuff(BuffID.Frostburn, 600);
}
the weird there here is, it only applies on my screen when I'm holding the weapon, my friend gets the debuffs on my screen, but he's completely fine on his.
 
I'm trying to make a custom crate item that can drop 1 of 3 items when opened, however whenever I try it out in game all it does is consume the crate without producing any items. This is the code I have in the crate's item file:

Code:
Random rnd = new System.Random();
public virtual void RightClick(Item item, Player player)
{
   switch (rnd.Next(1, 3))
   {
   case 1:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Berserker Helmet"));
      break;
   case 2:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Berserker Breastplate"));
      break;
   case 3:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Berserker Tassets"));
     break;
   default:
      Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("Mechanite_Bar"));
      break;
   }
}

I also suspect that my code for making Plantera drop this crate is faulty as well, although I have not tested it much yet. This is in the GlobalNPC file:
Code:
Random rnd = new System.Random();

public override void NPCLoot(NPC npc)
{
   if (npc.type == NPCID.Plantera)
   {
      if (rnd.Next(1, 100) <= 5)
      {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BerserkerCrate"));
      }
   }
}
switch (rnd.Next(1, 3)) should be switch (rnd.Next(1, 4))

and I don't think this is right: mod.ItemType("Mechanite_Bar"), it's probably "MechaniteBar" and "BerserkerBreastplate" and so on since this is the actual internal name (the classname), not the displayname
 
Hi everyone. Just joined as need advice with a problem. Everytime my son plays Terraria on his PC everyone else in our home loses internet as we are unable to get on. His Dad thinks the TModloader is corrupted or virused. He has the Calamity and Tremor mod. Any help is welcome. My son does not want to delete anything. He is only 9 so please be gentle. :)
I'd suggest you also monitor network usage on the computer that's running Terraria, to see if it's being a network hog. Terraria with mods could be a bit of a network hog if the mods aren't well optimised. Using quality of service may help.

A few years ago, if someone else was using the internet while I was playing Vanilla Terraria, I'd get disconnected every time they clicked a link. So Terraria isn't perfect, but I think it's improved since then.
 
switch (rnd.Next(1, 3)) should be switch (rnd.Next(1, 4))

and I don't think this is right: mod.ItemType("Mechanite_Bar"), it's probably "MechaniteBar" and "BerserkerBreastplate" and so on since this is the actual internal name (the classname), not the displayname
I placed the default case there just so I could see if rng was being weird or I set it up wrong. And when I have it working I plan to remove it. However I am not getting any drops at all from the crate. Even when using the correct internal names I still get nothing from the crates
 
What I need to find out:
- How to make custom blocks glow when player uses spelunker potion.
- How to make the custom block appear on the mini-map.
- How to make that custom block generate only in the Underground Jungle.
- How to make a projectile explode when hitting a block, without it destroying the block.
- How to make a projectile not just disappear when touching a block. (As in a break effect)
- How would you make an accessory that makes you immune to a modded debuff?
(Also, how do you change a buff into a debuff?)
 
Hey guys

I used dynamite on a tmodloader server, and now ever since I get bugs such as:
- Invisible players
- [n:] instead of player names in chat
- Only part of the map loads
- Crashes
- Invalid operation at this state

I downloaded the server map with filezilla to check if it's corrupted but it's fine, i also reinstalled a few times, tried different characters etc. I was thinking maybe the server installation was wrong but 2 other players experience no problems.

Anybody have any ideas?
 
Is it possible to make a sword shoot a self-damaging projectile such as the Lunatic Cultist lightning orb, but somehow override the AI to make it target enemies instead?
 
Is it possible to have a buff do something when it expires, such as give the player another buff?
The easiest way to do this would to check the time left on the buff from in the buffs Update hook. If time left == 2, then apply a new buff. You could try == 1, but I've found that doing stuff on the last tick of a thing's existence doesn't always work.
 
Hello got this error when i tried to load my mod:
NPCs/BugCather
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
 
Hello got this error when i tried to load my mod:
NPCs/BugCather
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
The BugCather NPC is missing some texture files, make sure they are named correctly
 
Thanks for answering everyone else's questions but mine...
Anyway, how do you make a worm AI spawn a minion, i'm making a worm boss.
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModOfRandomness.NPCs
{   
    public class VlitchWormTail : ModNPC
    {
        public override void SetDefaults()
        {
            npc.displayName = "Vlitch Gigipede";
            npc.name = "Vlitch Gigipede";
            npc.width = 64;     //this is where you put the npc sprite width.     important
            npc.height = 104;      //this is where you put the npc sprite height.   important
            npc.damage = 180;
            npc.defense = 250;
            npc.lifeMax = 1;
            npc.knockBackResist = 0.0f;
            npc.behindTiles = true;
            npc.noTileCollide = true;
            npc.netAlways = true;
            npc.noGravity = true;
            npc.dontCountMe = true;
            npc.HitSound = SoundID.NPCHit4;
        }

        public override bool PreAI()
        {
            if (npc.ai[3] > 0)
                npc.realLife = (int)npc.ai[3];
            if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
                npc.TargetClosest(true);
            if (Main.player[npc.target].dead && npc.timeLeft > 300)
                npc.timeLeft = 300;
            if (Main.netMode != 1)
            {
                if (!Main.npc[(int)npc.ai[1]].active)
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                    NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
                }
            }
            {
                if (Main.rand.Next(1) == 0)
                {
                    int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("Flame"));
                }
            }
                if (npc.ai[1] < (double)Main.npc.Length)
            {
                // We're getting the center of this NPC.
                Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
                float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
                float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
                // We then use Atan2 to get a correct rotation towards that parent NPC.
                npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
                // We also get the length of the direction vector.
                float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
                // We calculate a new, correct distance.
                float dist = (length - (float)npc.width) / length;
                float posX = dirX * dist;
                float posY = dirY * dist;

                // Reset the velocity of this NPC, because we don't want it to move on its own
                npc.velocity = Vector2.Zero;
                // And set this NPCs position accordingly to that of this NPCs parent NPC.
                npc.position.X = npc.position.X + posX;
                npc.position.Y = npc.position.Y + posY;
            }
            return false;
        }

        public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color drawColor)
        {
            Texture2D texture = Main.npcTexture[npc.type];
            Vector2 origin = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f);
            Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition, new Rectangle?(), drawColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0);
            return false;
        }
        public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
        {

            return false;      //this make that the npc does not have a health bar
        }
    }
}
 
So im supposed to be creating a weapon mod for terraria but this one bug keeps kicking my :red:.
Is it
Missing mod: rglmod/Items/Aetherblade
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
YES!
pls help.

the cs file which has the item is coded as follows
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace rglmod.Items
{ public class Aetherblade : ModItem
{
public override void SetDefaults()
{
item.name = "Aetherblade";
item.width = 16;
item.height = 16;
item.maxStack = 1;
AddTooltip("Starter weapon for the majority of Races.");
item.value = 100;
item.rare = 3;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(this);
recipe.AddRecipe();
recipe = new ModRecipe(mod);
recipe.AddRecipeGroup("RGLMod:Aetherblade");
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
So im supposed to be creating a weapon mod for terraria but this one bug keeps kicking my :red:.
Is it
Missing mod: rglmod/Items/Aetherblade
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
YES!
pls help.

the cs file which has the item is coded as follows
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace rglmod.Items
{ public class Aetherblade : ModItem
{
public override void SetDefaults()
{
item.name = "Aetherblade";
item.width = 16;
item.height = 16;
item.maxStack = 1;
AddTooltip("Starter weapon for the majority of Races.");
item.value = 100;
item.rare = 3;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(this);
recipe.AddRecipe();
recipe = new ModRecipe(mod);
recipe.AddRecipeGroup("RGLMod:Aetherblade");
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
According to this error, you're missing a texture file at "rglmod/Items" with the name "Aetherblade.png". If you do have a texture at that given location, double check your spelling.
 
Back
Top Bottom