Standalone [1.3] tModLoader - A Modding API

Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace Minecraft.Items
{
    public class Mags: ModItem
    {
        public override void SetStaticDefaults()
        {
            Tooltip.SetDefault(Mag);
        }

        public override void SetDefaults()
        {
            item.damage = 50;
            item.ranged = true;
            item.width = 8;
            item.height = 8;
            item.maxStack = 999;
            item.consumable = true;             //You need to set the item consumable so that the ammo would automatically consumed
            item.knockBack = 1.5f;
            item.value = 10;
            item.rare = 2;
            item.shoot = mod.ProjectileType(SubMacgineGun);   //The projectile shoot when your weapon using this ammo
            item.shootSpeed = 16f;                  //The speed of the projectile
            item.ammo = AmmoID.Bullet;              //The ammo class this ammo belongs to.
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.MusketBall, 50);
            recipe.AddIngredient(ItemID.WoodenArrow, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this, 50);
            recipe.AddRecipe();
        }
    }
}
 
i need help making a custom drop for the vanilla npc's, but i need to set the drop to ALL the npc's of the game, like: Enemies drops Monster Soul, Animals drops Animal Soul etc...
 
I got this error message when I open try to "terraria" (with a jungle tree) it says:


System.DIINotFoundException: Unable to load DLL 'CSteamworks': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Steamworks.NativeMethods.SteamAPI_RestartAppIfNecessary(Appld_tunOwnAppID)
at Terraria.Socal.steam.coresocialmodule.initialize()
at Terraria.Socal.socialAPI.initialize(Nullable'1 mode)
at Terraria.Socal.Program.LaunchGame(string[] args, Boolean monoArgs)



plz help me
 
I NEED HELP! Every time i try to start a new mod like calamety, thorium and etc I get this error message

Object reference not set to an instance of an object
at EnemyMods.NPCs.gNPC.SetDefaults (Terraria.NPC npc) [0x001b4] in <ded3aa3997c0410e948c53ecd9a6f1b2>:0
at Terraria.ModLoader.NPCLoader.SetDefaults (Terraria.NPC npc, System.Boolean createModNPC) [0x0009d] in <41f1e63266174ef887e2364f66de8ccf>:0
at Terraria.ModLoader.Mod.SetupContent () [0x00227] in <41f1e63266174ef887e2364f66de8ccf>:0
at Terraria.ModLoader.ModLoader.do_Load (System.Object threadContext) [0x0010f] in <41f1e63266174ef887e2364f66de8ccf>:0

Anyone know what the problem is??
PS: I'm on mac if that helps
 
so... i was wondering
i want to make some sort of item that is consumable and you can use every 1-2 minutes or so,kind of like a special ability

ive tried using reuseDelay = 1600; and it works except that it doesnt let you use any weapons/items in the meantime while you are waiting

is there someway to make it so i can use other weapons/items while waiting?
 
Is that music bug fixed yet?

index.php
 
v0.10.1
-Mods can now have an icon! Make sure your file is named 'icon.png' and it has a size of 80x80 pixels. The icon will display in the mods menu and in the mod browser when published.
-Textures or sounds being loaded now show when a mod is being loaded
-FirstChanceException is now logged
-Added object overload for Main.NewText
-Added several new Point16 operators and constructors
-Added several new helper methods for UnifiedRandom
-Added a TagSerializer for Point16
-Added NetSend and NetReceive for Mystery Items (unloaded items)
-Added a new hook to modify a weapon's critical strike chance: GetWeaponCrit
-Made CreateTrackable() in LegacySoundStyle public
-Added click ! (Mod references button) in Mods menu to Enable dependent mods
-Added a download all functionality of both ModPack and Mod Dependencies (this one while in Mod Browser Menu)
-Fixed a crash for the mod browser when the user had duplicate .tmod files in the mods folder
-Added better MP3 support, major memory performance boost!
-Added tooltip draw hooks for ModItem and GlobalItem: PreDrawTooltip(), PostDrawTooltip(), PreDrawTooltipLine() and PostDrawTooltipLine()
-Added ModifySunLightColor and ModifyLightingBrightness hooks to Mod
-Fixed CaughtFishStack not working
-Fixed CommandType.World functionality
-skipselect launch flag for mod authors who wish to skip player and world select
-Translations
-- Russian
-- Polish
-- Portugese

Thanks to @zadum4ivii for Russian translations, @Shockah for Polish translations, and Aleck for Portuguese translations! We still need help with translations for Spanish, German, Italian, French, and Chinese, so if anyone wants to help with that, that would be amazing :dryadhappy:
 
Last edited:
Some instructions for Mod Icons:

You should have an icon.png that is 80x80 in the base directory of your mod. This is all you need for basic Mod Icon functionality. With this, your icon will be displayed in the Mods menu (but not the Mod Browser menu.)

Consider using this template, or a recolor of it to help preserve a common visual style:

iconTemplate.png


As an incentive for those who wish to alleviate the bandwidth, the Mod Browser menu will also display your Mod Icon if your mod can be hosted separately on a Github repository. To do this, visit the mod browser website and then manage mods, then click submit github authorization for the mod. Follow the instructions. For those who want a Mod Icon but their mod isn't open source, you can still make a dummy github repository and reap the benefits of it. Be sure to read the rules. (For example, an inappropriate mod icon means all your mods will be removed from the mod browser.)

We really appreciate those who can help alleviate our bandwidth limitations because it'll open up the doors for more mods to have more content.
 
Last edited:
Great work @blushiemagic, @jopojelly and the rest of the tModLoader team. I bet everyone will be particularly happy about the mp3 fix. Also, the mod icons are a nice touch. :)
Rartrin and jopo did a great job on the mp3 changes :) (or rather sound changes in general)

Also, to add to the changelog: the mod browser is no longer beta. For the new tooltip drawing hooks, check the ExampleDrawTooltips items from ExampleMod which showcases drawing a simple white background box for the tooltip. The major thing of this patch is hefty performance increases regarding memory. I have been able to play with 40 mods in a LARGE world, using only roughly 2.3 GB memory while playing. Remember that you can go up to about 3.5 GB before running into issues, so I recommend to mod your game up to 3.0 GB. Happy modding!

For modders: please update your mods to unload content properly. Unload all your static assets, things like Texture2D, and everything referencing your mod (for example your Mod instance, ModHotkey, SoundEffects, Effects etc.) Also remember to unload references to other Mods, if you have any. If you say have a static boolean or integer, they don't need to be unloaded. Use the Unload() hook. Example:

Code:
public override void Load()
{
    instance = this;
    RandomBuffHotKey = RegisterHotKey("Random Buff", "P");
  
    if (!Main.dedServ)
    {
        exampleEffect = GetEffect("Effects/ExampleEffect");
        Ref<Effect> exampleEffectRef = new Ref<Effect>();
        exampleEffectRef.Value = exampleEffect;
        GameShaders.Armor.BindShader<ArmorShaderData>(ItemType<Items.ExampleDye>(), new ArmorShaderData(exampleEffectRef, "ExampleDyePass"));
    }
}

public override void Unload()
{
    instance = null;
    exampleEffect = null;
    RandomBuffHotKey = null;
}
 
Last edited:
Hey there. I got an Issue. When I start up my Terraria Server I get this.
11:19:36 [Info] System.ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Array+FunctorComparer`1[System.Int32]'.
11:19:36 [Info] at System.Collections.Generic.IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer (System.Object comparer) [0x0000b] in <902ab9e386384bec9c07fa19aa938869>:0
11:19:36 [Info] at System.Collections.Generic.ArraySortHelper`1[T].Sort (T[] keys, System.Int32 index, System.Int32 length, System.Collections.Generic.IComparer`1[T] comparer) [0x00022] in <902ab9e386384bec9c07fa19aa938869>:0
11:19:36 [Info] at System.Array.Sort[T] (T[] array, System.Int32 index, System.Int32 length, System.Collections.Generic.IComparer`1[T] comparer) [0x00048] in <902ab9e386384bec9c07fa19aa938869>:0
11:19:36 [Info] at System.Collections.Generic.List`1[T].Sort (System.Comparison`1[T] comparison) [0x00019] in <902ab9e386384bec9c07fa19aa938869>:0
11:19:36 [Info] at Terraria.UI.ItemSorting+ItemSortingLayers+<>c.<.cctor>b__40_0 (Terraria.UI.ItemSorting+ItemSortingLayer layer, Terraria.Item[] inv, System.Collections.Generic.List`1[T] itemsToSort) [0x00065] in <ffb4c9c5ab7642f8a59e4fc57587ef1c>:0
11:19:36 [Info] at Terraria.UI.ItemSorting.SetupWhiteLists () [0x0021b] in <ffb4c9c5ab7642f8a59e4fc57587ef1c>:0
11:19:36 [Info] at Terraria.ModLoader.ModLoader.do_Load (System.Object threadContext) [0x00199] in <ffb4c9c5ab7642f8a59e4fc57587ef1c>:0
11:19:36 [Info] at Terraria.Main.DedServ () [0x00068] in <ffb4c9c5ab7642f8a59e4fc57587ef1c>:0
11:19:36 [Info] at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x000f1] in <ffb4c9c5ab7642f8a59e4fc57587ef1c>:0
11:19:36 [Info]
11:19:36 [Info] Please send crashlog.txt to [email protected]

Its pretty weird and doesn't seem to be linked to any particular mod. Also Just confirmed this happens without any mods at all. Also it happens on load up. And I do believe its running on a 64 bit server.
 
Last edited:
v0.10.1
-Mods can now have an icon! Make sure your file is named 'icon.png' and it has a size of 80x80 pixels. The icon will display in the mods menu and in the mod browser when published.
-Textures or sounds being loaded now show when a mod is being loaded
-FirstChanceException is now logged
-Added object overload for Main.NewText
-Added several new Point16 operators and constructors
-Added several new helper methods for UnifiedRandom
-Added a TagSerializer for Point16
-Added NetSend and NetReceive for Mystery Items (unloaded items)
-Added a new hook to modify a weapon's critical strike chance: GetWeaponCrit
-Made CreateTrackable() in LegacySoundStyle public
-Added click ! (Mod references button) in Mods menu to Enable dependent mods
-Added a download all functionality of both ModPack and Mod Dependencies (this one while in Mod Browser Menu)
-Fixed a crash for the mod browser when the user had duplicate .tmod files in the mods folder
-Added better MP3 support, major memory performance boost!
-Added tooltip draw hooks for ModItem and GlobalItem: PreDrawTooltip(), PostDrawTooltip(), PreDrawTooltipLine() and PostDrawTooltipLine()
-Added ModifySunLightColor and ModifyLightingBrightness hooks to Mod
-Fixed CaughtFishStack not working
-Fixed CommandType.World functionality
-skipselect launch flag for mod authors who wish to skip player and world select
-Translations
-- Russian
-- Polish
-- Portugese

Thanks to @zadum4ivii for Russian translations and @Shockah for Polish translations! We still need help with translations for Spanish, German, Italian, French, and Chinese, so if anyone wants to help with that, that would be amazing :dryadhappy:
Good job on the update!
Glad I could help with the translations ;)
 
The major thing of this patch is hefty performance increases regarding memory. I have been able to play with 40 mods in a LARGE world, using only roughly 2.3 GB memory while playing. Remember that you can go up to about 3.5 GB before running into issues, so I recommend to mod your game up to 3.0 GB. Happy modding!
finally my modlist of epic adventures will be..... crap I forgot, looks like jopojelly will need to update terracustom "if" I want make my personal large (huge modded) worlds before doing this (adding more than 4 big mods crash terracustom when generating the worlds).
 
Back
Top Bottom