Repository navigation
API Players
API reference · generated by
tools/docs/ApiReference, do not edit by hand
The player, what is attached to the player, and the screen layers drawn on it.
static class Terraria.ModLoader.BuffLoader
This serves as the central class from which buff-related functions are supported and carried out.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int BuffCount |
static property | same | How many exist, with the game's and every mod's. |
ModBuff GetBuff(int type) |
static method | same | Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null. |
tModLoader's BuffLoader also has 8 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
class Terraria.ModLoader.EquipTexture
This serves as a place for you to program behaviors of equipment textures. This is useful for equipment slots that do not have any item associated with them (for example, the Werewolf buff). Note that this class is purely for visual effects.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string Texture |
property | same | The name and folders of the texture file used by this equipment texture. |
string Name |
property | same | The internal name of this equipment texture. |
EquipType Type |
property | same | The type of equipment that this equipment texture is used as. |
int Slot |
property | same | The slot (internal ID) of this equipment texture. |
ModItem Item |
property | same | The item that is associated with this equipment texture. Null if no item is associated with this. Note that this item is a template item and will not be the same instance as the item in an inventory. |
void FrameEffects(Player player, EquipType type) |
hook | same | Allows you to create special effects (such as dust) when this equipment texture is displayed on the player under the given equipment type. By default this will call the associated ModItem's UpdateVanity if there is an associated ModItem. |
bool IsVanitySet(int head, int body, int legs) |
hook | same | Returns whether or not the head armor, body armor, and leg armor textures make up a set. This hook is used for the PreUpdateVanitySet, UpdateVanitySet, and ArmorSetShadows hooks. By default this will return the same thing as the associated ModItem's IsVanitySet, or false if no ModItem is associated. |
void PreUpdateVanitySet(Player player) |
hook | same | Allows you to create special effects (such as the necro armor's hurt noise) when the player wears this equipment texture's vanity set. This hook is called regardless of whether the player is frozen in any way. By default this will call the associated ModItem's PreUpdateVanitySet if there is an associated ModItem. |
void UpdateVanitySet(Player player) |
hook | same | Allows you to create special effects (such as dust) when the player wears this equipment texture's vanity set. This hook will only be called if the player is not frozen in any way. By default this will call the associated ModItem's UpdateVanitySet if there is an associated ModItem. |
void ArmorSetShadows(Player player) |
hook | same | Allows you to determine special visual effects this vanity set has on the player without having to code them yourself. By default this will call the associated ModItem's ArmorSetShadows if there is an associated ModItem. |
void SetMatch(bool male, ref int equipSlot, ref bool robes) |
hook | same | Allows you to modify the equipment that the player appears to be wearing. This is most commonly used to add legs to robes and for swapping to female variant textures if male is false for head and leg armor. This hook will only be called for head, body, and leg textures. Note that equipSlot is not the same as the item type of the armor the player will appear to be wearing. Worn equipment has a separate set of IDs. You can find the vanilla equipment IDs by looking at the headSlot, bodySlot, and legSlot fields for items, and modded equipment IDs by looking at EquipLoader. If this hook is called on body armor, equipSlot allows you to modify the leg armor the player appears to be wearing. If you modify it, make sure to set robes to true. If this hook is called on leg armor, equipSlot allows you to modify the leg armor the player appears to be wearing, and the robes parameter is useless. The same is true for head armor. By default, if there is an associated ModItem, this will call that ModItem's SetMatch. |
void DrawArmorColor(Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor) |
hook | same | Allows you to modify the colors in which this armor texture and surrounding accessories are drawn, in addition to which glow mask and in what color is drawn. By default this will call the associated ModItem's DrawArmorColor if there is an associated ModItem. Note that the glowMask parameter will only work with existing glowmask textures until glowmask support is added. Note that the glowMask parameter will only work with existing glowmask textures (GlowMaskID until custom glowmask support is added. You can use ModifyDraw and manually add a DrawData for the glowmask instead. |
void ArmorArmGlowMask(Player drawPlayer, float shadow, ref int glowMask, ref Color color) |
hook | same | Allows you to modify which glow mask and in what color is drawn on the player's arms. Note that this is only called for body equipment textures. By default this will call the associated ModItem's ArmorArmGlowMask if there is an associated ModItem. |
void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) |
hook | same | Allows you to modify vertical wing speeds. |
void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration) |
hook | same | Allows you to modify horizontal wing speeds. |
bool WingUpdate(Player player, bool inUse) |
hook | same | Allows for wing textures to do various things while in use. "inUse" is whether or not the jump button is currently pressed. Called when this wing texture visually appears on the player. Use to animate wings, create dusts, invoke sounds, and create lights. By default this will call the associated ModItem's WingUpdate if there is an associated ModItem. |
bool ModifyDraw(ref PlayerDrawSet drawInfo, ref DrawData drawData, string methodName) |
hook | same | Allows customization of the DrawData responsible for drawing this EquipTexture. Additional DrawData can be added to drawInfo for more advanced drawing if needed. methodName is the name of the method being hooked into. Some EquipType are drawn multiple times depending on layering, this provides that context if relevant. Note that the default behavior of this hook is to call and return the return value of the ModifyEquipTextureDraw hook on the associated ModItem, if it exists. Return false to stop the game from adding the drawData to the player drawing. Returns true if not associated with a ModItem. |
bool WingGlidingSpeeds(Player player, ref float gravityMultiplier, ref float maxSpeedMultiplier) |
hook | not here | Allows you to modify wing gliding speeds. Return false to prevent vanilla gliding behavior. |
enum Terraria.ModLoader.Gender
The gender a mod hair picks when the player randomizes.
Values: Unspecified, Male, Female
abstract class Terraria.ModLoader.GlobalBuff : ModType
This class allows you to modify the behavior of any buff in the game.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void Update(int type, Player player, ref int buffIndex) |
hook | same | Allows you to make the buff with the given ID give certain effects to a player. If you remove the buff from the player, make sure the decrement the buffIndex parameter by 1. |
void Update(int type, NPC npc, ref int buffIndex) |
hook | same | Allows you to make the buff with the given ID give certain effects to an NPC. If you remove the buff from the NPC, make sure to decrement the buffIndex parameter by 1. |
bool ReApply(int type, Player player, int time, int buffIndex) |
hook | same | Allows to you make special things happen when adding the given type of buff to a player when the player already has that buff. Return true to block the vanilla re-apply code from being called; returns false by default. The vanilla re-apply code sets the buff time to the "time" argument if that argument is larger than the current buff time. If AddBuffTimeAdditivelyToCap is set, it will instead accumulate up to the cap contained in that set. That set is used for ManaSickness and "High Spirits" (Kite) |
bool ReApply(int type, NPC npc, int time, int buffIndex) |
hook | same | Allows to you make special things happen when adding the given buff type to an NPC when the NPC already has that buff. Return true to block the vanilla re-apply code from being called; returns false by default. The vanilla re-apply code sets the buff time to the "time" argument if that argument is larger than the current buff time. |
void ModifyBuffText(int type, ref string buffName, ref string tip, ref int rare) |
hook | same | Allows you to modify the name and tooltip that displays when the mouse hovers over the buff icon, as well as the color the buff's name is drawn in. |
void CustomBuffTipSize(string buffTip, List<Vector2> sizes) |
hook | same | If you are using the DrawCustomBuffTip hook, then you must use this hook as well. Calculate the location (relative to the origin) of the bottom-right corner of everything you will draw, and add that location to the sizes parameter. |
void DrawCustomBuffTip(string buffTip, SpriteBatch spriteBatch, int originX, int originY) |
hook | same | Allows you to draw whatever you want when a buff tooltip is drawn. The originX and originY parameters are the top-left corner of everything that's drawn; you should add these to the position argument passed to SpriteBatch.Draw. |
bool PreDraw(SpriteBatch spriteBatch, int type, int buffIndex, ref BuffDrawParams drawParams) |
hook | same | Allows you to draw things before the default draw code is ran. Return false to prevent drawing the buff. Returns true by default. |
void PostDraw(SpriteBatch spriteBatch, int type, int buffIndex, BuffDrawParams drawParams) |
hook | same | Allows you to draw things after the buff has been drawn. skipped is true if you or another mod has skipped drawing the buff (possibly hiding it or in favor of new visuals). |
bool RightClick(int type, int buffIndex) |
hook | same | Allows you to make things happen when the buff icon is right-clicked. Return false to prevent the buff from being cancelled. |
static class Terraria.ModLoader.HairLoader
Registers mod hairs.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Count |
static property | same | How many exist, with the game's and every mod's. |
ModHair GetHair(int type) |
static method | same | The ModHair of a number, or null. |
void UpdateUnlocks(HairstyleUnlocksHelper unlocksHelper, bool inCharacterCreation) |
static method | same | Fills the styles the stylist offers. |
abstract class Terraria.ModLoader.ModAccessorySlot : ModType
A ModAccessorySlot instance represents a net new accessory slot instance. You can store fields in the ModAccessorySlot class.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | |
Player Player |
static property | same | The player that this ModAccessorySlot is currently accessing, equivalent to CurrentPlayer. ModAccessorySlot are singletons, the behavior of properties like FunctionalItem depends on the current player. Main.CurrentPlayer documentation: |
ModAccessorySlotPlayer ModSlotPlayer |
property | same | |
Vector2 CustomLocation |
hook | same | |
string DyeBackgroundTexture |
hook | same | |
string VanityBackgroundTexture |
hook | same | |
string FunctionalBackgroundTexture |
hook | same | |
string DyeTexture |
hook | same | |
string VanityTexture |
hook | same | |
string FunctionalTexture |
hook | same | |
bool DrawFunctionalSlot |
hook | same | |
bool DrawVanitySlot |
hook | same | |
bool DrawDyeSlot |
hook | same | |
bool HasEquipmentLoadoutSupport |
hook | same | Gets or sets a value indicating whether this slot supports equipment loadouts. If false, the slot's item is shared between all loadouts. Defaults to true. Changing this value requires a reload. This value is not allowed to be different between multiplayer clients or issues will occur. Changing the value from true to false will cause the extra items to be spawned on the player when they enter the world. Changing the value from false to true will result in the currently selected loadout holding the items. Slots that don't support loadouts will appear with the default green background texture, as if they were an accessory in loadout #1 or from before loadout support was added to the game. |
Item FunctionalItem |
property | same | The functional item of this equipment slot. This property always accesses the equipment of the current player, see Player for more info. |
Item VanityItem |
property | same | The vanity item of this equipment slot. This property always accesses the equipment of the current player, see Player for more info. |
Item DyeItem |
property | same | The dye item of this equipment slot. This property always accesses the equipment of the current player, see Player for more info. |
bool HideVisuals |
property | same | Indicates if the corresponding FunctionalItem is set to be hidden or not. This property always accesses the equipment of the current player, see Player for more info. |
bool IsEmpty |
property | same | |
bool PreDraw(AccessorySlotType context, Item item, Vector2 position, bool isHovered) |
hook | same | Allows drawing prior to vanilla ItemSlot.Draw code. Return false to NOT call ItemSlot.Draw |
void PostDraw(AccessorySlotType context, Item item, Vector2 position, bool isHovered) |
hook | same | |
void ApplyEquipEffects() |
hook | same | Override to replace the vanilla effect behavior of the slot with your own. By default calls: Player.VanillaUpdateEquips(FunctionalItem), Player.ApplyEquipFunctional(FunctionalItem, ShowVisuals), Player.ApplyEquipVanity(VanityItem) |
bool CanAcceptItem(Item checkItem, AccessorySlotType context) |
hook | same | Override to set conditions on what can be placed in the slot. Default is to return false only when item property FitsAccessoryVanity says can't go in to a vanity slot. Return false to prevent the item going in slot. Return true for dyes, if you want dyes. Example: only wings can go in slot. Receives data: checkItem :: the item that is attempting to enter the slot |
bool ModifyDefaultSwapSlot(Item item, int accSlotToSwapTo) |
hook | same | After checking for empty slots in ItemSlot.AccessorySwap, this allows for changing what the default target slot (accSlotToSwapTo) will be. DOES NOT affect vanilla behavior of swapping items like for like where existing in a slot Return true to set this slot as the default targeted slot. |
bool IsHidden() |
hook | same | Override to control whether or not drawing will be skipped during the given frame. NOTE: Nothing will be drawn, nor will subsequent drawing hooks be called on this slot for the frame while true |
bool IsEnabled() |
hook | same | Override to set conditions on when the slot is valid for stat/vanity calculations and player usage. Example: the demonHeart is consumed and in Expert mode in Vanilla. |
bool IsVisibleWhenNotEnabled() |
hook | same | Override to change the condition on when the slot is visible, but otherwise non-functional for stat/vanity calculations. Defaults to check 'property' IsEmpty |
void OnMouseHover(AccessorySlotType context) |
hook | same | Allows you to do stuff while the player is hovering over this slot. |
void BackgroundDrawColor(AccessorySlotType context, ref Color color) |
hook | same | Allows customizing the background texture draw color. For HasEquipmentLoadoutSupport slots without a custom texture, the color will already have been adjusted for the current loadout (ItemSlot.GetColorByLoadout), otherwise the color will be inventoryBack, which will oscillate all values between 180 and 240. |
class Terraria.ModLoader.Default.ModAccessorySlotPlayer
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Player Player |
property | only here | The Player instance that this ModPlayer instance is attached to. |
int SlotCount |
property | same | Total modded slots to show, including UnloadedAccessorySlot at the end. On the local instance of a ModAccessorySlotPlayer, this might have extra entries not present on remote clients. |
int LoadedSlotCount |
property | same | Total loaded modded slots. This does not include UnloadedAccessorySlot entries. This value is used for network syncing since this will be consistent between clients. |
Item GetSharedLoadoutItem(int context, int slot, out int sharedFromLoadout) |
method | same | |
void UpdateDyes(bool socialSlots) |
method | same | Mirrors Player.UpdateDyes() for modded slots Runs On Player Select, so is Player instance sensitive!!! |
void DropItems(IEntitySource itemSource) |
method | same |
abstract class Terraria.ModLoader.ModBuff : ModTexturedType
This class serves as a place for you to define a new buff and how that buff behaves.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The buff id of this buff. |
string LocalizationCategory |
hook | same | The folder of this content in the localization files. |
LocalizedText DisplayName |
hook | same | The translations of this buff's display name. |
LocalizedText Description |
hook | same | The translations of this buff's description. |
void Update(Player player, ref int buffIndex) |
hook | same | Allows you to make this buff give certain effects to the given player. If you remove the buff from the player, make sure the decrement the buffIndex parameter by 1. |
void Update(NPC npc, ref int buffIndex) |
hook | same | Allows you to make this buff give certain effects to the given NPC. If you remove the buff from the NPC, make sure to decrement the buffIndex parameter by 1. |
bool ReApply(Player player, int time, int buffIndex) |
hook | same | Allows to you make special things happen when adding this buff to a player when the player already has this buff. Return true to block the vanilla re-apply code from being called; returns false by default. The vanilla re-apply code sets the buff time to the "time" argument if that argument is larger than the current buff time. If AddBuffTimeAdditivelyToCap is set, it will instead accumulate up to the cap contained in that set. |
bool ReApply(NPC npc, int time, int buffIndex) |
hook | same | Allows to you make special things happen when adding this buff to an NPC when the NPC already has this buff. Return true to block the vanilla re-apply code from being called; returns false by default. The vanilla re-apply code sets the buff time to the "time" argument if that argument is larger than the current buff time. |
void ModifyBuffText(ref string buffName, ref string tip, ref int rare) |
hook | same | Allows you to modify the name and tooltip that displays when the mouse hovers over the buff icon, as well as the color the buff's name is drawn in. |
bool PreDraw(SpriteBatch spriteBatch, int buffIndex, ref BuffDrawParams drawParams) |
hook | same | Allows you to draw things before the default draw code is ran. Return false to prevent drawing the buff. Returns true by default. |
void PostDraw(SpriteBatch spriteBatch, int buffIndex, BuffDrawParams drawParams) |
hook | same | Allows you to draw things after the buff has been drawn. skipped is true if you or another mod has skipped drawing the buff (possibly hiding it or in favor of new visuals). |
bool RightClick(int buffIndex) |
hook | same | Allows you to make things happen when the buff icon is right-clicked. Return false to prevent the buff from being cancelled. |
abstract class Terraria.ModLoader.ModHair : ModTexturedType
This class allows you to define custom hair styles for a player, controlling the associated gender and unlock conditions.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The hair's number. |
string AltTexture |
hook | same | The path to the alternative texture used for when the hair is covered by a hat. |
Gender RandomizedCharacterCreationGender |
hook | same | Used to set the character gender based on hairstyle when randomizing a new character. If Unspecified, the gender will be randomly rolled. Note that all hairstyles can be selected with either gender. This is just a default for quick randomization. Phone: Applied after the game's random character button. |
bool AvailableDuringCharacterCreation |
hook | same | Determines whether this hairstyle is available during character creation. This is distinctly different from GetUnlockConditions, which determines whether the hairstyle is available in-game in the Stylist UI. |
void AutoStaticDefaults() |
hook | same | Automatically sets certain static defaults. Override this if you do not want the properties to be set for you. |
IEnumerable<Condition> GetUnlockConditions() |
hook | same | Gets the unlock conditions for this hairstyle. No conditions by default. These conditions are used exclusively for the Stylist UI in-game; see AvailableDuringCharacterCreation for character creation. |
abstract class Terraria.ModLoader.ModMount : ModType
This class serves as a place for you to place all your properties and hooks for each mount. To use it, simply create a new class deriving from this one. Implementations will be registered automatically. Only one instance of ModMount will exist for each mount, so storing player specific data on the ModMount is not good. Modders can use player.mount._mountSpecificData or a ModPlayer class to store player specific data relating to a mount. Use SetMount to assign these fields. Note that texture autoloading is unique for ModMount, see Texture for more information.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ref MountData MountData |
property | differs | The vanilla MountData object that is controlled by this ModMount. tML: MountData MountData
|
int Type |
property | same | The index of this ModMount in the Mount.mounts array. |
string Texture |
hook | same | The file name of this type's texture file in the mod loader's file space. For mounts, this path isn't used directly to autoload a texture, but it is combined with MountTextureType values to autoload textures for each of the different layers that mounts support, if that texture exists. ModMount typically want at least one of either a "Back" or "Front" texture. For example, a mount named "MyMount" would need to include a "MyMount_Back.png" or "MyMount_Front.png" texture. |
string GetExtraTexture(MountTextureType textureType) |
hook | same | The path of one of the mount's textures. |
void JumpHeight(Player mountedPlayer, ref int jumpHeight, float xVelocity) |
hook | same | Allows you to modify the mount's jump height based on its state. |
void JumpSpeed(Player mountedPlayer, ref float jumpSeed, float xVelocity) |
hook | same | Allows you to modify the mount's jump speed based on its state. |
void UpdateEffects(Player player) |
hook | same | Allows you to make things happen when mount is used (creating dust etc.) Can also be used for mount special abilities. |
bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) |
hook | same | Allows for manual updating of mount frame. Return false to stop the default frame behavior. Returns true by default. Possible values for state include: 0. Standing still on the ground or sliding 1. Moving on the ground 2. In the air, not flying. Hovering counts as this as well. 3. In the air, flying 4. Flying in water |
void UseAbility(Player player, Vector2 mousePosition, bool toggleOn) |
hook | same | Allows you to make things happen while the mouse is pressed while the mount is active. Called each tick the mouse is pressed. |
void AimAbility(Player player, Vector2 mousePosition) |
hook | same | Allows you to make things happen when the mount ability is aiming (while charging). |
void SetMount(Player player, ref bool skipDust) |
hook | same | Allows you to make things happen when this mount is spawned in. Useful for player-specific initialization, utilizing player.mount._mountSpecificData or a ModPlayer class since ModMount is shared between all players. Custom dust spawning logic is also possible via the skipDust parameter. |
void Dismount(Player player, ref bool skipDust) |
hook | same | Allows you to make things happen when this mount is de-spawned. Useful for player-specific cleanup, see SetMount. Custom dust spawning logic is also possible via the skipDust parameter. |
bool Draw(List<DrawData> playerDrawData, int drawType, Player drawPlayer, ref Texture2D texture, ref Texture2D glowTexture, ref Vector2 drawPosition, ref Rectangle frame, ref Color drawColor, ref Color glowColor, ref float rotation, ref SpriteEffects spriteEffects, ref Vector2 drawOrigin, ref float drawScale, float shadow) |
hook | same | Allows for complete customization of mount drawing. This method will be called once for each supported mount texture layer that exists. Use drawType to conditionally apply changes. drawType corresponds to the following: 0: backTexture, 1: backTextureExtra, 2: frontTexture. 3: frontTextureExtra Corresponding glow textures, such as backTextureGlow, are paired with their corresponding texture and passed into this method as well. Return false if you are manually adding DrawData to playerDrawData to replace the vanilla draw behavior, otherwise tweak ref variables to customize the drawing and add additional DrawData to playerDrawData. |
abstract class Terraria.ModLoader.ModPlayer : ModType<Player, ModPlayer>
A ModPlayer instance represents an extension of a Player instance. To use it, simply create a new class deriving from this one. Implementations will be registered automatically. You can store fields in the ModPlayer classes, much like how the Player class abuses field usage, to keep track of mod-specific information on the player that a ModPlayer instance represents. It also contains hooks to insert your code into the Player class.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ushort Index |
property | same | Its place in Player.ModPlayers. |
Player Player |
property | same | The Player instance that this ModPlayer instance is attached to. |
Player CreateTemplateEntity() |
override | same | Creates the player the template instance works on. |
ModPlayer NewInstance(Player entity) |
override | same | Creates the instance of one player. |
bool TypeEquals(ModPlayer other) |
method | same | Whether both are the same class. |
void Initialize() |
hook | same | Called whenever the player is loaded (on the player selection screen). This can be used to initialize data structures, etc. |
void ResetEffects() |
hook | same | This is where you reset any fields you add to your ModPlayer subclass to their default states. This is necessary in order to reset your fields if they are conditionally set by a tick update but the condition is no longer satisfied. Called on local, server, and remote clients. |
void ResetInfoAccessories() |
hook | same | This is where you reset any fields related to INFORMATION accessories to their "default" states. This is identical to ResetEffects(); but should ONLY be used to reset info accessories. It will cause unintended side-effects if used with other fields. Called on local, server, and remote clients. |
void RefreshInfoAccessoriesFromTeamPlayers(Player otherPlayer) |
hook | same | This is where you set any fields related to INFORMATION accessories based on the passed in player argument. Called on the local client. Note that this hook is only called if all of the requirements for a "nearby teammate" is met, which is when the other player is on the same team and within a certain distance, determined by the following code: (Main.player[i].Center - base.Center).Length() < 800f |
void EmitEnchantmentVisualsAt(Projectile projectile, Vector2 boxPosition, int boxWidth, int boxHeight) |
hook | same | Draws dust for a weapon enchantment on a projectile or item. |
void NaturalLifeRegen(ref float regen) |
hook | same | Allows you to modify the power of the player's natural life regeneration. This can be done by multiplying the regen parameter by any number. For example, campfires multiply it by 1.1, while walking multiplies it by 0.5. Called on local, server, and remote clients. |
void UpdateAutopause() |
hook | same | Allows you to modify the player's stats while the game is paused due to the autopause setting being on. This is called in single player only, some time before the player's tick update would happen when the game isn't paused. |
void ProcessTriggers(TriggersSet triggersSet) |
hook | same | Use this to check on keybinds you have registered. While SetControls is set even while in text entry mode, this hook is only called during gameplay. Called on the local client only. Read ExampleKeybindPlayer.cs for examples and information on using this hook. |
void ArmorSetBonusActivated() |
hook | same | This is called when the player activates their armor set bonus by double tapping down (or up if ReversedUpDownArmorSetBonuses is true). As an example, the Vortex armor uses this to toggle stealth mode. Use this to implement armor set bonuses that need to be activated by the player. Don't forget to check if your armor set is active. While this technically can be used for other effects, it will likely be frustrating for your players if non-armor set effects are being triggered in tandem with armor set bonus effects. Modders can use holdDownCardinalTimer and doubleTapCardinalTimer directly in other hooks for similar effects if needed. Called on the local client only. |
void ArmorSetBonusHeld(int holdTime) |
hook | same | This is called when the player activates their armor set bonus by holding down (or up if ReversedUpDownArmorSetBonuses is true) for some amount of time. The holdTime parameter indicates how many ticks the key has been held down for. As an example, the Stardust armor prior to 1.4.4 used to use this to set the location of the Stardust Guardian if holdTime was greater than 60. Use this to implement armor set bonuses that need to be activated by the player. Don't forget to check if your armor set is active. While this technically can be used for other effects, it will likely be frustrating for your players if non-armor set effects are being triggered in tandem with armor set bonus effects. Modders can use holdDownCardinalTimer and doubleTapCardinalTimer directly in other hooks for similar effects if needed. Called on the local client only. |
void UpdateVisibleAccessories() |
hook | same | Is called in Player.Frame() after vanilla functional slots are evaluated, including selection screen to prepare and denote visible accessories. Player Instance sensitive. |
void UpdateVisibleVanityAccessories() |
hook | same | Is called in Player.Frame() after vanilla vanity slots are evaluated, including selection screen to prepare and denote visible accessories. Player Instance sensitive. |
void UpdateDyes() |
hook | same | Is called in Player.UpdateDyes(), including selection screen. Player Instance sensitive. |
void PostUpdateMiscEffects() |
hook | same | This is called after miscellaneous update code is called in Player.Update, which is sometime after PostUpdateEquips is called. This can be used for general update tasks. Called on local, server, and remote clients. |
void PostUpdateRunSpeeds() |
hook | same | This is called after the player's horizontal speeds are modified, which is sometime after PostUpdateMiscEffects is called, and right before the player's horizontal position is updated. Use this to modify maxRunSpeed, accRunSpeed, runAcceleration, and similar variables before the player moves forwards/backwards. Called on local, server, and remote clients. |
void PreUpdateMovement() |
hook | same | This is called right before modifying the player's position based on velocity. Use this to make direct changes to the velocity. Called on local, server, and remote clients. |
void OnEquipmentLoadoutSwitched(int oldLoadoutIndex, int loadoutIndex) |
hook | same | Allows to execute some code if the equipment loadout was switched. Called on the server and on all clients. |
void ModifyMaxStats(out StatModifier health, out StatModifier mana) |
hook | same | Allows you to modify the player's max stats. This hook runs after vanilla increases from the Life Crystal, Life Fruit and Mana Crystal are applied Called on local, server, and remote clients. NOTE: You should NOT modify statLifeMax nor statManaMax here. Use the health and mana parameters. Also note that unlike many other tModLoader hooks, the default implementation of this hook has code that will assign health and mana to Default. Take care to place base.ModifyMaxStats(out health, out mana); before any other code you add to this hook to avoid issues, if you use it. |
void UpdateDead() |
hook | same | Similar to ResetEffects, except this is only called when the player is dead. If this is called, then ResetEffects will not be called. Called on local, server, and remote clients. |
void PreSaveCustomData() |
hook | same | Currently never gets called, so this is useless. |
void SaveData(TagCompound tag) |
hook | same | Allows you to save custom data for this player. NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization. NOTE: Try to only save data that isn't default values. |
void LoadData(TagCompound tag) |
hook | same | Allows you to load custom data that you have saved for this player. Try to write defensive loading code that won't crash if something's missing. |
void CopyClientState(ModPlayer targetCopy) |
hook | same | Allows you to copy information to the targetCopy parameter that you intend to sync between this local client and both the server and other clients. You would then use the SendClientChanges hook to compare against that data and decide what needs synchronizing, sending that data in a ModPacket to the server. The server will then need to relay that information to the other remote clients. This hook is called with every call of the clientClone method (each game update). See the Player / ModPlayer section of the Basic Netcode wiki page for more information. NOTE: For performance reasons, avoid deep cloning or copying any excessive information. NOTE: Using CopyNetStateTo is the recommended way of creating item snapshots. |
void SyncPlayer(int toWho, int fromWho, bool newPlayer) |
hook | same | Allows you to sync information about this player between server and client. This hook will be called whenever a player joins the game, both to sync the joining player's data to the server and other clients and to sync the data of the existing players to the joining player. This should be used to sync all necessary modded data from this ModPlayer to other clients. The SendClientChanges hook is used to selectively sync changes that happen during gameplay. The toWho and fromWho parameters correspond to the remoteClient/toClient and ignoreClient arguments, respectively, of NetMessage.SendData/ModPacket.Send. They should be passed in as-is. The newPlayer parameter is whether or not the player is joining the server (it is true on the joining client). This hook will be called on the local client to send the data to the server and also on the server to send the data to other clients. See the Player / ModPlayer section of the Basic Netcode wiki page for more information. |
void SendClientChanges(ModPlayer clientPlayer) |
hook | same | Allows you to sync any information that has changed for this ModPlayer since the last game update from this local client to the server. The server will need to take those changes and relay them to other remote clients. Here, you should check the information you have copied in the clientClone parameter during CopyClientState; if they differ between this ModPlayer and the clientPlayer parameter, then you should send that information using NetMessage.SendData or ModPacket.Send. All of the differences are the changes that occurred during the last game update for the local player. See the Player / ModPlayer section of the Basic Netcode wiki page for more information. |
void PlayerConnect() |
hook | same | Called on remote clients when a player connects. |
void PlayerDisconnect() |
hook | same | Called on the server and remote clients when a player disconnects. |
void PreSavePlayer() |
hook | same | PreSavePlayer and PostSavePlayer wrap the vanilla player saving code (both are before the ModPlayer.Save). Useful for advanced situations where a save might be corrupted or rendered unusable by the values that normally would save. |
void PostSavePlayer() |
hook | same | PreSavePlayer and PostSavePlayer wrap the vanilla player saving code (both are before the ModPlayer.Save). Useful for advanced situations where a save might be corrupted or rendered unusable by the values that normally would save. |
void UpdateBadLifeRegen() |
hook | same | Allows you to give the player a negative life regeneration based on its state (for example, the "On Fire!" debuff makes the player take damage-over-time). This is typically done by setting Player.lifeRegen to 0 if it is positive, setting Player.lifeRegenTime to 0, and subtracting a number from Player.lifeRegen. The player will take damage at a rate of half the number you subtract per second. Called on local, server, and remote clients. |
void UpdateLifeRegen() |
hook | same | Allows you to increase the player's life regeneration based on its state. This can be done by incrementing Player.lifeRegen by a certain number. The player will recover life at a rate of half the number you add per second. You can also increment Player.lifeRegenTime to increase the speed at which the player reaches its maximum natural life regeneration. Called on local, server, and remote clients. |
void PreUpdate() |
hook | same | This is called at the beginning of every tick update for this player, after checking whether the player exists. This can be used to adjust timers and cooldowns. Called on local, server, and remote clients. |
void PreUpdateBuffs() |
hook | same | This is called sometime after SetControls is called, and right before all the buffs update on this player. This hook can be used to add buffs to the player based on the player's state (for example, the Campfire buff is added if the player is near a Campfire). Called on local, server, and remote clients. |
void PostUpdateBuffs() |
hook | same | This is called right after all of this player's buffs update on the player. This can be used to modify the effects that the buff updates had on this player, and can also be used for general update tasks. Called on local, server, and remote clients. |
void UpdateEquips() |
hook | same | Called after Update Accessories. Called on local, server, and remote clients. |
void PostUpdateEquips() |
hook | same | This is called right after all of this player's equipment and armor sets update on the player, which is sometime after PostUpdateBuffs is called. This can be used to modify the effects that the equipment had on this player, and can also be used for general update tasks. Called on local, server, and remote clients. |
void PostUpdate() |
hook | same | This is called at the very end of the Player.Update method. Final general update tasks can be placed here. Called on local, server, and remote clients. |
void FrameEffects() |
hook | same | Allows you to modify the armor and accessories that visually appear on the player. In addition, you can create special effects around this character, such as creating dust. Called on local, server, and remote clients. |
bool ImmuneTo(PlayerDeathReason damageSource, int cooldownCounter, bool dodgeable) |
hook | same | Allows you to make a player immune to damage from a certain source, or at a certain time. Vanilla examples include shimmer and journey god mode. Runs before dodges are used, or any damage calculations are performed. If immunity is determined on the local player, the hit will not be sent across the network. In pvp the hit will be sent regardless, and all clients will determine immunity independently, though it only really matters for the receiving player. Called on local, server, and remote clients. |
bool FreeDodge(HurtInfo info) |
hook | same | Allows you to dodge damage for a player. Intended for guaranteed 'free' or random dodges. Vanilla example is black belt. For dodges which consume a stack/buff or have a cooldown, use ConsumableDodge instead. Called on the local client receiving damage. If dodge is determined on the local player, the hit will not be sent across the network. If visual indication of the dodge is required on remote clients, you will need to send your own packet. |
bool ConsumableDodge(HurtInfo info) |
hook | same | Allows you to dodge damage for a player. Vanilla examples include hallowed armor shadow dodge, and brain of confusion. For dodges which are 'free' and should be used before triggering consumables, use FreeDodge instead. Called on the local client receiving damage. If dodge is determined on the local player, the hit will not be sent across the network. You may need to send your own packet to synchronize the consumption of the effect, or application of the cooldown in multiplayer. |
void ModifyHurt(ref HurtModifiers modifiers) |
hook | same | Allows you to adjust an instance of player taking damage. Called on the local client taking damage. Only use this hook if you need to modify the hurt parameters in some way, eg consuming a buff which reduces the damage of the next hit. Use OnHurt or PostHurt instead where possible. The player will always take at least 1 damage. To prevent damage use ImmuneTo or FreeDodge
|
void OnHurt(HurtInfo info) |
hook | same | Allows you to make anything happen when the player takes damage. Called on the local client taking damage. Called right before health is reduced. |
void PostHurt(HurtInfo info) |
hook | same | Allows you to make anything happen when the player takes damage. Called on the local client taking damage Only called if the player survives the hit. |
bool CanBeHitByNPC(NPC npc, ref int cooldownSlot) |
hook | same | Allows you to determine whether the given NPC can hit this player. Return false to block this player from being hit by the NPC. Returns true by default. CooldownSlot determines which of the player's cooldown counters (ImmunityCooldownID) to use, and defaults to -1 (General). Called on the client taking damage |
bool CanBeHitByProjectile(Projectile proj) |
hook | same | Allows you to determine whether the given hostile projectile can hit this player. Return false to block this player from being hit. Returns true by default. Called on the client taking damage |
void ModifyHitByNPC(NPC npc, ref HurtModifiers modifiers) |
hook | same | Allows you to modify the damage, etc., that an NPC does to this player. Called on the client taking damage |
void ModifyHitByProjectile(Projectile proj, ref HurtModifiers modifiers) |
hook | same | Allows you to modify the damage, etc., that a hostile projectile does to this player. Called on the client taking damage |
void OnHitByNPC(NPC npc, HurtInfo hurtInfo) |
hook | same | Allows you to create special effects when an NPC hits this player (for example, inflicting debuffs). Called on the client taking damage |
void OnHitByProjectile(Projectile proj, HurtInfo hurtInfo) |
hook | same | Allows you to create special effects when a hostile projectile hits this player. Called on the client taking damage |
bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genDust, ref PlayerDeathReason damageSource) |
hook | same | This hook is called whenever the player is about to be killed after reaching 0 health. Called on local, server, and remote clients. Set the playSound parameter to false to stop the death sound from playing. Set the genDust parameter to false to stop the dust from being created. These are useful for creating your own sound or dust to replace the normal death effects, such as how the Frost armor set spawns IceTorch instead of Blood. For mod compatibility, it is recommended to check if these values are true before setting them to true and spawning dust or playing sounds to avoid overlapping sounds and dust effects. Return false to stop the player from being killed. Only return false if you know what you are doing! Returns true by default. |
void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource) |
hook | same | Allows you to make anything happen when the player dies. Called on local, server, and remote clients. |
bool PreModifyLuck(ref float luck) |
hook | same | Called before vanilla makes any luck calculations. Return false to prevent vanilla from making their luck calculations. Returns true by default. Called on local, server, and remote clients. |
void ModifyLuck(ref float luck) |
hook | same | Allows you to modify a player's luck amount. Called on local, server, and remote clients. |
bool PreItemCheck() |
hook | same | Allows you to do anything before the update code for the player's held item is run. Return false to stop the held item update code from being run (for example, if the player is frozen). Returns true by default. Called on local, server, and remote clients. |
void PostItemCheck() |
hook | same | Allows you to do anything after the update code for the player's held item is run. Hooks for the middle of the held item update code have more specific names in ModItem and ModPlayer. Called on local, server, and remote clients. |
float UseTimeMultiplier(Item item) |
hook | same | Allows you to change the effective useTime of an item. Note that this hook may cause items' actions to run less or more times than they should per a single use. Called on local, server, and remote clients. |
float UseAnimationMultiplier(Item item) |
hook | same | Allows you to change the effective useAnimation of an item. Note that this hook may cause items' actions to run less or more times than they should per a single use. Called on local, server, and remote clients. |
float UseSpeedMultiplier(Item item) |
hook | same | Allows you to safely change both useTime and useAnimation while keeping the values relative to each other. Useful for status effects. Called on local, server, and remote clients. |
void GetHealLife(Item item, bool quickHeal, ref int healValue) |
hook | same | Allows you to temporarily modify the amount of life a life healing item will heal for, based on player buffs, accessories, etc. This is only called for items with a healLife value. Called on local, server, and remote clients. |
void GetHealMana(Item item, bool quickHeal, ref int healValue) |
hook | same | Allows you to temporarily modify the amount of mana a mana healing item will heal for, based on player buffs, accessories, etc. This is only called for items with a healMana value. Called on local, server, and remote clients. |
void ModifyManaCost(Item item, ref float reduce, ref float mult) |
hook | same | Allows you to temporarily modify the amount of mana an item will consume on use, based on player buffs, accessories, etc. This is only called for items with a mana value. Called on local, server, and remote clients. |
void OnMissingMana(Item item, int neededMana) |
hook | same | Allows you to make stuff happen when a player doesn't have enough mana for the item they are trying to use. If the player has high enough mana after this hook runs, mana consumption will happen normally. Only runs once per item use. Called on local, server, and remote clients. |
void OnConsumeMana(Item item, int manaConsumed) |
hook | same | Allows you to make stuff happen when a player consumes mana on use of an item. Called on local, server, and remote clients. |
bool ApplyPotionDelay(Item item, int potionDelay) |
hook | same | Called before the potion delay is applied to the player after consuming a healing potion. Return false to prevent application of the PotionSickness buff and setting potionDelay. |
void ModifyWeaponDamage(Item item, ref StatModifier damage) |
hook | same | Allows you to dynamically modify a weapon's damage based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. Called on local, server, and remote clients. |
void ModifyWeaponKnockback(Item item, ref StatModifier knockback) |
hook | same | Allows you to dynamically modify a weapon's knockback based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. Called on the local client only. |
void ModifyWeaponCrit(Item item, ref float crit) |
hook | same | Allows you to dynamically modify a weapon's crit chance based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. Called on the local client only. |
bool CanConsumeAmmo(Item weapon, Item ammo) |
hook | same | Whether or not the given ammo item will be consumed by this weapon. By default, returns true; return false to prevent ammo consumption. If false is returned, the OnConsumeAmmo hook is never called. Called on local, server, and remote clients. |
void OnConsumeAmmo(Item weapon, Item ammo) |
hook | same | Allows you to make things happen when the given ammo is consumed by the given weapon. Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place. Called on local, server, and remote clients. |
bool CanShoot(Item item) |
hook | same | Allows you to prevent an item from shooting a projectile on use. Returns true by default. Called on local, server, and remote clients. |
void ModifyShootStats(Item item, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) |
hook | same | Allows you to modify the position, velocity, type, damage and/or knockback of a projectile being shot by an item. Called on the local client only. |
bool Shoot(Item item, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) |
hook | same | Allows you to modify an item's shooting mechanism. Return false to prevent vanilla's shooting code from running. Returns true by default. Called on the local client only. |
void MeleeEffects(Item item, Rectangle hitbox) |
hook | same | Allows you to give this player's melee weapon special effects, such as creating light or dust. This is typically used to implement a weapon enchantment, similar to flasks, frost armor, or magma stone effects. If implementing a weapon enchantment, also implement EmitEnchantmentVisualsAt to support enchantment visuals for projectiles as well. Called on the local client only. |
void ModifyItemScale(Item item, ref float scale) |
hook | same | Allows you to dynamically modify the given item's size for this player, similarly to the effect of the Titan Glove. Called on local and remote clients |
void OnHitAnything(float x, float y, Entity victim) |
hook | same | This hook is called when a player damages anything, whether it be an NPC or another player, using anything, whether it be a melee weapon or a projectile. The x and y parameters are the coordinates of the victim parameter's center. Called on the client hitting the target. |
bool CanHitNPC(NPC target) |
hook | same | Allows you to determine whether a player can hit the given NPC. Returns true by default. Called on the client hitting the target. |
bool CanMeleeAttackCollideWithNPC(Item item, Rectangle meleeAttackHitbox, NPC target) |
hook | same | Allows you to determine whether a player melee attack can collide the given NPC by swinging a melee weapon. Use CanHitNPCWithItem instead for Guide Voodoo Doll-type effects. Called on the client hitting the target. |
void ModifyHitNPC(NPC target, ref HitModifiers modifiers) |
hook | same | Allows you to modify the damage, knockback, etc that this player does to an NPC. Called on the client hitting the target. |
void OnHitNPC(NPC target, HitInfo hit, int damageDone) |
hook | same | Allows you to create special effects when this player hits an NPC. Called on the client hitting the target. |
bool CanHitNPCWithItem(Item item, NPC target) |
hook | same | Allows you to determine whether a player can hit the given NPC by swinging a melee weapon. Return true to allow hitting the target, return false to block this player from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default. Called on the client hitting the target. |
void ModifyHitNPCWithItem(Item item, NPC target, ref HitModifiers modifiers) |
hook | same | Allows you to modify the damage, knockback, etc., that this player does to an NPC by swinging a melee weapon. Called on the client hitting the target. |
void OnHitNPCWithItem(Item item, NPC target, HitInfo hit, int damageDone) |
hook | same | Allows you to create special effects when this player hits an NPC by swinging a melee weapon (for example how the Pumpkin Sword creates pumpkin heads). Called on the client hitting the target. |
bool CanHitNPCWithProj(Projectile proj, NPC target) |
hook | same | Allows you to determine whether a projectile created by this player can hit the given NPC. Return true to allow hitting the target, return false to block this projectile from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default. Called on the client hitting the target. |
void ModifyHitNPCWithProj(Projectile proj, NPC target, ref HitModifiers modifiers) |
hook | same | Allows you to modify the damage, knockback, etc., that a projectile created by this player does to an NPC. Called on the client hitting the target. |
void OnHitNPCWithProj(Projectile proj, NPC target, HitInfo hit, int damageDone) |
hook | same | Allows you to create special effects when a projectile created by this player hits an NPC (for example, inflicting debuffs). Called on the client hitting the target. |
bool CanHitPvp(Item item, Player target) |
hook | same | Allows you to determine whether a melee weapon swung by this player can hit the given opponent player. Return false to block this weapon from hitting the target. Returns true by default. Called on the client hitting the target. |
bool CanHitPvpWithProj(Projectile proj, Player target) |
hook | same | Allows you to determine whether a projectile created by this player can hit the given opponent player. Return false to block the projectile from hitting the target. Returns true by default. Called on the client hitting the target. |
bool CanUseItem(Item item) |
hook | same | Return false to prevent an item from being used. By default returns true. Called on local, server, and remote clients. The item may or not be used after this method is called, so logic in this method should have no side effects such as consuming items or resources. |
bool CanAutoReuseItem(Item item) |
hook | same | Allows you to modify the autoswing (auto-reuse) behavior of any item without having to mess with Item.autoReuse. Useful to create effects like the Feral Claws which makes melee weapons and whips auto-reusable. Return true to enable autoswing (if not already enabled through autoReuse), return false to prevent autoswing. Returns null by default, which applies vanilla behavior. Called on local, server, and remote clients. |
bool CanCatchNPC(NPC target, Item item) |
hook | same | Allows you to determine whether the given item can catch the given NPC. Return true or false to say the target can or cannot be caught, respectively, regardless of vanilla rules. Returns null by default, which allows vanilla's NPC catching rules to decide the target's fate. If this returns false, OnCatchNPC is never called. Called on the local client only. NOTE: this does not classify the given item as a catch tool, which is necessary for catching NPCs in the first place. To do that, you will need to use the "CatchingTool" set in ItemID.Sets. |
void OnCatchNPC(NPC npc, Item item, bool failed) |
hook | same | Allows you to make things happen when the given item attempts to catch the given NPC. Called on the local client only. |
bool ShiftClickSlot(Item[] inventory, int context, int slot) |
hook | same | Called whenever the player shift-clicks an item slot. This can be used to override default clicking behavior (ie. selling, trashing, moving items). Called on the local client only. |
bool HoverSlot(Item[] inventory, int context, int slot) |
hook | same | Called whenever the player hovers over an item slot. This can be used to override cursorOverride Called on the local client only. See CursorOverrideID for cursor override style IDs |
void PostSellItem(NPC vendor, Item[] shopInventory, Item item) |
hook | same | Called whenever the player sells an item to an NPC. Called on the local client only. Note that item might be an item sold by the NPC, not an item to buy back. Check buyOnce if relevant to your logic. |
bool CanSellItem(NPC vendor, Item[] shopInventory, Item item) |
hook | same | Return false to prevent a transaction. Called before the transaction. Called on the local client only. |
void PostBuyItem(NPC vendor, Item[] shopInventory, Item item) |
hook | same | Called whenever the player buys an item from an NPC. Called on the local client only. |
bool CanBuyItem(NPC vendor, Item[] shopInventory, Item item) |
hook | same | Return false to prevent a transaction. Called before the transaction. Called on the local client only. |
bool ModifyNurseHeal(NPC nurse, ref int health, ref bool removeDebuffs, ref string chatText) |
hook | same | Called while the nurse chat is displayed. Return false to prevent the player from healing. If you return false, you need to set chatText so the user knows why they can't heal. Called on the local client only. |
void ModifyNursePrice(NPC nurse, int health, bool removeDebuffs, ref int price) |
hook | same | Called while the nurse chat is displayed and after ModifyNurseHeal. Allows custom pricing for Nurse services. See the Nurse wiki page for the default pricing. Called on the local client only. |
void PostNurseHeal(NPC nurse, int health, bool removeDebuffs, int price) |
hook | same | Called after the player heals themselves with the Nurse NPC. Called on the local client only. |
IEnumerable<Item> AddStartingItems(bool mediumCoreDeath) |
hook | same | Called when the player is created in the menu. You can use this method to add items to the player's starting inventory, as well as their inventory when they respawn in mediumcore. Called on the local client only. |
void ModifyStartingInventory(IReadOnlyDictionary<string, List<Item>> itemsByMod, bool mediumCoreDeath) |
hook | same | Allows you to modify the items that will be added to the player's inventory. Useful if you want to stop vanilla or other mods from adding an item. You can access a mod's items by using the mod's internal name as the indexer, such as: additions["ModName"]. To access vanilla items you can use "Terraria" as the index. Called on the local client only. |
void DrawEffects(PlayerDrawSet drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) |
hook | same | Allows you to create special effects when this player is drawn, such as creating dust, modifying the color the player is drawn in, etc. The fullBright parameter makes it so that the drawn player ignores the modified color and lighting. Make sure to add the indexes of any dusts you create to drawInfo.DustCache, and the indexes of any gore you create to drawInfo.GoreCache. This will be called multiple times a frame if a player afterimage is being drawn. Check if(drawinfo.shadow == 0f) to do some logic only when drawing the original player image. For example, spawning dust only for the original player image is commonly the desired behavior. Called on local and remote clients. |
void ModifyDrawInfo(ref PlayerDrawSet drawInfo) |
hook | same | Allows you to modify the drawing parameters of the player before drawing begins (before every PlayerDrawLayer runs). Called on local and remote clients. |
void TransformDrawData(ref PlayerDrawSet drawInfo) |
hook | same | Allows modifying player draw data after all PlayerDrawLayer have run (and added DrawDataCache entries) and immediately before the DrawDataCache entries are actually drawn. This can be used to modify all DrawDataCache entries, such as modifying the draw color of each entry. Vanilla uses this to apply the scale parameter of DrawPlayer and to customize how the First Fractal clones are rendered (unobtainable weapon). |
void ModifyDrawLayerOrdering(IDictionary<PlayerDrawLayer, Position> positions) |
hook | same | Allows you to reorder the player draw layers. This is called once at the end of mod loading, not during the game. Use with extreme caution, or risk breaking other mods. |
void HideDrawLayers(PlayerDrawSet drawInfo) |
hook | same | Allows you to modify the visibility of layers about to be drawn. All layers can be accessed via Layers. Individual layers can be accessed by the PlayerDrawLayers fields for vanilla layers or for modded layers. The Hide method is how a layer can be hidden. For example: PlayerDrawLayers.Wings.Hide(); ModContent.GetInstance().Hide(); Called on local and remote clients.
|
void ModifyScreenPosition() |
hook | same | Use this hook to modify screenPosition after weapon zoom and camera lerp have taken place. Called on the local client only. Also consider using Main.instance.CameraModifiers.Add(CameraModifier); as shown in ExampleMods MinionBossBody for screen shakes. |
void ModifyZoom(ref float zoom) |
hook | same | Use this to modify the zoom factor for the player. The zoom correlates to the percentage of half the screen size the zoom can reach. A value of -1 passed in means no vanilla scope is in effect. A value of 1.0 means the scope can zoom half a screen width/height away, putting the player on the edge of the game screen. Vanilla values include .8, .6666, and .5. Called on the local client only. |
void DrawPlayer(Camera camera) |
hook | same | Allows drawing additional copies of the player, usually to implement an armor set shadow visual effect, dodge effect, or dash effect. Use Main.PlayerRenderer.DrawPlayer(...) to draw the additional player copies. The normal player will be drawn after this method runs. Called during DrawPlayerFull. |
void ModifyExtraJumpDurationMultiplier(ExtraJump jump, ref float duration) |
hook | same | Use this hook to modify the jump duration from an extra jump. Called on local, server, and remote clients. Vanilla's extra jumps use the following values: Basilisk mount: 0.75 Blizzard in a Bottle: 1.5 Cloud in a Bottle: 0.75 Fart in a Jar: 2 Goat mount: 2 Sandstorm in a Bottle: 3 Santank mount: 2 Tsunami in a Bottle: 1.25 Unicorn mount: 2 |
bool CanStartExtraJump(ExtraJump jump) |
hook | same | An extra condition for whether an extra jump can be started. Returns true by default. Called on local, server, and remote clients. |
void OnExtraJumpStarted(ExtraJump jump, ref bool playSound) |
hook | same | Effects that should appear when the extra jump starts should happen here. For example, the Cloud in a Bottle's initial puff of smoke is spawned here. Called on local, server, and remote clients. |
void OnExtraJumpEnded(ExtraJump jump) |
hook | same | This hook runs before the Active flag for an extra jump is set from true to false when the extra jump's duration has expired This occurs when a grappling hook is thrown, the player grabs onto a rope, the jump's duration has finished and when the player's frozen, turned to stone or webbed. Called on local, server, and remote clients. |
void OnExtraJumpRefreshed(ExtraJump jump) |
hook | same | This hook runs before the Available flag for an extra jump is set to true in RefreshDoubleJumps This occurs at the start of the grounded jump and while the player is grounded. Called on local, server, and remote clients. |
void ExtraJumpVisuals(ExtraJump jump) |
hook | same | Effects that should appear while the player is performing an extra jump should happen here. For example, the Sandstorm in a Bottle's dusts are spawned here. Called on local, server, and remote clients. |
bool CanShowExtraJumpVisuals(ExtraJump jump) |
hook | same | Return false to prevent ShowVisuals from executing on jump. By default, this hook returns whether the player is moving upwards with respect to gravDir Called on local, server, and remote clients. |
void OnExtraJumpCleared(ExtraJump jump) |
hook | same | This hook runs before the Available flag for an extra jump is set to false in Update due to the jump being unavailable or when calling ConsumeAllExtraJumps (vanilla calls it when a mount that blocks jumps is active) |
void ModifyFishingAttempt(ref FishingAttempt attempt) |
hook | same | Allows you to change information about the ongoing fishing attempt before caught items/NPCs are decided, after all vanilla information has been gathered. Will not be called if various conditions for getting a catch aren't met, meaning you can't modify those. Setting rolledItemDrop or rolledEnemySpawn is not allowed and will be reset, use CatchFish for that. Called for the local client only. |
void CatchFish(FishingAttempt attempt, ref int itemDrop, ref int npcSpawn, ref AdvancedPopupRequest sonar, ref Vector2 sonarPosition) |
hook | same | Allows you to change the item or enemy the player gets when successfully catching an item or NPC. The Fishing Attempt structure contains most information about the vanilla event, including the Item Rod and Bait used by the player, the liquid it is being fished on, and so on. The Sonar and Sonar position fields allow you to change the text, color, velocity and position of the catch's name (be it item or NPC) freely Called on the local client only. |
void ModifyCaughtFish(Item fish) |
hook | same | Allows you to modify the item caught by the fishing player, including stack Called on the local client only. |
void SetControls() |
hook | same | Use this to modify the control inputs that the player receives. For example, the Confused debuff swaps the values of Player.controlLeft and Player.controlRight. This is called sometime after PreUpdate is called. Called on the local client only. |
bool CanConsumeBait(Item bait) |
hook | same | Choose if this bait will be consumed or not when used for fishing. return null for vanilla behavior. Not consuming will always take priority over forced consumption Called on the local client only. |
void GetFishingLevel(Item fishingRod, Item bait, ref float fishingLevel) |
hook | same | Allows you to modify the player's fishing power. As an example of the type of stuff that should go here, the phase of the moon can influence fishing power. Called on the local client only. |
void AnglerQuestReward(float rareMultiplier, List<Item> rewardItems) |
hook | same | Allows you to add to, change, or remove from the items the player earns when finishing an Angler quest. The rareMultiplier is a number between 0.15 and 1 inclusively; the lower it is the higher chance there should be for the player to earn rare items. Called on the local client only. |
void GetDyeTraderReward(List<int> rewardPool) |
hook | same | Allows you to modify what items are possible for the player to earn when giving a Strange Plant to the Dye Trader. Called on the local client only. |
IEnumerable<Item> AddMaterialsForCrafting(out ItemConsumedCallback itemConsumedCallback) |
hook | same | Called when Recipe.FindRecipes is called or the player is crafting an item You can use this method to add items as the materials that may be used for crafting items Called on the local client only. |
bool OnPickup(WorldItem item) |
hook | same | Allows you to make special things happen when this player picks up an item. Return false to stop the item from being added to the player's inventory; returns true by default. Called on the local client only. |
bool CanBeTeleportedTo(Vector2 teleportPosition, string context) |
hook | same | Whether or not the player can be teleported to the given coordinates with methods such as Teleportation Potions or the Rod of Discord. The coordinates correspond to the top left corner of the player position after teleporting. This gets called in CheckForGoodTeleportationSpot and ItemCheck_UseTeleportRod. The context will have a value of "CheckForGoodTeleportationSpot" or "TeleportRod" respectively indicating which type of teleport is being attempted. |
void OnEnterWorld() |
hook | same | Called when the player enters the world. A possible use is ensuring that UI elements are reset to the configuration specified in data saved to the ModPlayer. Can also be used for informational messages. Called on the local client only. |
void OnRespawn() |
hook | same | Called when a player respawns in the world. Called on local, server, and remote clients. |
abstract class Terraria.ModLoader.ModResourceOverlay : ModType
This class serves as a place for you to customize how the vanilla resource displays (Classic, Fancy and Bars) are drawn. For implementing your own resource displays, use ModResourceDisplaySet.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The overlay's number. |
bool PreDrawResource(ResourceOverlayDrawContext context) |
hook | same | Allows you to draw below any resource (hearts, stars, bars or panels) in a display set |
void PostDrawResource(ResourceOverlayDrawContext context) |
hook | same | Allows you to draw on top of any resource (hearts, stars, bars or panels) in a display set |
bool PreDrawResourceDisplay(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife, ref Color textColor, out bool drawText) |
hook | same | Allows you to draw before the resources (hearts, stars, bars and/or panels) in a display set are drawn. If you want to implement your own display set, it is recommended to use ModResourceDisplaySet instead of this hook. |
void PostDrawResourceDisplay(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife, Color textColor, bool drawText) |
hook | same | Allows you to draw after the resources (hearts, stars, bars and/or panels) in a display set are drawn |
bool DisplayHoverText(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife) |
hook | same | Allows you to specify if the hover text for a resource (life or mana) should be displayed |
struct Terraria.Mount
What Bunny Loader adds to the game's mount.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
object _mountSpecificData |
property | same | Free data of the mount, for your ModMount. |
struct Terraria.Mount.MountData
What Bunny Loader adds to a mount's data.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int[] playerYOffsets |
property | same | How high the player sits, per frame. |
struct Terraria.Mount.MountDelegatesData
Replaceable methods of a mount, such as MinecartDust.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Action<Vector2> MinecartDust |
property | same | The dust of a minecart. |
Action<Player, Vector2, int, int> MinecartJumpingSound |
property | same | The sound of a minecart's jump. |
Action<Player, Vector2, int, int> MinecartLandingSound |
property | same | The sound of a minecart's landing. |
Action<Player, Vector2, int, int> MinecartBumperSound |
property | same | The sound of a minecart's bumper. |
static class Terraria.ModLoader.MountLoader
This serves as the central place from which mounts are stored and mount-related functions are carried out.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int MountCount |
static property | same | How many exist, with the game's and every mod's. |
ModMount GetMount(int type) |
static method | same | Gets the ModMount instance corresponding to the given type. Returns null if no ModMount has the given type. |
bool IsModMount(MountData m) |
static method | only here | Whether a mount comes from a mod. |
tModLoader's MountLoader also has 7 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
enum Terraria.ModLoader.MountTextureType
This is an enum of all possible types of extra mount textures for custom mounts. The enum's keys are used in default texture autoloading lookup paths, which can be overriden in GetExtraTexture.
Values: Back, BackGlow, BackExtra, BackExtraGlow, Front, FrontGlow, FrontExtra, FrontExtraGlow
struct Terraria.Player
What Bunny Loader adds to the game's player.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
IEntitySource GetSource_FromThis(string context) |
method | same | The source for what the player creates. |
IEntitySource GetSource_Buff(int buffIndex) |
method | same | The source for what a buff creates. |
IEntitySource GetSource_Accessory(Item item, string context) |
method | same | The source for what an accessory creates. |
IEntitySource GetSource_Accessory_OnHurt(Item item, Entity attacker, string context) |
method | same | The source for what an accessory creates when hurt. |
IEntitySource GetSource_Accessory_OnHurt(Item item, PlayerDeathReason damageSource, string context) |
method | same | The source for what an accessory creates when hurt. |
void SetCCed() |
method | same | Call this method to mark as true for this game update. Use for modded crowd control effects. |
bool ItemAnimationEndingOrEnded |
property | same | Returns true if the item animation is on or after its last frame. Meaning it could (if the player clicks etc) start again next frame. Vanilla uses it to despawn spears, but it's not recommended because it will desync in multiplayer (a remote player could get the packet for a new projectile just as they're finishing a swing). It is recommended to use ai counters for the lifetime of animation bound projectiles instead. |
int ItemUsesThisAnimation |
property | same | The number of times the item has been used/fired this animation (swing) |
bool HasAmmo(Item item) |
method | differs | Whether the player has ammo for the item. tML: bool HasAmmo(Item sItem, bool canUse)
|
IEntitySource GetSource_ItemUse_WithPotentialAmmo(Item item, int ammoItemId, string context) |
method | same | The source for a weapon's shot, with its ammo. |
bool PickAmmo(Item item, out int projectile, out float speed, out int damage, out float knockback, out int usedAmmoItemId, bool dontConsume) |
method | differs | Finds the ammo and works out the shot. tML: void PickAmmo(Item sItem, ref int projToShoot, ref float speed, ref bool canShoot, ref int Damage, ref float KnockBack, out int usedAmmoItemId, bool dontConsume)
|
bool MeleeEnchantActive |
property | same | Checks or sets meleeEnchant, indicating if a melee enchantment is active or not. Mods can check the meleeEnchant value directly to act on existing melee enchantments, but modded melee enchantments do not have specific assigned values. |
ref StatModifier PotionDelayModifier |
property | differs | Modifies the cooldown of health potions. Can be used to adjust potion cooldown calculations, similar to the Philosopher's Stone. tML: StatModifier PotionDelayModifier
|
SceneEffectInstance CurrentSceneEffect |
property | same | Container for current SceneEffect client properties such as: Backgrounds, music, and water styling |
bool InModBiome(ModBiome baseInstance) |
method | same | Whether the player is in this biome. |
bool InModBiome<T>() |
method | same | Whether the player is in this biome. |
HashSet<int> NearbyModTorch |
property | same | The mod torches near the player. |
bool HasBuff(int type) |
method | same | Returns whether or not this Player currently has a (de)buff of the provided type. |
int LifeCrystalMax |
const | same | The maximum amount of Life Crystals this player is allowed to consume total |
int LifeFruitMax |
const | same | The maximum amount of Life Fruit this player is allowed to consume total |
int ManaCrystalMax |
const | same | The maximum amount of Mana Crystals this player is allowed to consume total |
int ConsumedLifeCrystals |
property | same | How many Life Crystals this player has consumed |
int ConsumedLifeFruit |
property | same | How many Life Fruit this player has consumed |
int ConsumedManaCrystals |
property | same | How many Mana Crystals this player has consumed |
void UseHealthMaxIncreasingItem(int increase) |
method | same | The effect of a Life Crystal: text, dust and sound. |
void UseManaMaxIncreasingItem(int increase) |
method | same | The effect of a Mana Crystal: text, dust and sound. |
void AddImmuneTime(int cooldownCounterId, int immuneTime) |
method | same | Adds to either Player.immuneTime or Player.hurtCooldowns based on the cooldownCounterId |
ModPlayer[] ModPlayers |
property | differs | Its ModPlayer instances. tML: RefReadOnlyArray<ModPlayer> ModPlayers
|
T GetModPlayer<T>() |
method | same | Gets the instance of the specified ModPlayer type. This will throw exceptions on failure. |
T GetModPlayer<T>(T baseInstance) |
method | same | Gets the local instance of the type of the specified ModPlayer instance. This will throw exceptions on failure. |
bool TryGetModPlayer<T>(out T result) |
method | same | Gets the instance of the specified ModPlayer type. |
bool TryGetModPlayer<T>(T baseInstance, out T result) |
method | same | Safely attempts to get the local instance of the type of the specified ModPlayer instance. |
string setBonus |
property | only here | The set bonus text. |
ref StatModifier GetDamage<T>() |
method | same | Gets the damage modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. |
ref StatModifier GetDamage(DamageClass damageClass) |
method | same | Gets the damage modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. |
ref float GetCritChance<T>() |
method | same | Gets the crit chance modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. Note that crit values are percentage values ranging from 0 to 100, unlike damage multipliers. Adding 4, for example, would add 4% to the crit chance. |
ref float GetCritChance(DamageClass damageClass) |
method | same | Gets the crit chance modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. Note that crit values are percentage values ranging from 0 to 100, unlike damage multipliers. Adding 4, for example, would add 4% to the crit chance. |
ref float GetAttackSpeed<T>() |
method | same | Gets the attack speed modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return values with operators. Setting this such that it results in zero or a negative value will throw an exception. NOTE: Due to the nature of attack speed modifiers, modifications to Flat will do nothing for this modifier. Note that attack speed is a multiplier. Adding 0.15f, for example, would add 15% to the attack speed stat. |
ref float GetAttackSpeed(DamageClass damageClass) |
method | same | Gets the attack speed modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return values with operators. Note that attack speed is a multiplier. Adding 0.15f, for example, would add 15% to the attack speed stat. |
ref float GetArmorPenetration<T>() |
method | same | Gets the armor penetration modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. Note that armor penetration value are typically whole numbers. Adding 5, for example, would add 5 to the armor penetration stat, similar to the Shark Tooth Necklace accessory. |
ref float GetArmorPenetration(DamageClass damageClass) |
method | same | Gets the armor penetration modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. Note that armor penetration value are typically whole numbers. Adding 5, for example, would add 5 to the armor penetration stat, similar to the Shark Tooth Necklace accessory. |
ref StatModifier GetKnockback<T>() |
method | same | Gets the knockback modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. Note that knockback values are multipliers. Adding 0.12f, for example, would add 12% to the knockback stat. |
ref StatModifier GetKnockback(DamageClass damageClass) |
method | same | Gets the knockback modifier for this damage type on this player. This returns a reference, and as such, you can freely modify this method's return value with operators. Note that knockback values are multipliers. Adding 0.12f, for example, would add 12% to the knockback stat. |
StatModifier GetTotalDamage<T>() |
method | same | The damage of a class, with what it inherits. |
StatModifier GetTotalDamage(DamageClass damageClass) |
method | same | The damage of a class, with what it inherits. |
float GetTotalCritChance<T>() |
method | same | The critical chance of a class, with what it inherits. |
float GetTotalCritChance(DamageClass damageClass) |
method | same | The critical chance of a class, with what it inherits. |
float GetTotalAttackSpeed<T>() |
method | same | The attack speed of a class, with what it inherits. |
float GetTotalAttackSpeed(DamageClass damageClass) |
method | same | The attack speed of a class, with what it inherits. |
float GetTotalArmorPenetration<T>() |
method | same | The armor penetration of a class, with what it inherits. |
float GetTotalArmorPenetration(DamageClass damageClass) |
method | same | The armor penetration of a class, with what it inherits. |
StatModifier GetTotalKnockback<T>() |
method | same | The knockback of a class, with what it inherits. |
StatModifier GetTotalKnockback(DamageClass damageClass) |
method | same | The knockback of a class, with what it inherits. |
float GetWeaponAttackSpeed(Item sItem) |
method | same | The attack speed for this weapon, with the hooks. |
int GetWeaponArmorPenetration(Item sItem) |
method | same | The armor penetration for this weapon, with the hooks. |
ref ExtraJumpState GetJumpState<T>(T baseInstance) |
method | same | The state of an extra jump. |
ref ExtraJumpState GetJumpState<T>() |
method | same | The state of an extra jump. |
Span<ExtraJumpState> ExtraJumps |
property | same | The state of every extra jump. |
ref bool blockExtraJumps |
property | differs | When true, all extra jumps will be blocked, including Flipper usage. Setting this field to true will not stop any currently active extra jumps. tML: bool blockExtraJumps
|
bool AnyExtraJumpUsable() |
method | same | Returns true if any extra jump is Available and CanStart. Setting blockExtraJumps will cause this method to return false instead. |
void StopExtraJumpInProgress() |
method | same | Cancels any extra jump in progress. Sets all Active flags to false and calls OnExtraJumpEnded hooks. Also sets jump to 0 if a an extra jump was active. Used by vanilla when performing an action which would cancel jumping, such as grappling, grabbing a rope or getting frozen. To prevent the use of remaining jumps, use ConsumeAllExtraJumps or blockExtraJumps. To cancel a regular jump as well, do Player.jump = 0;
|
void ConsumeAllExtraJumps() |
method | same | Spends every extra jump. |
void ManageSpecialBiomeVisuals(string biomeName, bool inZone, Vector2 activationSource) |
method | only here | Turns a biome's filter and sky on or off. |
struct Terraria.Player.HurtInfo
Represents a finalized damage calculation for damage about to be applied to a Player. This is the result of all modifications done previously in a HurtModifiers provided to various hooks.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerDeathReason DamageSource |
field | same | Who or what did it. |
bool PvP |
field | same | Whether another player did it. |
int CooldownCounter |
field | same | Which immunity counter it uses. |
bool Dodgeable |
field | same | Whether it can be dodged. |
int SourceDamage |
property | same | The amount of damage 'dealt' to the player, before incoming damage multipliers, armor, damage reduction. Use this to trigger effects which scale based on how 'hard' the player was hit rather than how much life was lost. Cannot be set to less than 1. Using this instead of Damage can prevent diminishing returns damage mitigation, when adding beneficial effects like retaliatory damage. |
int Damage |
property | same | The amount of damage received by the player. How much life the player will lose. Is NOT capped at the player's current life. Cannot be set to less than 1. |
int HitDirection |
field | same | The side it came from. |
float Knockback |
field | same | The amount of knockback to apply. Should always be >= 0. |
bool Cancelled |
field | same | Whether a hook cancelled it. |
bool DustDisabled |
field | same | If true, dust will not spawn |
bool SoundDisabled |
field | same | If true, sound will not play |
new HurtInfo() |
constructor | same | Creates an instance. |
struct Terraria.Player.HurtModifiers
Represents a damage calculation in the process of being calculated for damage to be applied to a Player. The final damage calculation will be present in the resulting HurtInfo provided to various hooks.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerDeathReason DamageSource |
property | same | The source of the strike. Use TryGetCausingEntity to get the source of the strike (only safe to do when the target is the local player). |
bool PvP |
property | same | Whether or not this strike came from another player. Note that PvP support in Terraria is rudimentary and inconsistent, so careful research and testing may be required. |
int CooldownCounter |
property | same | The ImmunityCooldownID of the strike |
bool Dodgeable |
property | same | Whether or not this strike was dodgeable. |
int HitDirection |
property | same | The direction to apply knockback. If 0, no knockback will be applied. Could potentially be used for directional resistances. Can be overridden by HitDirectionOverride
|
StatModifier SourceDamage |
field | same | Use this to enhance or scale the base damage of the NPC/projectile/hit. Not used by vanilla due to lack of proper pvp support. Use cases are similar to SourceDamage
|
MultipliableFloat IncomingDamageMultiplier |
field | same | Use this to reduce damage from certain sources before applying defense. Used by vanilla for coldResist and banner damage reduction. |
StatModifier FinalDamage |
field | same | Applied to the final damage result. Used by endurance to reduce overall incoming damage. Multiply to grant damage reduction buffs (eg *0.9f for -10% damage taken). Add to Base to deal damage which ignores armor, but still respects scaling damage reduction like endurance or paladins shield. Adding to Flat will ignore all reductions or increases to deal unconditional damage. Not recommended due to potential compatibility issues with accessories like paladin's shield, use Base instead. |
AddableFloat ArmorPenetration |
field | same | Flat defense reduction. Applies after ScalingArmorPenetration. Consider supplying armorPenetration as an argument to Hurt instead if possible. |
AddableFloat ScalingArmorPenetration |
field | same | Used to ignore a fraction of player defense. Applies before flat ArmorPenetration. At 1f, the attack will completely ignore all defense. |
void SetMaxDamage(int limit) |
method | same | Sets an inclusive upper bound on the final damage of the hit. Can be set by multiple mods, in which case the lowest limit will be used. Cannot be set to less than 1 |
StatModifier Knockback |
field | same | Modifiers to apply to the knockback. Add to Base to increase the knockback of the strike. Multiply to decrease or increase overall knockback susceptibility. |
int HitDirectionOverride |
property | same | Overrides the direction to apply knockback. Will not affect HitDirection, only the final HitDirection If set by multiple mods, only the last override will apply. Intended for use by attacks which want to hit the player towards the source of the attack. |
MultipliableFloat KnockbackImmunityEffectiveness |
field | same | Use this to reduce the effectiveness of noKnockback (cobalt shield accessory). Eg, *0.8f to reduce knockback to 20% when cobalt shield is equipped. Defaults to 1f (knockback immunity is 100% effective by default). Used by vanilla for the ogre's launching attack. |
void Cancel() |
method | same | Cancels the Hurt. Further hooks like FreeDodge and OnHurt will not be called. Does not automatically apply immune frames, so the player can get hit again next frame. |
void DisableDust() |
method | same | Prevents dust from spawning |
void DisableSound() |
method | same | Prevents the hurt sound from playing |
HurtInfoModifier ModifyHurtInfo |
event | same | Use with caution and consider other alternatives first. Can be used to register a callback to freely modify the HurtInfo produced by ToHurtInfo before it is returned If multiple mods register different callbacks which modify the hurt info in different ways the results could be a mess! |
new HurtModifiers() |
constructor | same | Creates an instance. |
float GetDamage(float baseDamage, float defense, float defenseEffectiveness) |
method | same | The final damage of the hit. |
float GetKnockback(float baseKnockback, bool knockbackImmune) |
method | same | The final knockback of the hit. |
HurtInfo ToHurtInfo(int damage, int defense, float defenseEffectiveness, float knockback, bool knockbackImmune) |
method | same | The hit as a HurtInfo. |
abstract class Terraria.ModLoader.PlayerDrawLayer : ModType
This class represents a DrawLayer for the player. Drawing should be done by adding Terraria.DataStructures.DrawData objects to drawInfo.DrawDataCache in the Draw method. Custom PlayerDrawLayer can be used to add additional layers to player drawing. There are a few options for customizing player rendering without resorting to a custom PlayerDrawLayer for some specific use-cases: ModifyEquipTextureDraw can be used to modify how an equipment texture for an item is drawn. ModifyItemDraw can be used to modify how the held item is drawn.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool Visible |
property | same | Whether it draws in this frame. |
Transformation Transform |
hook | same | The change applied around this layer. |
IReadOnlyList<PlayerDrawLayer> ChildrenBefore |
property | same | Layers drawn just before it. |
IReadOnlyList<PlayerDrawLayer> ChildrenAfter |
property | same | Layers drawn just after it. |
bool IsHeadLayer |
hook | same | Returns whether or not this layer should be rendered for the minimap icon. |
void Hide() |
method | same | Hides the layer in this frame. |
bool GetDefaultVisibility(PlayerDrawSet drawInfo) |
hook | same | Returns the layer's default visibility. This is usually called as a layer is queued for drawing, but modders can call it too for information. |
Position GetDefaultPosition() |
hook | same | Returns the layer's default position in regards to other layers. Make use of BeforeParent, AfterParent, Between, or Multiple to indicate the position. Use other layers as arguments, usually vanilla layers contained in the PlayerDrawLayers. BeforeFirstVanillaLayer and AfterLastVanillaLayer are also possible values. |
void Draw(ref PlayerDrawSet drawInfo) |
hook | same | Draws this layer. This will be called multiple times a frame if a player afterimage is being drawn. If this layer shouldn't draw with each afterimage, check if(drawinfo.shadow == 0f) to only draw for the original player image. |
void DrawWithTransformationAndChildren(ref PlayerDrawSet drawInfo) |
method | same | Draws the layer, its children and its change. |
string ToString() |
override | same | The text form of this value. |
class Terraria.ModLoader.PlayerDrawLayer.AfterParent : Position
Places this layer immediately after (over) the provided parent layer. The visibility and draw order of the layer is also bound to the parent layer, if the parent layer is moved or hidden, this layer will also be moved or hidden.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerDrawLayer Parent |
property | same | The layer it follows. |
new AfterParent(PlayerDrawLayer parent) |
constructor | same | Creates an instance. |
class Terraria.ModLoader.PlayerDrawLayer.BeforeParent : Position
Places this layer immediately before (under) the provided parent layer. The visibility and draw order of the layer is also bound to the parent layer, if the parent layer is moved or hidden, this layer will also be moved or hidden.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerDrawLayer Parent |
property | same | The layer it comes before. |
new BeforeParent(PlayerDrawLayer parent) |
constructor | same | Creates an instance. |
class Terraria.ModLoader.PlayerDrawLayer.Between : Position
Places this layer between the two provided layers. This layer will draw over layer1 and under layer2. null can be used to indicate that the exact position of the layer doesn't matter aside from being before/after the other non-null argument. For example new Between(PlayerDrawLayers.HairBack, null) would place the layer anywhere after HairBack, while new Between(null, PlayerDrawLayers.HairBack) would be anywhere before HairBack. For ordering before or after all vanilla layers, the helper properties BeforeFirstVanillaLayer and AfterLastVanillaLayer can be used directly. The layer parameters used must have fixed positions, meaning that layers registered using either Multiple, BeforeParent, or AfterParent are not valid. For vanilla layers, this includes FrontAccFront and HeldItem. If ordering in relation to these layers, consider either using AfterParent or BeforeParent to draw at whatever positions that layer is actually drawn, or referencing a different layer for ordering instead.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerDrawLayer Layer1 |
property | same | The layer before it. |
PlayerDrawLayer Layer2 |
property | same | The layer after it. |
new Between(PlayerDrawLayer layer1, PlayerDrawLayer layer2) |
constructor | same | Creates an instance. |
new Between() |
constructor | same | Creates an instance. |
class Terraria.ModLoader.PlayerDrawLayer.Multiple : Position
Places this layer into multiple Positions. Use this as a helper for layers that need to move around in the draw order rather than making multiple PlayerDrawLayer 'slots' manually. An example of this can be seen in PlayerDrawLayers.tML.cs. Note how the conditions for FrontAccFront and HeldItem are mutually exclusive, ensuring that the layer will only be drawn once for a given player.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
IList<(Between, Condition)> Positions |
property | same | Each place, with its condition. |
void Add(Between position, Condition condition) |
method | same | Adds a place. |
IEnumerator GetEnumerator() |
method | same | Walks the items in foreach. |
abstract class Terraria.ModLoader.PlayerDrawLayer.Position
A PlayerDrawLayer's position in the player rendering draw order. When a player is drawn, each "layer" is drawn from back to front.
| Member | Kind | tModLoader | What it does |
|---|
abstract class Terraria.ModLoader.PlayerDrawLayer.Transformation
A change applied to every layer in a group, as PlayerDrawLayer positions it.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Transformation Parent |
hook | same | The change around this one. |
void PreDraw(ref PlayerDrawSet drawInfo) |
hook | same | Add a transformation to the drawInfo |
void PostDraw(ref PlayerDrawSet drawInfo) |
hook | same | Reverse a transformation from the drawInfo |
void PreDrawRecursive(ref PlayerDrawSet drawInfo) |
method | same | Applies it before the layer. |
void PostDrawRecursive(ref PlayerDrawSet drawInfo) |
method | same | Undoes it after the layer. |
static class Terraria.ModLoader.PlayerDrawLayerLoader
Orders the layers and draws them.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
IReadOnlyList<PlayerDrawLayer> Layers |
static property | same | Every layer. |
IReadOnlyList<PlayerDrawLayer> DrawOrder |
static property | same | The layers in the order they draw. |
PlayerDrawLayer[] GetDrawLayers(PlayerDrawSet drawInfo) |
static method | same | Note, not threadsafe |
class Terraria.ModLoader.PlayerDrawLayerSlot : PlayerDrawLayer
A layer that stands for a slot where another is drawn.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerDrawLayer Layer |
property | same | The layer behind the slot. |
Condition Condition |
property | same | When the slot applies. |
string Name |
override | same | The name of the slot. |
Position GetDefaultPosition() |
override | same | Where it goes in the draw order. |
void Draw(ref PlayerDrawSet drawInfo) |
override | same | Draws what the layer holds. |
bool GetDefaultVisibility(PlayerDrawSet drawInfo) |
override | same | Whether it draws in this frame. |
struct Terraria.DataStructures.PlayerDrawLayers
The game's layers by name, as PlayerDrawLayers.Head, to position yours against.
Members: TorsoGroup, MountGroup, JimsCloak, MountBack, Carpet, PortableStool, ElectrifiedDebuffBack, ForbiddenSetRing, SafemanSun, WebbedDebuffBack, LeinforsHairShampoo, Backpacks, Tails, Wings, HairBack, BackAcc, HeadBack, BalloonAcc, ArmorBackCoat, Skin, Leggings, Shoes, Robe, SkinLongCoat, ArmorLongCoat, Torso, OffhandAcc, WaistAcc, NeckAcc, Head, Magiluminescence, FaceAcc, MountFront, Pulley, JimsDroneRadio, FrontAccBack, Shield, SolarShield, ArmOverItem, HandOnAcc, BladedGlove, ProjectileOverArm, FrozenOrWebbedDebuff, ElectrifiedDebuffFront, IceBarrier, CaptureTheGem, BeetleBuff, EyebrellaCloud, FrontAccFront, HeldItem, FirstVanillaLayer, LastVanillaLayer, BeforeFirstVanillaLayer, AfterLastVanillaLayer
struct Terraria.DataStructures.PlayerDrawSet
Contains all the parameters defining how a particular player will be rendered in the current lighting, copied from the drawPlayer. First, the color of each body part is calculated and all of the fields are populated. Next, this data is used by each PlayerDrawLayer to populate DrawDataCache with DrawData corresponding to each individual layer making up the visuals of the player. Finally, every DrawDataCache is actually drawn. In terms of modded logic, DrawEffects runs before body part color values are calculated, ModifyDrawInfo runs right before each PlayerDrawLayer runs, then each PlayerDrawLayer runs, and finally TransformDrawData runs.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
DrawDataList DrawDataCache |
property | differs | The sprites to draw. Layers add to this list. tML: List<DrawData> DrawDataCache
|
bool headOnlyRender |
field | not here | Not implemented. |
bool isBottomOverriden |
field | not here | Not implemented. |
struct Terraria.GameContent.PlayerEyeHelper
The blink state of the player's eyes.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
EyeState CurrentEyeState |
property | same | What the eyes are doing. |
EyeFrame CurrentEyeFrame |
property | same | Which eye frame shows. |
int TimeInState |
property | same | Ticks in the current state. |
static class Terraria.ModLoader.PlayerLoader
This is where all ModPlayer hooks are gathered and called.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void ResetMaxStatsToVanilla(Player player) |
static method | not here | Resets statLifeMax and statManaMax to their expected values by vanilla |
void SetStartInventory(Player player, IList<Item> items) |
static method | not here | Internal here. Use ModPlayer.AddStartingItems. |
List<Item> GetStartingItems(Player player, IEnumerable<Item> vanillaItems, bool mediumCoreDeath) |
static method | not here | Internal here. Use ModPlayer.AddStartingItems. |
IEnumerable<(IEnumerable<Item>, ItemConsumedCallback)> GetModdedCraftingMaterials(Player player) |
static method | not here | Internal here. |
tModLoader's PlayerLoader also has 124 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
struct Terraria.GameContent.UI.ResourceSets.PlayerStatsSnapshot
The player's life and mana at the moment the resource bars are drawn.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
new PlayerStatsSnapshot(Player player) |
constructor | same | Creates an instance. |
int AmountOfLifeHearts |
property | same | How many hearts show. |
int AmountOfManaStars |
property | same | How many stars show. |
struct Terraria.ModLoader.ResourceOverlayDrawContext
What a ModResourceOverlay is drawing now: texture, position, color. Draw draws it.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PlayerStatsSnapshot snapshot |
field | same | A snapshot of the player's health and mana stats |
int resourceNumber |
field | same | Which heart/star/bar/panel is being drawn NOTE: This value usually starts at 0, but it can start at other values |
Asset<Texture2D> texture |
field | same | The texture to draw. |
Vector2 position |
field | same | Where it goes. |
Rectangle source |
field | same | The slice of the texture to draw null represents the entire texture |
Color color |
field | same | Its color. |
float rotation |
field | same | Its rotation. |
Vector2 origin |
field | same | The center for rotation and scaling within the source rectangle |
Vector2 scale |
field | same | Its scale. |
SpriteEffects effects |
field | same | Its flip. |
IPlayerResourcesDisplaySet DisplaySet |
property | same | The resource display set that this context is drawing from |
SpriteBatch SpriteBatch |
property | same | The batch to draw on. |
new ResourceOverlayDrawContext(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, int resourceNumber, Asset<Texture2D> texture) |
constructor | same | Creates a context for drawing resources from a display set |
void Draw() |
method | same | Draws with these values. |
static class Terraria.ModLoader.ResourceOverlayLoader
Runs the hooks of mod resource overlays.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int OverlayCount |
static property | same | How many exist, with the game's and every mod's. |
ModResourceOverlay GetOverlay(int type) |
static method | same | The ModResourceOverlay of a number, or null. |
bool PreDrawResource(ResourceOverlayDrawContext context) |
static method | same | Allows you to draw below any resource (hearts, stars, bars or panels) in a display set |
void PostDrawResource(ResourceOverlayDrawContext context) |
static method | same | Allows you to draw on top of any resource (hearts, stars, bars or panels) in a display set |
bool PreDrawResourceDisplay(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife, ref Color textColor, out bool drawText) |
static method | same | Allows you to draw before the resources (hearts, stars, bars and/or panels) in a display set are drawn. If you want to implement your own display set, it is recommended to use ModResourceDisplaySet instead of this hook. |
void PostDrawResourceDisplay(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife, Color textColor, bool drawText) |
static method | same | Allows you to draw after the resources (hearts, stars, bars and/or panels) in a display set are drawn |
bool DisplayHoverText(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife) |
static method | same | Allows you to specify if the hover text for a resource (life or mana) should be displayed |
void DrawResource(ResourceOverlayDrawContext drawContext) |
static method | not here | Draws a resource, typically life or mana |
Bunny Loader wiki ·
Discord ·
Repository ·
BL Editor
Written for Bunny Loader 0.5.5-beta and Terraria Mobile 1.4.5.8.6.
Bunny Loader is not affiliated with Re-Logic or 505 Games.
