Standalone [1.3] tModLoader - A Modding API

It just sets jumpHeight and jumpSpeed to a hardcoded value in the UpdateJumpHeight method. Considering those are both private and don't have properties, I don't think there's any way of modifying them.
Dont worry, i have a better idea to replace it.
I'm home now an I figured something out:
jumpHeight and jumpSpeed are both very much accessible, just not from a class instance, but by directly accessing it from the Player class (since they're static variables). Meaning the following works fine for me:
Code:
Player.jumpHeight += 5;
Player.jumpSpeed += 2.5F;
 
Those were illustrative, they weren't meant to be copied directly (otherwise you could extend your max life to infinity).
Yeah, but people asking here are more than likely to copy them directly, so might as well link to a working example. Not having the save portion would just mean they'll come back complaining later when the effects aren't permanent.
 
I'm home now an I figured something out:
jumpHeight and jumpSpeed are both very much accessible, just not from a class instance, but by directly accessing it from the Player class (since they're static variables). Meaning the following works fine for me:
Code:
Player.jumpHeight += 5;
Player.jumpSpeed += 2.5F;

I thought private fields couldn't be accessed like that. Either that or I somehow missed a property.
 
There are two field used for max health modifications, namely statLifeMax and statLifeMax2. Be very sure to use the right one.
  • statLifeMax is used for permanent health bonuses and is never reset during gameplay, so any modifications are permanent. statLifeMax can (I believe) exceed 500, but will be reset to 500 whenever the player is loaded.
  • statLifeMax2 is reset every frame, then set to statLifeMax, so can be used for temporary or conditional modifications (like the Life Force potion). statLifeMax2 can (I believe) be as high as you like, but eventually you should get UI problems.
How the Life Crystal/Life Fruit works is hard coded, so you can't edit that, but you can make a similar item, which on use modifies statLifeMax.

Example (pseudo-code):
Code:
public override bool UseItem(Item item, Player player)
{
player.statLifeMax += 20;
return true;
}

You can use an if statement to set limits, for instance statLifeMax < 500.

If you want to increase max HP, you'll have to use statLifeMax2.

Example (pseudo-code):
Code:
public override void UpdateEquip(Item item, Player player)
{
// Don't do this, as it will conflict with Life Force potions or other max life modifications.
player.statLifeMax2 = player.statLifeMax + 20;
// Do this instead:
player.statLifeMax2 = player.statLifeMax2 + 20;
// Which is the same as:
player.statLifeMax2 += 20;
}

The error says it all, there is no NPC called Slime. You have to specifiy GreenSlime, BlueSlime, YellowSlime, etc.

Add && Main.hardMode to the condition.
I just want to point out that for the purposes of tModLoader, statLifeMax should never be modified, and you could create a field in ModPlayer that updates statLifeMax2 every tick.

I cant, because jumpHeight is a private static int, not a public one.
As of the most recent version that is now public.
 
Sorry if this has been asked before, if it has I couldn't find the answer.

What, exactly, does
Code:
item.width
item.height
do?

Copper Ore, as an item, has these values set to 12, while the PNG is (i think) 16 by 16 pixels?
 
I thought private fields couldn't be accessed like that. Either that or I somehow missed a property.
Yeah, I had that thought too!
But I tested it and the program has proven the opposite. You learn something new everyday was the saying, right? ;)

EDIT:
And what we learnt today was... That this value was made public in the latest tModLoader release XD
 
is anyone else getting the Automatically disabling mod even though it was working before you reloaded them? All my mods were working and then i reload for updates then 7 mods get disabled
 
I'm home now an I figured something out:
jumpHeight and jumpSpeed are both very much accessible, just not from a class instance, but by directly accessing it from the Player class (since they're static variables). Meaning the following works fine for me:
Code:
Player.jumpHeight += 5;
Player.jumpSpeed += 2.5F;
I tried with that but i get this:
'Terraria.Player.jumpHeight' cannot be accessed with an instance reference; qualify it with a type name instead

Sorry if this has been asked before, if it has I couldn't find the answer.

What, exactly, does
Code:
item.width
item.height
do?

Copper Ore, as an item, has these values set to 12, while the PNG is (i think) 16 by 16 pixels?
The item.width an height only makes the hitbox of the item, npc, projectile....
 
hey, anyone here know what i should do if tmodreader keeps crashing everytime i use it? and if it doesnt crash, it only makes a folder with the mods name
 
Does anyone here knows what mod is there that has a sarcophagus? cause its an annoying monster, I only dealt 1 damage on it and it instant kills me just by touching the enemy and it only appears at night which will make a hard time for me to kill a boss.

If only there's a way for me to identify what mod it is :)
 
Does anyone here knows what mod is there that has a sarcophagus? cause its an annoying monster, I only dealt 1 damage on it and it instant kills me just by touching the enemy and it only appears at night which will make a hard time for me to kill a boss.

If only there's a way for me to identify what mod it is :)
The ExampleMod has a Sarcophagus that only spawns in the Desert at any time of day after you beat the Abomination... that doesn't sound like what's happening to you though. What mods do you have right now?
 
The ExampleMod has a Sarcophagus that only spawns in the Desert at any time of day after you beat the Abomination... that doesn't sound like what's happening to you though. What mods do you have right now?

Extensions+ v0.1.1
Miscellania v0.3
Infinity - Endless Items
Adventurer v2.1
Cheeze's Content Pack v0.6.1
Prefixes For Enemies v1.0.6
More Accessories+ v1.3
The Luggage v0.1.0.3
Tremor Mod Remastered v1.2.1
ZoaklenMod v0.6.2.9
Quality of Life v1.2.1
Rockos ARPG v0.91.1
Summoners Association v0.2.0.4
EnergyMod v0.2.5.2
Fargo's Mod v0.0.1
Randomod v1.2.2
Shorter Respawn Time v0.2.1
Hotbar Swapper v1.1.1.0
Cosmetic Variety v1.5.2.2
Thorium Mod v1.2.5.10
Pies Vanity Set v0.1.8.2
AdvancedTerraria v1.7
MaxStackPlus v2.2
Terranova v0.6.1
Vannila Tweaks v1.2.1
AeONS of Terraria v1.0.1.22
 
There are two field used for max health modifications, namely statLifeMax and statLifeMax2. Be very sure to use the right one.
  • statLifeMax is used for permanent health bonuses and is never reset during gameplay, so any modifications are permanent. statLifeMax can (I believe) exceed 500, but will be reset to 500 whenever the player is loaded.
  • statLifeMax2 is reset every frame, then set to statLifeMax, so can be used for temporary or conditional modifications (like the Life Force potion). statLifeMax2 can (I believe) be as high as you like, but eventually you should get UI problems.
How the Life Crystal/Life Fruit works is hard coded, so you can't edit that, but you can make a similar item, which on use modifies statLifeMax.
OK, I grab it. So I may draw a conclusion that I can't make something like life crystal?
Originally I'm kinda in the mood for increasing the max life of a player to 800 or something - by allowing players to eat more than just 15 life crystals, or like I'm tryna make, make something like life crystal that spawns over the world and can be gained through some means and can be eaten and increases max life over 500 but also have a limits like 800... basically behaving precisely the same as life crystal. Only it's third type of item that can enhance max life except life crystal and life fruit.
Since statLifeMax has a limit of 500, I think this is, for now, impossible to realize. But using statLifeMax2 is OK with equipment, which I think would be an alternative for my situation.
I still got some ideas in my mind. I'll just go screwing it up myself!
Anyways, appreciate for the detailed reply.
 
OK, I grab it. So I may draw a conclusion that I can't make something like life crystal?
Originally I'm kinda in the mood for increasing the max life of a player to 800 or something - by allowing players to eat more than just 15 life crystals, or like I'm tryna make, make something like life crystal that spawns over the world and can be gained through some means and can be eaten and increases max life over 500 but also have a limits like 800... basically behaving precisely the same as life crystal. Only it's third type of item that can enhance max life except life crystal and life fruit.
Since statLifeMax has a limit of 500, I think this is, for now, impossible to realize. But using statLifeMax2 is OK with equipment, which I think would be an alternative for my situation.
I still got some ideas in my mind. I'll just go screwing it up myself!
Anyways, appreciate for the detailed reply.
You can still update statLifeMax2 based on a field that your third life crystal type increments.
 
Well, but, isn't it something like buff?
I mean that I eat it, the effect won't last permanently, right?
It's only temporary if you make it temporary. All you need to do is update statLifeMax2 in every tick (like in one of the Update hooks in ModPlayer).
You'll also need SaveCustomData and LoadCustomData. This is the easiest way to prevent clashes with other mods, too.
 
Back
Top Bottom