Standalone [1.3] tModLoader - A Modding API

Here's the steps broken down:
1. In your Terraria installation directory, find Terraria.exe and TerrariaServer.exe.
2. Copy these files into (tML download)/Patcher/Vanilla.
3. Run Patcher.bat (from tML download). A modded Terraria.exe and tModLoaderServer.exe should appear in Patcher/tModLoader.
4. Copy these new files into your Terraria installation directory. Replace Terraria.exe.
5. Copy all items in the Files folder (in tML download) into your Terraria installation directory (the same place you found and replaced Terraria.exe).
6. Launch and play! Hopefully.
If you're sure you've completed these exact steps and still get an error, please let us know (and provide a screenshot/paste)
I completed those steps correctly Heres the error
57c7140e095e45a6b0b61c76f0d1d910.png
http://image.prntscr.com/image/57c7140e095e45a6b0b61c76f0d1d910.png
 
So i'v never had this problem before with tmodloader but my firewall is blocking two files called RoslynWrapper.dll and Mono.Cecil.Pdb.dll when i download tmodloader are thy needed as i am running it fine with out them? Also i just got the newest update as well.
Hm, if I remember correctly those are just needed if you want to compile your mods using C# 6.

@Mineblaze Go to Steam\steamapps\common\Terraria and it will be in there
[doublepost=1465398879,1465398692][/doublepost]@bluemagic123 i need some serious help, i don't know how to make RecipeGroups. Can you please help me???
There's an example of creating a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/ExampleMod.cs#L63
There's an example of using a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Items/ExampleItem.cs#L25

I completed those steps correctly Heres the error
57c7140e095e45a6b0b61c76f0d1d910.png
Hm, I remember sometimes people would get this error at the beginning of tModLoader, which is why I eventually switched to just distributing the exe. Some quick googling tells me this is most likely related to the version of the NET framework.
 
Hm, if I remember correctly those are just needed if you want to compile your mods using C# 6.


There's an example of creating a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/ExampleMod.cs#L63
There's an example of using a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Items/ExampleItem.cs#L25


Hm, I remember sometimes people would get this error at the beginning of tModLoader, which is why I eventually switched to just distributing the exe. Some quick googling tells me this is most likely related to the version of the NET framework.
umm How could i fix this?
 
Two questions:
First, whenever i use this line of code in a solution (using the monochrome from your example mod)
Code:
                                                if (TileID.Sets.Conversion.Grass[type])
                        {
                            Main.tile[k, l].type = (ushort)mod.TileType("SpiritGrass");
                            WorldGen.SquareTileFrame(k, l, true);
                            NetMessage.SendTileSquare(-1, k, l, 1);
                        }
to change grass to a block to spiritgrass, a lot of crazy crap happens. Example:
:red:.PNG

How can I fix this?

Second question:
How do I make this line (from monochrome)
Code:
                        int type = (int)Main.tile[k, l].type;
                        int wall = (int)Main.tile[k, l].wall;
                        if (wall != 0)
                        {
                            Main.tile[k, l].wall = (ushort)mod.WallType("SpiritNaturalWall");
                            WorldGen.SquareWallFrame(k, l, true);
                            NetMessage.SendTileSquare(-1, k, l, 1);
                        }
Only targeet naturual walls (grass walls or stone walls)
and how to I make natural walls (Walls that act like natural walls (Have to be broken from edge)
[doublepost=1465404956,1465404777][/doublepost]Heres the tile sheet if it helps:
SpiritGrass.png
 
Is anyone else having a problem where transparent projectiles are not transparent? This includes vanilla projectiles. Has this bug been pointed out yet?

EDIT: Nevermind, the problem seems to be with a certain mod.
 
Last edited:
Hm, if I remember correctly those are just needed if you want to compile your mods using C# 6.


There's an example of creating a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/ExampleMod.cs#L63
There's an example of using a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Items/ExampleItem.cs#L25


Hm, I remember sometimes people would get this error at the beginning of tModLoader, which is why I eventually switched to just distributing the exe. Some quick googling tells me this is most likely related to the version of the NET framework.
thanks!
[doublepost=1465416784,1465416761][/doublepost]
Anyone know why my game is like it's in slow motion?
do you have frame skip turned on or off?
[doublepost=1465416923][/doublepost]
Hm, if I remember correctly those are just needed if you want to compile your mods using C# 6.


There's an example of creating a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/ExampleMod.cs#L63
There's an example of using a RecipeGroup here: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Items/ExampleItem.cs#L25


Hm, I remember sometimes people would get this error at the beginning of tModLoader, which is why I eventually switched to just distributing the exe. Some quick googling tells me this is most likely related to the version of the NET framework.
For some reason it isn't compiling
 
@bluemagic123 My mod is currently too large for the mod browser. Would there be any way I could make it available there without having to cut parts of it out?

Thanks in advance!
 
Guys I am still having an issue with items not dropping in multiplayer, I saw a post earlier saying that the multiplayer bugs were fixed, is it still bugged or am I just doing something wrong? It wouldn't be the first time lol.
 
Guys I am still having an issue with items not dropping in multiplayer, I saw a post earlier saying that the multiplayer bugs were fixed, is it still bugged or am I just doing something wrong? It wouldn't be the first time lol.
No items are dropping? You are on the latest and the latest tmodloader server?
 
It's on subtle
Subtle is the same thing as OFF. Well, actually, Subtle and OFF are supposedly different things, but I don't see any difference. Subtle is actually what OFF used to be, then they made the new OFF from an older version of the Frame Skip option.

Set Frame Skip to ON for general play, removes the slow motion effect. However, I find that the slow motion is incredibly helpful for bosses, especially for ones that have fast attack patterns or generally tend to cause FPS drops. Do note that changing Frame Skip does absolutely nothing for people who get a solid 60 - slow motion is a super power only available to low-tier electronics. Cherish it.
 
Quick question:

When using 'GlobalNPC.EditSpawnRate()', does that (the spawnRate argument) affect all NPCs (monsters, critters, townNPCs), just monsters, monsters and critters, or all three?

EDIT:

Another question:

I have a town NPC that I want to sell a vanilla item, but the vanilla item's price is way below what I want it sold for. Is my only option to use GlobalItem.SetDefaults() and change the item's value, or is there another way besides that function and/or the item's value field?

EDIT:

Third question, or more like a request for confirmation.

Ok, I'm trying to make a door that is 4 blocks tall. When I use my item to place the closed door, it works. If I change the item to place the open door, that also work. But, if I try to close a placed open door or open a placed closed door, the door is destroyed and it returns 2 of the door items.

After doing some digging in the code, it seems to me that WorldGen.OpenDoor() and WorldGen.CloseDoor() are both hardcoded for 3 block tall doors. OpenDoor() creates six new tiles and CloseDoor() does loops x while less than x + 2 and y while less than y + 3. Am I reading that right?

Including my code for completeness, in case I messed something up:

Code:
    public class Barricade : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Construction Barricade";
            item.width = 32;
            item.height = 32;
            item.maxStack = 99;
            item.toolTip = "A barricade to restrict movement.";
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.value = 300;
            item.createTile = mod.TileType("BarricadeOpen");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }

Code:
    public class BarricadeClosed : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileFrameImportant[Type] = true;
            Main.tileBlockLight[Type] = true;
            Main.tileSolid[Type] = true;
            Main.tileNoAttach[Type] = true;
            Main.tileLavaDeath[Type] = true;
            TileObjectData.newTile.Width = 1;
            TileObjectData.newTile.Height = 4;
            TileObjectData.newTile.Origin = new Point16(0, 0);
            TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
            TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
            TileObjectData.newTile.UsesCustomCanPlace = true;
            TileObjectData.newTile.LavaDeath = true;
            TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 };
            TileObjectData.newTile.CoordinateWidth = 16;
            TileObjectData.newTile.CoordinatePadding = 2;
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(0, 1);
            TileObjectData.addAlternate(0);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(0, 2);
            TileObjectData.addAlternate(0);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(0, 3);
            TileObjectData.addAlternate(0);
            TileObjectData.addTile(Type);
            AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor);
            AddMapEntry(new Color(200, 200, 200), "Construction Barricade");
            dustType = mod.DustType("Sparkle");
            disableSmartCursor = true;
            adjTiles = new int[] { TileID.ClosedDoor };
            openDoorID = mod.TileType("BarricadeOpen");
        }

        public override void NumDust(int i, int j, bool fail, ref int num)
        {
            num = 1;
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 16, 64, mod.ItemType("Barricade"));
        }
    }

Code:
    public class BarricadeOpen : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileFrameImportant[Type] = true;
            Main.tileSolid[Type] = false;
            Main.tileLavaDeath[Type] = true;
            Main.tileNoSunLight[Type] = true;
            TileObjectData.newTile.Width = 2;
            TileObjectData.newTile.Height = 4;
            TileObjectData.newTile.Origin = new Point16(0, 0);
            TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 0);
            TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 0);
            TileObjectData.newTile.UsesCustomCanPlace = true;
            TileObjectData.newTile.LavaDeath = true;
            TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 };
            TileObjectData.newTile.CoordinateWidth = 16;
            TileObjectData.newTile.CoordinatePadding = 2;
            TileObjectData.newTile.StyleHorizontal = true;
            TileObjectData.newTile.StyleMultiplier = 2;
            TileObjectData.newTile.StyleWrapLimit = 2;
            TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight;
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(0, 1);
            TileObjectData.addAlternate(0);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(0, 2);
            TileObjectData.addAlternate(0);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(0, 3);
            TileObjectData.addAlternate(0);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(1, 0);
            TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
            TileObjectData.addAlternate(1);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(1, 1);
            TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
            TileObjectData.addAlternate(1);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(1, 2);
            TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
            TileObjectData.addAlternate(1);
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Origin = new Point16(1, 3);
            TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
            TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
            TileObjectData.addAlternate(1);
            TileObjectData.addTile(Type);
            AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor);
            TileID.Sets.HousingWalls[Type] = true; //needed for non-solid blocks to count as walls
            AddMapEntry(new Color(200, 200, 200), "Construction Barricade");
            dustType = mod.DustType("Sparkle");
            disableSmartCursor = true;
            adjTiles = new int[] { TileID.OpenDoor };
            closeDoorID = mod.TileType("BarricadeClosed");
        }

        public override void NumDust(int i, int j, bool fail, ref int num)
        {
            num = 1;
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 64, mod.ItemType("Barricade"));
        }
    }
 
Last edited:
I'm having trouble with a boomerang
I want it to be like the Paladin's hammer, but It won't penetrate at all, instead it just bounces of the enemy even when I say
projectile.penetrate = 10;

it has an ai style of 3 for boomerang

I have another problem with it as well which is It goes out at the proper fast speed, but then returns slow like an Ice boomerang. How can I make it return faster like the Paladin's hammer does

also, I wanted to make It heal the player, but I didn't like the Red line of the vampire heal When I had that in there so I removed it and tried

Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            player.statLife += 10; 
            player.HealEffect(10); 
        }

but that only seems to work for Item weapons and not projectiles

here's the code just in case

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

namespace Pack.Items.Weapons
{
    public class PossessedTempliteHammer : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Possessed Templite Hammer";
            item.damage = 120;
            item.melee = true;
            item.width = 32;
            item.height = 32;
            item.useTime = 15;
            item.useAnimation = 15;
            item.useStyle = 1;
            item.noMelee = true;
            item.knockBack = 2;
            item.noUseGraphic = true;
            item.value = 100000;
            item.rare = 8;
            item.useSound = 19;
            item.autoReuse = true;
            item.shoot = mod.ProjectileType("PossessedTempliteHammerP");
            item.shootSpeed = 20;
        }
       
      
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "TempliteIngot", 50);
            recipe.AddIngredient(null, "TempliteGem", 1);
            recipe.AddTile(TileID.MythrilAnvil);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

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

namespace Pack.Projectiles
{
    public class PossessedTempliteHammerP : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Possessed Templite Hammer";
            projectile.width = 32;
            projectile.height = 32;
            projectile.friendly = true;
            projectile.penetrate = 10;
            projectile.aiStyle = 3;
            projectile.melee = true;
            projectile.tileCollide = true;
            projectile.timeLeft = 60000;
            projectile.light = 1f;
        }
    }
}
 
I'm having trouble with a boomerang
I want it to be like the Paladin's hammer, but It won't penetrate at all, instead it just bounces of the enemy even when I say
projectile.penetrate = 10;

it has an ai style of 3 for boomerang

I have another problem with it as well which is It goes out at the proper fast speed, but then returns slow like an Ice boomerang. How can I make it return faster like the Paladin's hammer does

also, I wanted to make It heal the player, but I didn't like the Red line of the vampire heal When I had that in there so I removed it and tried

Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            player.statLife += 10;
            player.HealEffect(10);
        }

but that only seems to work for Item weapons and not projectiles

here's the code just in case

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

namespace Pack.Items.Weapons
{
    public class PossessedTempliteHammer : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Possessed Templite Hammer";
            item.damage = 120;
            item.melee = true;
            item.width = 32;
            item.height = 32;
            item.useTime = 15;
            item.useAnimation = 15;
            item.useStyle = 1;
            item.noMelee = true;
            item.knockBack = 2;
            item.noUseGraphic = true;
            item.value = 100000;
            item.rare = 8;
            item.useSound = 19;
            item.autoReuse = true;
            item.shoot = mod.ProjectileType("PossessedTempliteHammerP");
            item.shootSpeed = 20;
        }
      
     
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "TempliteIngot", 50);
            recipe.AddIngredient(null, "TempliteGem", 1);
            recipe.AddTile(TileID.MythrilAnvil);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

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

namespace Pack.Projectiles
{
    public class PossessedTempliteHammerP : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Possessed Templite Hammer";
            projectile.width = 32;
            projectile.height = 32;
            projectile.friendly = true;
            projectile.penetrate = 10;
            projectile.aiStyle = 3;
            projectile.melee = true;
            projectile.tileCollide = true;
            projectile.timeLeft = 60000;
            projectile.light = 1f;
        }
    }
}
I'm pretty sure that AI makes it bounce off.
 
I'm having trouble with a boomerang
I want it to be like the Paladin's hammer, but It won't penetrate at all, instead it just bounces of the enemy even when I say
projectile.penetrate = 10;

it has an ai style of 3 for boomerang

I have another problem with it as well which is It goes out at the proper fast speed, but then returns slow like an Ice boomerang. How can I make it return faster like the Paladin's hammer does

also, I wanted to make It heal the player, but I didn't like the Red line of the vampire heal When I had that in there so I removed it and tried

Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            player.statLife += 10;
            player.HealEffect(10);
        }

but that only seems to work for Item weapons and not projectiles

here's the code just in case

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

namespace Pack.Items.Weapons
{
    public class PossessedTempliteHammer : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Possessed Templite Hammer";
            item.damage = 120;
            item.melee = true;
            item.width = 32;
            item.height = 32;
            item.useTime = 15;
            item.useAnimation = 15;
            item.useStyle = 1;
            item.noMelee = true;
            item.knockBack = 2;
            item.noUseGraphic = true;
            item.value = 100000;
            item.rare = 8;
            item.useSound = 19;
            item.autoReuse = true;
            item.shoot = mod.ProjectileType("PossessedTempliteHammerP");
            item.shootSpeed = 20;
        }
      
     
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "TempliteIngot", 50);
            recipe.AddIngredient(null, "TempliteGem", 1);
            recipe.AddTile(TileID.MythrilAnvil);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

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

namespace Pack.Projectiles
{
    public class PossessedTempliteHammerP : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Possessed Templite Hammer";
            projectile.width = 32;
            projectile.height = 32;
            projectile.friendly = true;
            projectile.penetrate = 10;
            projectile.aiStyle = 3;
            projectile.melee = true;
            projectile.tileCollide = true;
            projectile.timeLeft = 60000;
            projectile.light = 1f;
        }
    }
}
If you want the boomerang to heal the player, you'll need to put your healing code in your projectile, not your item. I believe that overriding your projectile's onHitNPC hook, may also prevent it from bouncing, but I'm not entirely sure about that. Either way, projectile behaviour is handled in the projectile's code, not the items.
 
just tried the gog version and... it didnt work i followed the readme correctly but when i run patch exe and it finishes no terraria exe will appear in the tmodloader folder ughhh i just wanna play terraria with mods why wont it work??
 
How can i increase custom stat via equiping an armor piece? I wrote this and well.. stat just ketp growing when i equiped it.
Code:
public override void UpdateEquip(Player player)
        {
            player.GetModPlayer<LegendPlayer>(mod).customStat += 50;
        }
 
Back
Top Bottom