Standalone [1.3] tModLoader - A Modding API

@Coolgaming933
Seems you had code from tModLoader 0.9, you need to separate the tooltip and name from the rest now.
here's it fixed up, tell me if it works!

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace UpdatedTerrariaMod.Items.IceyGreatsword
{
public class IceyGreatsword : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Icey Greatsword");
Tooltip.SetDefault("An Icey Blade That Can Resist Fire.");
}
public override void SetDefaults()
{
item.damage = 56;
item.melee = true;
item.width = 60;
item.height = 60;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 6;
item.value = Item.buyPrice(0, 1, 0, 0);
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

I think that the code is correct but I'm not Good enough to setup the script
 
can you give me the full error?

Sure

c:\Users\richi\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\UpdatedTerrariaMod\Items\IceyGreatsword\IceyGreatsword.cs(11,18) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
 
Question! How can you make an npc spawn another npc on a multiplayer server? I've figured out npc.newnpc(...), and I set netUpdate to true once I create it. I've tried a lot of different ways, but nothing seems to work. It never spawns on another player's screen, though it does on my screen if I activate it.

Code:
int npcIndex = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Virus"));
            Main.npc[npcIndex].netUpdate = true;
I've found that NPC's simply cannot be spawned client-side without your problem happening. You'll have to find and use a hook that is called server-side and create your NPC there. Put something like the following in a hook to see if it's being called server side.
Console.WriteLine("Name of hook");
Once you find a hook that works, remember to prevent the NPC from being spawned server-side or you'll get duplicate NPCs.
 
Sure

c:\Users\richi\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\UpdatedTerrariaMod\Items\IceyGreatsword\IceyGreatsword.cs(11,18) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

That error comes from referencing Item.name, which your old code does but not the revised version you were given.
 
now its just Tremor it says
The mp3 sound file at Sounds/Music/Trinity.mp3 failed to load
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

Inner Exception:
Operation is not valid due to the current state of the object.
at Microsoft.Xna.Framework.Audio.WavFile.ParseWavHeader()
at Microsoft.Xna.Framework.Audio.WavFile..ctor(Stream source)
at Microsoft.Xna.Framework.Audio.WavFile.Open(Stream stream)
at Microsoft.Xna.Framework.Audio.SoundEffect..ctor(Stream stream)
at Microsoft.Xna.Framework.Audio.SoundEffect.FromStream(Stream stream)
at Terraria.ModLoader.Mod.Autoload()
 
Last edited:
I've found that NPC's simply cannot be spawned client-side without your problem happening. You'll have to find and use a hook that is called server-side and create your NPC there. Put something like the following in a hook to see if it's being called server side.
Console.WriteLine("Name of hook");
Once you find a hook that works, remember to prevent the NPC from being spawned server-side or you'll get duplicate NPCs.

Makes sense to me. I'm currently creating an NPC that spawns a new NPC upon hitting a player. I have a couple questions, though. First of all, what's a general example of a server-side hook? I don't completely understand what code is called by the server and what isn't. Along with that, I thought that we don't want the NPCs to be spawned in the clients, but instead have them spawned by the server and then updated in the clients. Could you verify that?
 
Makes sense to me. I'm currently creating an NPC that spawns a new NPC upon hitting a player. I have a couple questions, though. First of all, what's a general example of a server-side hook? I don't completely understand what code is called by the server and what isn't. Along with that, I thought that we don't want the NPCs to be spawned in the clients, but instead have them spawned by the server and then updated in the clients. Could you verify that?
I wouldn't say that there's a specific example of a server-side hook. Many hooks are called both server-side and client-side, some are client-side only and some are server-side only. The only way to find out which is which that I know of is to test each hook manually. You could try something like this in your NPC's class.
Code:
public override void OnHitPlayer(Player target, int damage, bool crit)
{
    Main.NewText("Client Hook: OnHitPlayer");
    Console.WriteLine("Server Hook: OnHitPlayer");
}
A message will pop up in chat when this hook is called on a client, and a similar message will appear in the server's console window. If your hook is called both client and server-side, you'll want to prevent it being called on the client.
Code:
if (Main.netMode != 1) //when not on a client...
{
    //spawn NPC here
}
I like to run the game windowed while testing so that I can see what's happening in the console window. Be aware that some things on a client aren't updated to a server, and you'll need to account for that. For example, I created a debug item that could spawn an enemy where I clicked. But I ran into the same problem you did when testing on a multiplayer game. So I came up with the following...
Code:
public override bool UseItem(Player player)
{
    if (Main.netMode == 0) //when singleplayer, summon at mouse location
    {
        NPC.NewNPC((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 161); //eskimo zombie
    } else if (Main.netMode == 2) //when multiplayer, summon above player
    {
        int npcID = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y - 100, 161);
        if (npcID < 200)
        {
            NetMessage.SendData(23, -1, -1, null, npcID);
        }
    }
    if (Main.netMode != 2)
        Main.PlaySound(6, (int)player.position.X, (int)player.position.Y, 2);
    return true;
}
I hope that's been useful.
 
Hello everyone. I have a little problem. I was playing in my modded world, and I had to turn off my computer.
I closed the world, it saved normally, closed Terraria normally, and turned off my PC. When Im about to reenter my world, there are a few things that seems to me very weird:
  1. No world name, no Hardmode symbol (In other words, The yellow leafs on the World Icon)
  2. Instead of "Medium World", Its showed as "Unknown World"
  3. Once I pressed Play, it gave me a Crash:

"Índice fora dos limites da matriz.
at Terraria.Player.Spawn()
at Terraria.WorldGen.do_playWorldCallBack(Object threadContext)
at Terraria.WorldGen.playWorldCallBack(Object threadContext)"
Lost around 10 hours of Building and Progress on that World.
Someone help me asap
 
HI, I need some help if anyone is able to. I am trying to host a multiplayer modded server on a Mac. Doing the host and play resulted in being stuck on "Starting server". I tried running the tModLoaderServer in terminal like I would for a normal terraria server and I get this error

-bash: /Users/User/Library/Application Support/Steam/steamapps/common/Terraria/Terraria.app/Contents/MacOS/tModLoaderServer: /bin/bash^M: bad interpreter: No such file or directory

Anybody know what I can do to get this running??
Thank you
 
does anybody know how to extract mods without starting terraria?

because i have a bug that doesnt alow me to start t mod loader it loads them forever and gives a error message
 
the discord link isnt working was the server deleted
discord.me/tmodloader still works for me

does anybody know how to extract mods without starting terraria?

because i have a bug that doesnt alow me to start t mod loader it loads them forever and gives a error message
you can hold shift while tmodloader is starting up to skip loading mods. You could also just edit the enabled.json file.
 
Whenever I open up Terraria, the mods initialize, but once they finish loading, Terraria just crashes! There's no report or anything. I've tried opening Terraria multiple times but I always come out to no avail. Anyone who can help, thanks!
[doublepost=1504261904,1504261829][/doublepost]
discord.me/tmodloader still works for me


you can hold shift while tmodloader is starting up to skip loading mods. You could also just edit the enabled.json file.
By that, do you mean in terraria?
 
Whenever I open up Terraria, the mods initialize, but once they finish loading, Terraria just crashes! There's no report or anything. I've tried opening Terraria multiple times but I always come out to no avail. Anyone who can help, thanks!
[doublepost=1504261904,1504261829][/doublepost] By that, do you mean in terraria?
Edit the enabled.json file in a text editor:"?:\Documents\My Games\Terraria\ModLoader\Mods\enabled.json"
 
Back
Top Bottom