tModLoader Official tModLoader Help Thread

Anyone any idea how you make grass/grass seeds? I've got something but it can't be the right approach
 
I am unable to build my mod, on attempting to build my mod I get this:
Terraria_f0qol28mZF.png
 
How do I add multiple items to one mod?

To elaborate, I wanted to have multiple weapons in a mod I'm making. However, I'm unsure of how to do so. Do I just add another file for the code of the item with the sprite and everything, or is something specific that I need to do?

Yeah, you can just add another code file and sprite to the same folder your first item was in and it will add the next item.
 
Question: How do you make a modded rarity (e.g. Thorium's Blood Orange, Calamities Donator Red, etc.)
 
so i have ores that are supposed to spawn when you defeat moon lord and they work on singleplayer but not on multiplayer
anyone know how to fix this

using System.IO;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;

namespace MoreWeaponsAndTools
{
public class RyftWorld : ModWorld
{
public static bool spawnPostMoonLordOre;



public override void Initialize()
{
spawnPostMoonLordOre = false;
}

public override void Load(TagCompound tag)
{
spawnPostMoonLordOre = tag.GetBool("spawnPostMoonLordOre");
}
public override void LoadLegacy(BinaryReader reader)
{
int loadVersion = reader.ReadInt32();
if (loadVersion == 0)
{
BitsByte flags = reader.ReadByte();
spawnPostMoonLordOre = flags[0];
}
else
{
mod.Logger.WarnFormat("Ryft: Unknown loadVersion: {0}", loadVersion);
}
}
public override TagCompound Save()
{
return new TagCompound {
{"spawnPostMoonLordOre", spawnPostMoonLordOre }
};
}
public override void NetSend(BinaryWriter writer)
{
var flags = new BitsByte();
flags[0] = spawnPostMoonLordOre;
writer.Write(flags);


}

public override void NetReceive(BinaryReader reader)
{
BitsByte flags = reader.ReadByte();
spawnPostMoonLordOre = flags[0];
}


}
}
if (npc.type == NPCID.MoonLordCore)
{
if (!RyftWorld.spawnPostMoonLordOre)
{
Main.NewText("Foreign Materials have materialized within the earth", 200, 200, 55);
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 60E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayerLow, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(9, 15), WorldGen.genRand.Next(5, 9), (ushort)mod.TileType("AmuriumOreTile"));
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 55E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayerLow, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(8, 14), WorldGen.genRand.Next(4, 7), (ushort)mod.TileType("NiobiumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 30E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 4), (ushort)mod.TileType("HexoniumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 40E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(9, 15), WorldGen.genRand.Next(5, 9), (ushort)mod.TileType("OcniumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 50E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(6, 10), WorldGen.genRand.Next(3, 7), (ushort)mod.TileType("ZanadiumOreTile"));

}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 30E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200); //this is the coordinates where the veins ore will spawn, so in Cavern layer
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 4), (ushort)mod.TileType("IridiumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 40E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(9, 15), WorldGen.genRand.Next(5, 9), (ushort)mod.TileType("VibraniumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 40E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(3, 6), (ushort)mod.TileType("BavariumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 37E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(9, 15), WorldGen.genRand.Next(5, 9), (ushort)mod.TileType("KatchintiteOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 34E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(3, 6), (ushort)mod.TileType("TraptaniumOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 27E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(3, 6), (ushort)mod.TileType("AjaOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 32E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 4), (ushort)mod.TileType("KryptoniteOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 40E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(6, 11), WorldGen.genRand.Next(4, 8), (ushort)mod.TileType("RedstoneOreTile"));
}
for (int k = 0; k < (int)((double)(WorldGen.rockLayer * Main.maxTilesY) * 35E-05); k++)
{
int X = WorldGen.genRand.Next(0, Main.maxTilesX);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 200);
WorldGen.OreRunner(X, Y, WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(4, 8), (ushort)mod.TileType("PhosphorusStoneTile"));
}
RyftWorld.spawnPostMoonLordOre = true;
}
else
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RyftCrystal"), 1);
}

}
 
buenas una pregunta ¿ a ustedes no les esta pasando que no les funciona el navegador de mods, esta desactivado o algo por el estilo?
 
So whenever I try to launch the game now I get the message: "Please ensure Stream is logged in and running"

So... what is up with that?
 
Long story short: I got Terraria, GOG version. It was on 1.3.5.3, then I installed tmodloader. Now, my game is on version 1.3.5.2. I originally didn't worry about it at all, since I installed it the same way on my server app thing, thinking it would downgrade there too. Surprisingly, when I tried joining I got this error message in the terminal:

: 127.0.0.1:54517 is connecting...
127.0.0.1:54517 is connecting...
127.0.0.1:54517 was booted: You are not using the same version as this server.

Note that "You are not using the same version as this server." also appeared in-game.
 
I am having issues with my mod browser, I have an attached photo with the issue. My internet is fine, and It has worked before. Stopped working over 24 hours ago. What should I do?
 

Attachments

  • Mod issues.jpg
    Mod issues.jpg
    201.7 KB · Views: 174
I am having issues with my mod browser, I have an attached photo with the issue. My internet is fine, and It has worked before. Stopped working over 24 hours ago. What should I do?
looks like javid.ddns.net is down and thus is timing out I'm also getting the issue.
 
what mod do i do first
 
is anybody aware of how to detect how long a projectile/enemy has existed, and use that as a float or integer?
 
projectile.timeLeft = 60;
It's an integer, if you want to put this in your setdefaults of your projectile. Setting this value to 60 will make last 1 second without any extra updates.
This number is subtracted by 1 every game update, the one is increased if your projectile has extra updates.
 
is anybody aware of how item magnet effects work (as in stuff like ItemMagnetPlus, Calamity, et cetera)? i know i made a post yesterday, and i even tried to extract BouncyCoins (all others i could think of were not open source) but i couldn't figure it out. help please?
 
Hey, was wondering how to fix my pet, it's not displaying the entire image, only a small bit of the top. Is it cause the image is 61x71 or is it something code-wise?
 

Attachments

  • Screenshot.png
    Screenshot.png
    9.6 KB · Views: 136
Yo what's a quick and dirty way to display messages to a user? I'm using Main.NewText(), works great but i'm worried feedback from my mod will bleed into multiplayer if it's using that. Can someone confirm if NewText() chats everyone and if so is there a similar method that is only visible to the player?
 
Last edited:
How do I add multiple items to one mod?

To elaborate, I wanted to have multiple weapons in a mod I'm making. However, I'm unsure of how to do so. Do I just add another file for the code of the item with the sprite and everything, or is something specific that I need to do?

to add a new item/weapon you must right click your items folder and click add. Then you click the top of the list called class. this will make a new class with is an item. you will need to add a new sprite and for the code i normaly copy past then add adjustments .
 
Is there a way to make wings glow/semi transparent like the lunar wings?
 
im trying to make a shotgun and its not really working. here is my code. help would be much appreciated :) i did this to show what is marked red (this is marked red ---^)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace Modding2.Meteor
{
class MeteorShoty : ModItem
{

public override bool MeteorShoty.Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
(This is marked red)-------------------^
{ for (int x = 4; x < int shotAmount; x++)}
(This is marked red)---^-------^-------^---^
public override void SetDefaults()

item.Size = new Microsoft.Xna.Framework.Vector2(12, 24);
item.rare = ItemRarityID.Blue;
item.value = Item.sellPrice(silver: 25);

item.useTime = 25;
item.useAnimation = 25;
item.useStyle = ItemUseStyleID.HoldingOut;
item.UseSound = SoundID.Item14;

item.noMelee = true;
item.ranged = true;
item.damage = 16;

item.useAmmo = AmmoID.Bullet;
item.shoot = 10;
item.shootSpeed = 4.5f;
item.autoReuse = false;

}





}
}
 
A few things here.
First of all, instead of MeteorShoty.Shoot, all you need is Shoot.
To the second red mark, you have a for loop there, but it doesn't have any code inside.
I suggest looking at ExampleMod gun and using the shotgun code.
For convenience, I copied the code here. Just replace the for loop you have there with everything inside the Shoot() below.
C#:
// What if I wanted it to shoot like a shotgun?
        // Shotgun style: Multiple Projectiles, Random spread
        /*public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int numberProjectiles = 4 + Main.rand.Next(2); // 4 or 5 shots
            for (int i = 0; i < numberProjectiles; i++)
            {
                Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(30)); // 30 degree spread.
                // If you want to randomize the speed to stagger the projectiles
                // float scale = 1f - (Main.rand.NextFloat() * .3f);
                // perturbedSpeed = perturbedSpeed * scale;
                Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
            }
            return false; // return false because we don't want tmodloader to shoot projectile
        }*/

From there you can tweak the variables however you want.
One last thing, your SetDefaults() is missing a "{" after.

And that should be everything!
 
Back
Top Bottom