Standalone [1.3] tModLoader - A Modding API

You'll need to know how to program and know the internal structure of Terraria a bit. Let me give you a hint: you'll want to look at Main.recipe.

I can't seem to figure it out ATM... It sure has something to do with Item.NewItem...

It seems like it.. When the item is generated it's assuming it's a gun or something, since it's giving it ranged prefixes.
I'm gonna go around the source and give it another look.
Thanks Eldrazi.
 
No, i'm know what i need to use, but don't know how to. Please, give me example and i'll exit forum XD
Well, an example would be difficult right now...
I'd advice you to decompile Terraria (by using IlSpy and drag+dropping Terraria.exe in the application). Then you may want to take a look inside Recipe.CS and see how the vanilla recipes are added. If you know your way around programming, you'll know what to do after that :p
 
Well, an example would be difficult right now...
I'd advice you to decompile Terraria (by using IlSpy and drag+dropping Terraria.exe in the application). Then you may want to take a look inside Recipe.CS and see how the vanilla recipes are added. If you know your way around programming, you'll know what to do after that :p
i've already had decompile code of Terraria and i've looked on this code for 2 hours. There is private method which i cannot use...
 
Last edited:
for one mod it was written that the author didn't allow to read it but for others it look like this
"Unpacking PlasmaMod
Found files Resources, Windows, Other in PlasmaMod"

and that's all, a folder with the mod's name in the Output is just empty. maybe it's because the mod was made for tmodloader 0.6? but mods for 0.7 are also cannot be unpacked.
If it couldn't find an Info file, then yeah, it's from v0.6.

Could you please make a more Mac-friendly version of this? It's kinda annoying to have to do all that stuff and anyway when it asks me to drag my Terraria executable file, I can't do it. My Terraria file is a .app file. This would be greatly appreciated. Thanks
What we have right now is actually the more Mac-friendly than in the previous version. I'd recommend actually trying to read the instructions.

i've already had decompile code of Terraria and i've looked on this code for 2 hours. There is private method which i cannot use...
You shouldn't have to use any private methods. If you want to remove a recipe, then you can just check the public fields of Recipe, and once you find what you're looking for you can shift all the recipes in Main.recipe to one index lower to replace the recipe you want to remove.
 
Hey @bluemagic123, is there any way to make an item not get prefixes? I'm making an Endless Musket Pouch like item, but for other type of bullets. The thing is that every time I craft it, it gets a ranged prefix.
I've tried looking around the source but I can't come up with a solution.. Help? :D
 
Hey @bluemagic123, is there any way to make an item not get prefixes? I'm making an Endless Musket Pouch like item, but for other type of bullets. The thing is that every time I craft it, it gets a ranged prefix.
I've tried looking around the source but I can't come up with a solution.. Help? :D
I think I'll actually have to tweak some stuff in the code so that that stops happening.
 
I think I'll actually have to tweak some stuff in the code so that that stops happening.
I see. I was messing with my code and it seems to be somewhat related to item.ranged = true;. When I set the value to false I don't get anymore prefixes, but the item doesn't register "ranged damage" anymore.
Anyway, thanks for the quick reply. :D
Cheers!
 
Well guys, I posted about a large world not loading and now the game simply crashes when attempting to load the world. I have rechecked in vanilla and it loads fine and I'm able to play it.

Attached is the error window that pops up. I wonder if any of you guys might be able to shed some light on the matter.
 

Attachments

  • Error.jpg
    Error.jpg
    339.5 KB · Views: 195
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EnergyMod.NPCs {
public class EnemyDrops : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
if(npc.type == 2 && Main.rand.Next(10) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("SoaringEnergy"));
}
}
}
}
Here is what I had. I am using this to add drops to existing npc.
You sure?
c:\Users\Andrew S. d'Arms\Documents\My Games\Terraria\ModLoader\Mod Sources\Pumpking\NPC.cs(26,75) : error CS1061: 'Pumpking.NPC' does not contain a definition for 'height' and no extension method 'height' accepting a first argument of type 'Pumpking.NPC' could be found (are you missing a using directive or an assembly reference?)
 
its called 'show package contents' also, does anyone know of any tutorials or guides on how to make a summon weapon, or should i just look in example mod and wing it? :p
You can try looking back the General Mod Discusion section for the old tAPI summoning guide. Some of the concepts may not work directly, but it should help with creating it in tModLoader, since tAPI can be translated to tModLoader, though some of the code may not work at all with tModLoader.
 
I want to make my item so i can use it with both types of iron bars(lead and iron) and with both types of mythril anvil. How should i do that?
 
Can somebody help me? My creature won't spawn, except in the jungle and underground.

Here is the code:
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LihzarhdExpansion.NPCs
{
    public class Chameleon : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Chameleon";
            npc.displayName = "Chameleon";
            npc.width = 18;
            npc.height = 40;
            npc.damage = 14;
            npc.defense = 6;
            npc.lifeMax = 9999;
            npc.soundHit = 1;
            npc.soundKilled = 2;
            npc.value = 60f;
            npc.knockBackResist = 0.5f;
            npc.aiStyle = 3;
            Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Buggy];
            aiType = NPCID.Buggy;
            animationType = NPCID.Buggy;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 1.5f : 1.5f;
        }

        public override void HitEffect(int hitDirection, double damage)
        {
            for (int i = 0; i < 10; i++)
            {
                int dustType = Main.rand.Next(139, 143);
                int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
                Dust dust = Main.dust[dustIndex];
                dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
                dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
                dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
            }
        }
    }
}

My main issue is, he just won't spawn in the forest biome, only underground and in the jungle...
By the way, I don't want him to spawn in the rock layer, how would I remove that?
 
You sure?
c:\Users\Andrew S. d'Arms\Documents\My Games\Terraria\ModLoader\Mod Sources\Pumpking\NPC.cs(26,75) : error CS1061: 'Pumpking.NPC' does not contain a definition for 'height' and no extension method 'height' accepting a first argument of type 'Pumpking.NPC' could be found (are you missing a using directive or an assembly reference?)
That is odd. This is working for me.
 
---------------------------
Terraria: Error
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.

at Terraria.ModLoader.UI.UIModBrowser.OnActivate()

at Terraria.UI.UIElement.Activate()

at Terraria.UI.UserInterface.SetState(UIState state)

at Terraria.ModLoader.Interface.ModLoaderMenus(Main main, Int32 selectedMenu, String[] buttonNames, Single[] buttonScales, Int32[] buttonVerticalSpacing, Int32& offY, Int32& spacing, Int32& numButtons)

at Terraria.Main.DrawMenu(GameTime gameTime)

at Terraria.Main.do_Draw(GameTime gameTime)

at Terraria.Main.Draw(GameTime gameTime)

at Microsoft.Xna.Framework.Game.DrawFrame()

at Microsoft.Xna.Framework.Game.Tick()

at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)

at Microsoft.Xna.Framework.GameHost.OnIdle()

at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()

at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)

at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at Microsoft.Xna.Framework.WindowsGameHost.Run()

at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)

at Terraria.Program.LaunchGame(String[] args)
---------------------------
OK
---------------------------
[DOUBLEPOST=1452907168,1452906840][/DOUBLEPOST]---------------------------
Terraria: Error
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.

at Terraria.ModLoader.UI.UIModBrowser.OnActivate()

at Terraria.UI.UIElement.Activate()

at Terraria.UI.UserInterface.SetState(UIState state)

at Terraria.ModLoader.Interface.ModLoaderMenus(Main main, Int32 selectedMenu, String[] buttonNames, Single[] buttonScales, Int32[] buttonVerticalSpacing, Int32& offY, Int32& spacing, Int32& numButtons)

at Terraria.Main.DrawMenu(GameTime gameTime)

at Terraria.Main.do_Draw(GameTime gameTime)

at Terraria.Main.Draw(GameTime gameTime)

at Microsoft.Xna.Framework.Game.DrawFrame()

at Microsoft.Xna.Framework.Game.Tick()

at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)

at Microsoft.Xna.Framework.GameHost.OnIdle()

at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()

at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)

at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at Microsoft.Xna.Framework.WindowsGameHost.Run()

at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)

at Terraria.Program.LaunchGame(String[] args)
---------------------------
OK
---------------------------
Whenever i go to mod browser.
:/
 
Back
Top Bottom