Standalone [1.3] tModLoader - A Modding API

If i wanted to add multiple ingredients to create an item, how would i do that?
If you mean requiring multiple items for a crafting recipe, you would call AddRecipe multiple times. The example mod has some examples of that (I think the example furnitures require multiple ingredients).
 
Whoops, I forgot to turn the charger on for the laptop so it's now trying to restore ram from critical battery level. The ram level is probably about 5gb, so it's taking ages.
[DOUBLEPOST=1439703962,1439703803][/DOUBLEPOST]It still ran for 6 hours last night, and over 3 hours when I was still there, so I'm going to try ILSpy or dotPeek directly.

EDIT: Now decompiling using ILSpy directly!
 
Last edited:
pGTGd12.png


I got some stuff working :D, need to work on the armor though, any chance at a Cape Example?
 
Last edited:
Finished dotPeek, it's very fast but the folder format is different.
Attempted to patch dotPeek decompiled code, works except for Program.cs and Lang.cs, where applydiff.exe crashes. I also selectively decompiled both files in ILSpy, but it still fails. The same files work fine in unix patch (command line linux patch thing).
 
Last edited:
Attempted to patch dotPeek decompiled code, works except for Program.cs and Lang.cs, where applydiff.exe crashes.
Code:
Patching: Terraria\Program.cs.patch
Patching: Terraria\Lang.cs.patch
System.AggregateException: One or more errors occurred. ---> System.Exception: Assertion failed: p_base <= file_pos, file patch-2.5.4/pch.c, line 741

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

   at Terraria.ModLoader.Setup.PatchTask.CallPatch(String patchFile, String srcFile) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 142
   at Terraria.ModLoader.Setup.PatchTask.Patch(String relPath) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 111
   at Terraria.ModLoader.Setup.PatchTask.<>c__DisplayClass15_2.<Run>b__2() in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 69
   at Terraria.ModLoader.Setup.Task.<>c__DisplayClass1_0.<ExecuteParallel>b__1(WorkItem item) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\Task.cs:line 40
   at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__11()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass0.<ExecuteSelfReplicating>b__1(Object )
   --- End of inner exception stack trace ---
   at Terraria.ModLoader.Setup.Task.ExecuteParallel(List`1 items, Boolean resetProgress, Int32 maxDegree) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\Task.cs:line 52
   at Terraria.ModLoader.Setup.PatchTask.Run() in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 81
   at Terraria.ModLoader.Setup.MainForm.RunTaskThread(Task task) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\MainForm.cs:line 107
---> (Inner Exception #0) System.Exception: Assertion failed: p_base <= file_pos, file patch-2.5.4/pch.c, line 741

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

   at Terraria.ModLoader.Setup.PatchTask.CallPatch(String patchFile, String srcFile) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 142
   at Terraria.ModLoader.Setup.PatchTask.Patch(String relPath) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 111
   at Terraria.ModLoader.Setup.PatchTask.<>c__DisplayClass15_2.<Run>b__2() in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 69
   at Terraria.ModLoader.Setup.Task.<>c__DisplayClass1_0.<ExecuteParallel>b__1(WorkItem item) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\Task.cs:line 40
   at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__11()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass0.<ExecuteSelfReplicating>b__1(Object )<---

---> (Inner Exception #1) System.Exception: Assertion failed: hunk, file patch-2.5.4/patch.c, line 343

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

   at Terraria.ModLoader.Setup.PatchTask.CallPatch(String patchFile, String srcFile) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 142
   at Terraria.ModLoader.Setup.PatchTask.Patch(String relPath) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 111
   at Terraria.ModLoader.Setup.PatchTask.<>c__DisplayClass15_2.<Run>b__2() in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\PatchTask.cs:line 69
   at Terraria.ModLoader.Setup.Task.<>c__DisplayClass1_0.<ExecuteParallel>b__1(WorkItem item) in C:\Users\comp500\Downloads\tModLoader-master\tModLoader-master\setup\Setup\Task.cs:line 40
   at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__11()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass0.<ExecuteSelfReplicating>b__1(Object )<---

@bluemagic123 Do you know why this happens? I might update my patches.


EDIT: Nevermind. Line endings problem.
 
Last edited:
Oh hey that looks pretty cool! what kind of block are you standing on?
A mix of Demonite ore and some granite

im planning on making my armor available in corrupted worlds only, no crimson

Plus, i have to make it hard to get, it has crazy stats due to the scaling being the same as the game that it originates from.


Whoever can guess gets a cookie :3
 
Hi so i have a crafting item that has iron ore in but you also get lead ore on other worlds is it possible to make two recipes or does it do it on its own
thanks in advance :)
 
Hi so i have a crafting item that has iron ore in but you also get lead ore on other worlds is it possible to make two recipes or does it do it on its own
thanks in advance :)
Just copy the item you want, it will be like the mech worm

Then change the ingredients of one of them to Copper bars or whatever :)


i hope that works.. i really dont know what im saying
 
3DW2d3w.png

When I place my custom tile, it looks like this.
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
using Terraria.DataStructures;
using Terraria.Enums;

namespace PikaMod.Tiles {
public class HallowedAltar : ModTile
{
    public override void SetDefaults()
    {
        Main.tileSolidTop[Type] = true;
        Main.tileFrameImportant[Type] = true;
        Main.tileNoAttach[Type] = true;
        Main.tileTable[Type] = true;
        Main.tileLavaDeath[Type] = true;
        TileObjectData.newTile.Width = 3;
        TileObjectData.newTile.Height = 2;
        TileObjectData.newTile.Origin = new Point16(1, 0);
        TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
        TileObjectData.newTile.CoordinateWidth = 52;
        TileObjectData.newTile.CoordinatePadding = 2;  
        TileObjectData.newTile.UsesCustomCanPlace = true;      
        TileObjectData.addTile(Type);
        mapColor = new Color(200, 200, 200);
        mapName = "Hallowed Altar";
    }

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

    public override bool CreateDust(int i, int j, ref int type)
    {
        Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 6, 0f, 0f, 0, default(Color), 1.6f);
        return false;
    }

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

I probably made some dumb mistake somewhere.
 
Wow, there are a billion failures. Probably because the code is formatted differently.
And there are some missing files, like WindowsLaunch. Wait a minute. There is a format code button... I will try and see if it works!
[DOUBLEPOST=1439731244,1439731100][/DOUBLEPOST]Ah. Slight formatting problem.
Code:
Formatting: Main.cs
System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Value must be between 1 and 45398
Parameter name: line
Actual value was 2147483647.
   at ICSharpCode.NRefactory.Editor.ReadOnlyDocument.GetOffset(Int32 line, Int32 column)
   at ICSharpCode.NRefactory.Editor.ReadOnlyDocument.GetOffset(TextLocation location)

45654 LOC. The file is too big. Terraria has way too many god objects.
Now is that Terraria's problem, dotPeek's problem, C#'s problem or the code formatter's problem?

I will try ILSpying Main.cs. Nope. 54638 LOC.
 
Last edited:
Any hopes on Windows 10 compatibility? My notebook has Win 10 Home 64 bit and all my modding/coding stuff is on it.
jsIhkkY.png
 
pGTGd12.png


I got some stuff working :D, need to work on the armor though, any chance at a Cape Example?
To make a cape, you'd basically just follow the same pattern as the other example accessories, except with a different EquipType.

Hi so i have a crafting item that has iron ore in but you also get lead ore on other worlds is it possible to make two recipes or does it do it on its own
thanks in advance :)
Just set recipe.anyIronBar to true.

How do you add crafting stations in coding the recipe? Sorry if I'm disturbing anyone but this:
Code:
  public override void AddRecipes()
  {
  ModRecipe recipe = new ModRecipe(mod);
  recipe.AddIngredient( "Sapphire", 14);
  recipe.AddTile(null, "ChlorophyteAnvil");
  recipe.SetResult(this);
  recipe.AddRecipe();
  }
doesn't work. Well, there're no syntax errors whatsoever, but there ain't nothing showing up in-game either.

Also, how does one add another ingredient. Those 14 Sapphires are quite lonely.
I'm not entirely sure why that isn't working. My guesses are that either the item isn't loading properly, there's a typo somewhere, or there's an error in a recipe that's getting added earlier.
To add another ingredient, just call AddIngredient a second time, with your second ingredient.
 
How do you add crafting stations in coding the recipe? Sorry if I'm disturbing anyone but this:
Code:
  public override void AddRecipes()
  {
  ModRecipe recipe = new ModRecipe(mod);
  recipe.AddIngredient( "Sapphire", 14);
  recipe.AddTile(null, "ChlorophyteAnvil");
  recipe.SetResult(this);
  recipe.AddRecipe();
  }
doesn't work. Well, there're no syntax errors whatsoever, but there ain't nothing showing up in-game either.

Also, how does one add another ingredient. Those 14 Sapphires are quite lonely.
Well you're adding a custom tile as a required tile. If you're sure the tile is in the game, you have it placed and you're right next to it then it should work.
 
Back
Top Bottom