Standalone [1.3] tModLoader - A Modding API

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

// One of the problems you're encountering is that you're using the semicolon wrong.
// You only want to use the semicolon ( ; ) when closing a line of code, but if you look below, you're closing your namespace while you're trying to open it.
// Same goes for your class and SetDefaults method, so:

namespace ExampleMod.Items.Weapons // <-- Remove this semicolon
{
    public class ExampleGun : ModItem 
    {
        public override void SetDefaults() // <-- And this one this semicolon
        {
            item.name = ".55 Magnum";
            item.damage = 5500;
            item.ranged = true;
            item.width = 28;
            item.height = 20;
            item.toolTip = "This magnum is MORE powerful?!";
            item.toolTip2 = "I bet this shreds people with 1 shot.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 13;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 18; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 30f;
            item.useAmmo = ProjectileID.Bullet;
        }
       
        {// The following code... What is it encapsulated in? There's no function call here!
        Vector2[] speeds = ModHelper.Projectile.evenArc( 16f, 16f, 45, 5);
        for (int i = 0; i < 5; ++i)
        {
            Terraria.Projectile.NewProjectile(Main.player[0].position.X, Main.player[0].position.Y, speeds.X, speeds.Y, 45, 45, 15f);
        }
        }

        {// Same story here as above, no function is being called, so this code is just floating here...
        {
            if (Main.rand.Next(0, 4) == 0); // 50% chance not to consume ammo.
                return false;
            return true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
        }
    }
 
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

// One of the problems you're encountering is that you're using the semicolon wrong.
// You only want to use the semicolon ( ; ) when closing a line of code, but if you look below, you're closing your namespace while you're trying to open it.
// Same goes for your class and SetDefaults method, so:

namespace ExampleMod.Items.Weapons // <-- Remove this semicolon
{
    public class ExampleGun : ModItem
    {
        public override void SetDefaults() // <-- And this one this semicolon
        {
            item.name = ".55 Magnum";
            item.damage = 5500;
            item.ranged = true;
            item.width = 28;
            item.height = 20;
            item.toolTip = "This magnum is MORE powerful?!";
            item.toolTip2 = "I bet this shreds people with 1 shot.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 13;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 18; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 30f;
            item.useAmmo = ProjectileID.Bullet;
        }
      
        {// The following code... What is it encapsulated in? There's no function call here!
        Vector2[] speeds = ModHelper.Projectile.evenArc( 16f, 16f, 45, 5);
        for (int i = 0; i < 5; ++i)
        {
            Terraria.Projectile.NewProjectile(Main.player[0].position.X, Main.player[0].position.Y, speeds.X, speeds.Y, 45, 45, 15f);
        }
        }

        {// Same story here as above, no function is being called, so this code is just floating here...
        {
            if (Main.rand.Next(0, 4) == 0); // 50% chance not to consume ammo.
                return false;
            return true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
        }
    }
Allright, this part here:
Code:
{// The following code... What is it encapsulated in? There's no function call here!
    Vector2[] speeds = ModHelper.Projectile.evenArc( 16f, 16f, 45, 5);
    for (int i = 0; i < 5; ++i)
    {
        Terraria.Projectile.NewProjectile(Main.player[0].position.X, Main.player[0].position.Y, speeds.X, speeds.Y, 45, 45, 15f);
    }
}

{// Same story here as above, no function is being called, so this code is just floating here...
{
    if (Main.rand.Next(0, 4) == 0); // 50% chance not to consume ammo.
        return false;
    return true;
}
There are still things wrong here. You forgot to add the method signatures.
I can guess what you're trying to do by the naming of some of the code parts, so here you go:
Code:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    Vector2[] speeds = ModHelper.Projectile.evenArc(16f, 16f, 45, 5);
    for (int i = 0; i < 5; ++i)
    {
        Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
    }

    return false;
}
public override bool ConsumeAmmo(Player player)
{    
    if (Main.rand.Next(0, 4) == 0); // 25% chance not to consume ammo.
        return false;
    return true;
}
This is probably what you're looking for. Note that all I really did was adding the method signatures (and did made some changes to the shoot code).
 
Hello,
i have a few of questions and hope someone will be able to help me out. :)

1. I am looking for a Terraria vanilla dust list. I know i have seen one once but i cannot find it anymore, would be nice if someone can give me a link.

2. I am trying to add a doubleclick Dash, similar to the Ninjatabi and EoC-Shield Dash, to an Sword. I was able to attach the EoC-Shield Dash to my Sword but i want my own Dash with 100% knockbackresistence and dmg immunity while dashing as well as dealing dmg to every enemy hit, but costing mana on use. I hope someone can tell me how to do this :)

3. I want to add a Sword that is using the normal sword picture in the inventory but uses an Animation on use instead of swinging it. I tryed this as shown in the Example mod in the Face.cs but what i got was an Animated Sword in the inventory and the while Animation Sprite as one img on swing.

These are all my current questions, i hope someone will be able to help me out, even one answer to one of my problems would help me out for now, as i would be able to continue with my mod until i geet answers on the others. :) tY
 
Hello,
i have a few of questions and hope someone will be able to help me out. :)

1. I am looking for a Terraria vanilla dust list. I know i have seen one once but i cannot find it anymore, would be nice if someone can give me a link.

2. I am trying to add a doubleclick Dash, similar to the Ninjatabi and EoC-Shield Dash, to an Sword. I was able to attach the EoC-Shield Dash to my Sword but i want my own Dash with 100% knockbackresistence and dmg immunity while dashing as well as dealing dmg to every enemy hit, but costing mana on use. I hope someone can tell me how to do this :)

3. I want to add a Sword that is using the normal sword picture in the inventory but uses an Animation on use instead of swinging it. I tryed this as shown in the Example mod in the Face.cs but what i got was an Animated Sword in the inventory and the while Animation Sprite as one img on swing.

These are all my current questions, i hope someone will be able to help me out, even one answer to one of my problems would help me out for now, as i would be able to continue with my mod until i geet answers on the others. :) tY
1. This, but I don't know if it has been updated for newer versions.
2. Look into the source and how dashes are done (I got my custom one fixed in 10 minutes approx.).
3. Don't know how this would be done. Probably possible, but don't have time to try and figure that out now (someone else may be able to help).
 
1. This, but I don't know if it has been updated for newer versions.
2. Look into the source and how dashes are done (I got my custom one fixed in 10 minutes approx.).
3. Don't know how this would be done. Probably possible, but don't have time to try and figure that out now (someone else may be able to help).

1. Yeah i found that as well but it didnt really helped me out, i thought about something with pictures like This: http://forums.terraria.org/index.php?attachments/dust-png.79379/ ; but it seems like they are in the wrong order or something...

2. Thats sounds helpfull could you tell me how to do that?

3. Ok maybe someone else can help me there :)

And thanks for the fast reply!
 
1. Yeah i found that as well but it didnt really helped me out, i thought about something with pictures like This: http://forums.terraria.org/index.php?attachments/dust-png.79379/ ; but it seems like they are in the wrong order or something...

2. Thats sounds helpfull could you tell me how to do that?

3. Ok maybe someone else can help me there :)

And thanks for the fast reply!
1. What order do you think they are in? ;)
2. Quicket way (which I also use) is to download IlSpy (google!) binaries, drag and drop your Terraria.exe file into the program and you're good to go.
NOTE: it will take a little while to decompile some of the classes via IlSpy, but you'll want to look for a class called Player.
 
1. What order do you think they are in? ;)
2. Quicket way (which I also use) is to download IlSpy (google!) binaries, drag and drop your Terraria.exe file into the program and you're good to go.
NOTE: it will take a little while to decompile some of the classes via IlSpy, but you'll want to look for a class called Player.
1. Well the order they are in your link seem to be correct ( at least the colors seem to be those discribed, but it doesnt work if i count the columns in the image i linked. The discriptions of the first link arent specific enought tho :c

2. Thanks for your help, im just reading the code :)
 
still no answers. please, community. I beg you.

getting this crash error while playing multiplayer: http://imgur.com/p20h9mO

occurs after random stuff like shooting, using items, dropping stuff from mobs. I'm the host of the server too. I know that the tmodloader actual version isnt that good for multiplayer but I don't get why this keeps happening.

thanks :)
 
omg :c i cannot handle this!
i have read the code and i think i found what i need to create a dash, but i dont know how to access the player position, int dash and so on from the Terraria -> player class...
i dont know how to add a spoiler, its much code, can someone tell me how to add a spoiler so im able to show what i have found?
 
still no answers. please, community. I beg you.

getting this crash error while playing multiplayer: http://imgur.com/p20h9mO

occurs after random stuff like shooting, using items, dropping stuff from mobs. I'm the host of the server too. I know that the tmodloader actual version isnt that good for multiplayer but I don't get why this keeps happening.

thanks :)
It keeps happening because Terraria's codebase isn't that great.
This is most likely fixed for the next version which will be released in a few hours.
 
@bluemagic123 I tried fixing it by hosting the local server in my laptop while playing on the pc. for now, no crashes.
also, new version in a bit? awesome! gotta stay tuned :)

thx
 
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.
 
Last edited:
I'm getting the following error when trying to rebuild mods:
error CS1704: An assembly with the same simple name 'MP3Sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.
 
Back
Top Bottom