Standalone [1.3] tModLoader - A Modding API

v0.8:
Server Bugs:
-Fixed server sync bug with OnPickup hook for items
-Fixed server bug where chests are not synced properly
-Fixed bug where Steam servers don't work
-Hopefully fixed ItemLoader.GetAlpha crash for clients on servers
-Hopefully fixed NPCs disappearing on servers? Please?
-Fixed server bug where custom item data is not synced
-Fixed server bug where custom town NPCs do not work
Other Bugs:
-Fixed bug where bottom half of long hair does not draw
-Fixed bug where modded tiles crashed the game in early stages of world generation
-Fixed bug where Start Bag cannot contain vanilla items
-Fixed bug where Mod.GetEquipTexture always returns null
-Mods with sounds now load for people without sound cards
-Fixed NPC.CloneDefaults with buffImmune
-Fixed bug where SetMatch hook doesn't work at all
-Added the ability to build and debug mods from Visual Studio
-Improved the .tmod file format
-Added the ability to support future .tmod file format changes
-Renamed Other.dll to Mono.dll for noCompile mod-building
-Mods can now reference embedded dlls
-Added the ability to compile mods in C# 6
-Made the Mod Browser more secure
-ItemIO can now save items in general, including vanilla items
-Mods menu now displays how much stuff each mod adds
-Detect and display modder errors in LoadCustomData
-Huge performance improvements
-Changed structure of equipment update code to make it easy to create new equipment slots
-Converted some local world generation variables to static fields
-Made Player.jumpSpeed and Player.jumpHeight public
-Made a bunch of Mount fields public
-Added April Fools (sorry this was late)
-Added GlobalRecipe and RecipeAvailable hook for recipes
-Added gender parameter to SetMatch hook for items
-Added generic GetModX accessors for reduced redundancy
-Added OnCraft hook for recipes and items
-Added TileCountsAvailable hook for ModWorld
-Added GetMapBackgroundImage hook for ModPlayer
-Added ModifyBuffTip hook for buffs
-Added option to use constructor for cloned ModPlayers
-Added DrawEffects and CanExplode hooks for tiles
-Made code source files hidden from tModReader based on hideCode instead of hideResources

All mods must be rebuilt! Mods from v0.7.1.1 or earlier will not work!
The format for mod properties and the build.txt version have changed! Please look at the ExampleMod!

Mod properties must be made in the constructor, and you cannot put a "v" in your version number (we do that for you).

Code:
        //old
        //public override void SetModInfo(out string name, ref ModProperties properties)
        //{
        //    name = "TheLuggage";
        //    properties.Autoload = true;
        //    properties.AutoloadGores = true;
        //    properties.AutoloadSounds = true;
        //}
        //new
        public TheLuggage()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }

Edit 1: Also, if you had previous versions of tModLoader, you'll need to delete MP3Sharp.dll from your Terraria's Steam folder.

Now that that's out of the way, I don't remember whether I announced this or not, but @Chicken Bones is officially part of the team now! Ever since he's joined, progress has picked up a lot, and there's been tons of internal improvements, so be sure to thank him!

I had an April Fools joke in this update, but it looks like this update got released a bit late. Oh well, hope you guys can enjoy a day-late April Fools joke.

Was I going to say anything else? I don't remember... I guess I'll edit this post as things come up, just as usual.
Awesome, nice work!
Unfortunately my laptop just died, so I'll have to wait a while before I can enjoy this update :'(
 
I try to build my mod and this error pops out:
error CS0115: „EpicModpack.EpicModpack.SetModInfo(out string, ref Terraria.ModLoader.ModProperties)”: nie znaleziono odpowiedniej metody do zastąpienia
 
How do I get my custom music to play custom music?
Have you followed the example of ExampleMod? In what situation are we talking?
I try to build my mod and this error pops out:
error CS0115: „EpicModpack.EpicModpack.SetModInfo(out string, ref Terraria.ModLoader.ModProperties)”: nie znaleziono odpowiedniej metody do zastąpienia
Go read bluemagics post, the structure has changed a bit.
 
Tmodloader saves are separate from your original saves. And you could do a global npc script that override the spawning of the monsters . If you dont know how to make that PM me and I can do the mod it for you:p
So I'm finally getting around to trying to make my mod happen and I'm having a problem getting Visual Studio setup to work with the mods. All the terraria specific code/calls are being highlighted/underlined. Is there a doc on how to setup Visual Studio to work with tModLoader?

- Aerlock
 
So I saw in bugfixes for v0.8 you had done some work on trying to fix the issue of NPCs disappearing on multiplayer servers. I was excited for this because me and my friends have been trying to get a server with mods on it for a while only to find modded enemies would disappear on hit each time. So I did some testing on my private server running the tremor mod and this is what I've found.
-Only Certain enemies are disappearing on hit (Undead Warriors from the tremor mod)
-Sometimes if there are multiple on screen if I hit one the other will disappear (I'm not sure if im imagining this one or not)
-The guide on the new world I've started still shoots at the invisible enemies as if they are still there and following me
-The guide can still be hit by the enemies if I lead them into
-After about 30 seconds the invisible mob sometimes reappears and stays visible
-After they reappear they seem to have taken damage from the guide
-I'm the only one on my server at the moment ( I have no one else to test with at the moment)
-A little off topic is enemies are sometimes teleporting around once they get close to me even though my server is ran off the same network which suggests some desyncronization which doesn't happen on my vanilla server
-I have none of these problems on vanilla so they should all be a result of using the mod
-these situations do not happen in single player
If There is any other testing you would like me to do I would be glad to help! I hope this is of some use!
 
How can I place tile 3x2, when I tried before only 1/3 tile was placed. I saw that I have to modify this:
Code:
TileObjectData.newTile.CoordinateHeights = new int[]{ 18 };
but I don't know how.
 
Whath?
Error CS1704: ******(A lot of *s because of translation) "Steamworks.NET, Version=7.0.0.0, Culture=neutral, PublickKeyToken=null (Much more of *s).
 
How can I place tile 3x2, when I tried before only 1/3 tile was placed. I saw that I have to modify this:
Code:
TileObjectData.newTile.CoordinateHeights = new int[]{ 18 };
but I don't know how.
TileObjectData.newTile.Width = 3;
TileObjectData.newTile.Height = 2;
 
Heyo bluemagic123, unfortunately the NPCs dissappearing on multiplayer servers is even worse now. Half of the Normal mobs and Modded mobs dissappear on hit. From Tremor Mod's monsters to Vanilla Plantera. Everything. Hope you can fix it and good luck with your homework!
-TCFail
 
How can I place tile 3x2, when I tried before only 1/3 tile was placed. I saw that I have to modify this:
Code:
TileObjectData.newTile.CoordinateHeights = new int[]{ 18 };
but I don't know how.
TileObjectData.newTile.CoordinateHeights = new int[]{ 18 }; defines height of one block in tile in pixels.
For example TileObjectData.newTile.CoordinateHeights = new int[]{ 16, 18, }; means that upper block int tile made of 16 pixels and lower made of 18 pixels (18 pixels are using to "put" it in the ground like this
h_1459619492_7279478_7e2d247ecb.png
)
 
public override void AI()
{
projectile.timeLeft += 1000;
projectile.rotation += 0.05f;
Dust.NewDust(projectile.position, projectile.width, projectile.height, 158);
fCount++;
if (fCount > 70)
{

if (Main.npc[projectile.owner].position.X < projectile.position.X)
{
//projectile.velocity.X = -10 ;
}

if (Main.npc[projectile.owner].position.X > projectile.position.X)
{
//projectile.velocity.X = 10;
}

if (Main.npc[projectile.owner].position.Y < projectile.position.Y)
{
//projectile.velocity.Y = -10 ;
}

if (Main.npc[projectile.owner].position.Y > projectile.position.Y)
{
//projectile.velocity.Y = 10;
}

/*Rectangle a = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
Rectangle prjRec = new Rectangle((int)Main.npc[projectile.owner].position.X, (int)Main.npc[projectile.owner].position.Y,Main.npc[projectile.owner].width,Main.npc[projectile.owner].height);
if (a.Intersects(prjRec))
{
projectile.Kill();
}*/
}
}

The above is the code for the AI method of a projectile. For some reason, every time the variable fCount reaches 70, the projectile kills itself. I have been commenting out particular sections (as you can see) and I have narrowed it down to some 'if statements'... What am I doing wrong and how on earth do 'if statements' with no uncommented code within do anything?

[EDIT]
On further inspection, it seems like any reference to Main.npc[projectile.owner] kills it. Is there a reason behind this or is this some kind of bug?
 
Craftgroups haven't changed. My signature has a guide for them.
I've already found that out. Thank you anyways.
TileObjectData.newTile.CoordinateHeights = new int[]{ 18 }; defines height of one block in tile in pixels.
For example TileObjectData.newTile.CoordinateHeights = new int[]{ 16, 18, }; means that upper block int tile made of 16 pixels and lower made of 18 pixels (18 pixels are using to "put" it in the ground like this
h_1459619492_7279478_7e2d247ecb.png
)
Thank you!
 
public override void AI()
{
projectile.timeLeft += 1000;
projectile.rotation += 0.05f;
Dust.NewDust(projectile.position, projectile.width, projectile.height, 158);
fCount++;
if (fCount > 70)
{

if (Main.npc[projectile.owner].position.X < projectile.position.X)
{
//projectile.velocity.X = -10 ;
}

if (Main.npc[projectile.owner].position.X > projectile.position.X)
{
//projectile.velocity.X = 10;
}

if (Main.npc[projectile.owner].position.Y < projectile.position.Y)
{
//projectile.velocity.Y = -10 ;
}

if (Main.npc[projectile.owner].position.Y > projectile.position.Y)
{
//projectile.velocity.Y = 10;
}

/*Rectangle a = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
Rectangle prjRec = new Rectangle((int)Main.npc[projectile.owner].position.X, (int)Main.npc[projectile.owner].position.Y,Main.npc[projectile.owner].width,Main.npc[projectile.owner].height);
if (a.Intersects(prjRec))
{
projectile.Kill();
}*/
}
}

The above is the code for the AI method of a projectile. For some reason, every time the variable fCount reaches 70, the projectile kills itself. I have been commenting out particular sections (as you can see) and I have narrowed it down to some 'if statements'... What am I doing wrong and how on earth do 'if statements' with no uncommented code within do anything?

[EDIT]
On further inspection, it seems like any reference to Main.npc[projectile.owner] kills it. Is there a reason behind this or is this some kind of bug?
That's because projectile.owner only defines players, not npcs. All NPC projectiles are owned by Main.myPlayer usually.
 
Back
Top Bottom