Standalone [1.3] tModLoader - A Modding API

I've been trying to get some aspects of my mod working on with a server. I've been using "Main.NewText("something");" and "Console.WriteLine("something else");" to see what does and doesn't happen, and I've noticed some odd things.

When I use an item, the UseItem hook isn't called on the owner in singleplayer or the owner's client in multiplayer, but it is called on the server and other clients. I've also noticed that the Shoot hook is only called on the client of the item's owner, but not other clients or the server.

Are these bugs or intentional behaviour?
The source code does some really weird things.

Because the UseItem hook is called on the server, it allows for things like NPCs to spawn. Because the Shoot hook is called only on the client, it allows for the projectile's owner to be easily set (and also makes it so that you can see what you shoot right away).
 
Looks like you either have a pre 0.7.1 Terraria.exe or a pre 0.7.1 TerrariaMac.exe.

Here is ore generation:
Code:
        public override void PostWorldGen()
        {
            for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
            {
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("CoalOre"), false, 0f, 0f, false, true);
            }
        }
[DOUBLEPOST=1456561663,1456561555][/DOUBLEPOST]
I can't think of how to make that work.
[DOUBLEPOST=1456561682][/DOUBLEPOST]
You can't yet.
[DOUBLEPOST=1456561946][/DOUBLEPOST]
Sounds like a problem with the computer, since vanilla Terraria sounds don't work. I'd suggest reinstalling XNA, maybe even windows media player.
[DOUBLEPOST=1456562340][/DOUBLEPOST]

Terraria has a 2d array of tiles that represent the world, and it is initialized to the size of the world. Where would the alternate dimension fix in there? How would a server handle 2 players being in different dimensions when in reality they are right next to each other.(Their X Y positions)

Anyway, I managed something like this before, but I never went farther with the idea since I was certain it would end poorly:
The endless quiver and pouch do that with certain ammo and Alchemy station with every crafting material.

Or just how to make something similiar to Alchemy Station?
 
Hey, I have the problem that i am new to the modding and i want to ask, if i copy the example and change it so it fits my mod, like the sword one are there some things that i dont need to copy? Sorry form my bad spelling xD my english is pretty bad.
 
Hey, I have the problem that i am new to the modding and i want to ask, if i copy the example and change it so it fits my mod, like the sword one are there some things that i dont need to copy? Sorry form my bad spelling xD my english is pretty bad.
The only things you'll need are the build.txt file, the ExampleMod.CS file, the description.txt file and the .CS and .png files for the weapon (in the correct folder).
 
So which aspect of this correlates to the amount of veins that spawn in the world, not just the size of the veins? Is it the uh... 6E-05?
Code:
public override void PostWorldGen()
        {
            for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
            {
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 7), mod.TileType("ThoriumOre"), false, 0f, 0f, false, true);
            }
        }
 
Last edited:
I'm trying to get the endless snowball from my mod to be recognized as ammo for the snowball cannon, but the usual method for getting it to work isn't working.
I have:
Code:
            item.ammo = 166;
which is the projectile ID for the snowball, but it doesn't work as ammo for the cannon.
 
I'm trying to get the endless snowball from my mod to be recognized as ammo for the snowball cannon, but the usual method for getting it to work isn't working.
I have:
Code:
            item.ammo = 166;
which is the projectile ID for the snowball, but it doesn't work as ammo for the cannon.
The item.ammo usually corrosponds with an item's type. For example, with arrows, all of the arrows (i.e. jester arrow, fire arrow, etc.) are set with their item.ammo as the basic wooden arrow's item type. The weapon usually has their item.useAmmo as an item's type, which is why it is not working, I do not know how setting it to projectile IDs have actually worked.
 
The item.ammo usually corrosponds with an item's type. For example, with arrows, all of the arrows (i.e. jester arrow, fire arrow, etc.) are set with their item.ammo as the basic wooden arrow's item type. The weapon usually has their item.useAmmo as an item's type, which is why it is not working, I do not know how setting it to projectile IDs have actually worked.
I got it to work by setting it the the item id, thanks!
 
After updating to the new version and updating my only mod (tremor) i have this wierd texture in the backround at night. It looks like lines going across the screen. Does anyone know what this is?
 
please make a config file for each mod, that allow user to config mods. example:

Code:
enableZombie=true
enableSkeleton=true
enableArmor=true
enableShield = false

from this config, it'll disable all Shields in game.

sorry for my bad english. :)
 
@jopojelly How would it end poorly?
What I mean by that is it would be a huge mess of code trying to fix every situation that arises and it would be a headache.

Nice tool. But why reloading all mods when some already loaded ??
To make everything perfect, believe me, it's the way to do it.

Is it the uh... 6E-05?
Yes. If you didn't know, that means 0.00006.

Also, here are the method parameters: WorldGen.TileRunner(int i, int j, double strength, int steps, int type, bool addTile = false, float speedX = 0f, float speedY = 0f, bool noYChange = false, bool overRide = true)

After updating to the new version and updating my only mod (tremor) i have this wierd texture in the backround at night. It looks like lines going across the screen. Does anyone know what this is?
No idea, can you show us?

please make a config file for each mod, that allow user to config mods. example:

Code:
enableZombie=true
enableSkeleton=true
enableArmor=true
enableShield = false

from this config, it'll disable all Shields in game.

sorry for my bad english. :)
There will be configuration options later, but they will be determined by the mod makers.

wait, so 7.1 added worldgen stuff? i hadn't realized that O_O
Yup!
 
What I mean by that is it would be a huge mess of code trying to fix every situation that arises and it would be a headache.
No idea, can you show us?
I just launcher the game to take a screenshot and its gone.... i guess my game loaded wrong before or something.
 
So what would need to go into the min of the int J to be right above the hell/underworld layer? I have this currently, but I'm not even sure if it would recognize (int)WorldGen.worldSurfaceLow as a suitable max on the Y-axis. Does it have something to do with manipulating the Main.maxTilesY?

(int)WorldGen.worldSurfaceLow sounds like the bottom of the surface layer, correct me if I'm wrong... :sigh:
Code:
WorldGen.genRand.Next(?, (int)WorldGen.worldSurfaceLow)
 
I tried to make a projectile spin and grow larger, but it only grew larger. Please help!
Code:
public override void AI()
        {
            projectile.scale += 0.02f;
            projectile.rotation += 0.5f;
        }
 
Back
Top Bottom