tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ModPlayer Class Reference

A ModPlayer instance represents an extension of a Player instance. 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. More...

+ Collaboration diagram for Terraria.ModLoader.ModPlayer:

Public Member Functions

virtual void AnglerQuestReward (float rareMultiplier, List< Item > rewardItems)
 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. More...
 
virtual bool Autoload (ref string name)
 Allows you to automatically add a ModPlayer instead of using Mod.AddPlayer. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this to either force or stop an autoload, or change the name that identifies this type of ModPlayer. More...
 
virtual bool CanBeHitByNPC (NPC npc, ref int cooldownSlot)
 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 to use (-1, 0, or 1), and defaults to -1. More...
 
virtual bool CanBeHitByProjectile (Projectile proj)
 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. More...
 
virtual bool CanBuyItem (NPC vendor, Item[] shopInventory, Item item)
 Return false to prevent a transaction. Called before the transaction. More...
 
virtual ? bool CanHitNPC (Item item, NPC target)
 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. More...
 
virtual ? bool CanHitNPCWithProj (Projectile proj, NPC target)
 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. More...
 
virtual bool CanHitPvp (Item item, Player target)
 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. More...
 
virtual bool CanHitPvpWithProj (Projectile proj, Player target)
 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. More...
 
virtual bool CanSellItem (NPC vendor, Item[] shopInventory, Item item)
 Return false to prevent a transaction. Called before the transaction. More...
 
virtual void CatchFish (Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
 Allows you to change the item the player gains from catching a fish. The fishingRod and bait parameters refer to the said items in the player's inventory. The liquidType parameter is 0 if the player is fishing in water, 1 for lava, and 2 for honey. The poolSize parameter is the tile size of the pool the player is fishing in. The worldLayer parameter is 0 if the player is in the sky, 1 if the player is on the surface, 2 if the player is underground, 3 if the player is in the caverns, and 4 if the player is in the underworld. The questFish parameter is the item ID for the day's Angler quest. Modify the caughtType parameter to change the item the player catches. The junk parameter is whether the player catches junk; you can set this to true if you make the player catch a junk item, and is mostly used to pass information (has no effect on the game). More...
 
virtual void clientClone (ModPlayer clientClone)
 Allows you to copy information about this player to the clientClone parameter. You should copy information that you intend to sync between server and client. This hook is called in the Player.clientClone method. See SendClientChanges for more info. More...
 
virtual bool ConsumeAmmo (Item weapon, Item ammo)
 Whether or not ammo will be consumed upon usage. Return false to stop the ammo from being depleted. Returns true by default. If false is returned, the OnConsumeAmmo hook is never called. More...
 
virtual void CopyCustomBiomesTo (Player other)
 In this hook, you should copy the custom biome variables from this player to the other player parameter. This hook is used to help with client/server syncing. More...
 
virtual bool CustomBiomesMatch (Player other)
 Whether or not this player and the other player parameter have the same custom biome variables. This hook is used to help with client/server syncing. Returns true by default. More...
 
virtual void DrawEffects (PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
 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. Note that the fullBright parameter only works if r, g, b, and/or a is not equal to 1. Make sure to add the indexes of any dusts you create to Main.playerDrawDust, and the indexes of any gore you create to Main.playerDrawGore. More...
 
virtual void FrameEffects ()
 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. More...
 
virtual void GetDyeTraderReward (List< int > rewardPool)
 Allows you to modify what items are possible for the player to earn when giving a Strange Plant to the Dye Trader. More...
 
virtual void GetFishingLevel (Item fishingRod, Item bait, ref int fishingLevel)
 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. More...
 
virtual void GetHealLife (Item item, bool quickHeal, ref int healValue)
 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. More...
 
virtual void GetHealMana (Item item, bool quickHeal, ref int healValue)
 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. More...
 
virtual Texture2D GetMapBackgroundImage ()
 Allows you to change the background that displays when viewing the map. Return null if you do not want to change the background. Returns null by default. More...
 
virtual void GetWeaponCrit (Item item, ref int crit)
 Allows you to temporarily modify a weapon's crit chance based on player buffs, etc. More...
 
virtual void GetWeaponDamage (Item item, ref int damage)
 Allows you to temporarily modify a weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts). More...
 
virtual void GetWeaponKnockback (Item item, ref float knockback)
 Allows you to temporarily modify a weapon's knockback based on player buffs, etc. This allows you to customize knockback beyond the Player class's limited fields. More...
 
virtual void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
 Allows you to make anything happen right before damage is subtracted from the player's health. More...
 
virtual void Initialize ()
 Called whenever the player is loaded (on the player selection screen). This can be used to initialize data structures, etc. More...
 
virtual void Kill (double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
 Allows you to make anything happen when the player dies. More...
 
virtual void Load (TagCompound tag)
 Allows you to load custom data you have saved for this player. More...
 
virtual void LoadLegacy (BinaryReader reader)
 Allows you to load pre-v0.9 custom data you have saved for this player. More...
 
virtual void MeleeEffects (Item item, Rectangle hitbox)
 Allows you to give this player's melee weapon special effects, such as creating light or dust. More...
 
virtual float MeleeSpeedMultiplier (Item item)
 Allows you to multiply an item's regular melee speed. Returns 1f by default. Values greater than 1 increase the item speed. More...
 
virtual void ModifyDrawHeadLayers (List< PlayerHeadLayer > layers)
 Allows you to modify the drawing of the player head on the minimap. This is done by removing from, adding to, or rearranging the list, by setting some of the layers' visible field to false, etc. More...
 
virtual void ModifyDrawInfo (ref PlayerDrawInfo drawInfo)
 Allows you to modify the drawing parameters of the player before drawing begins. More...
 
virtual void ModifyDrawLayers (List< PlayerLayer > layers)
 Allows you to modify the drawing of the player. This is done by removing from, adding to, or rearranging the list, by setting some of the layers' visible field to false, etc. More...
 
virtual void ModifyHitByNPC (NPC npc, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that an NPC does to this player. More...
 
virtual void ModifyHitByProjectile (Projectile proj, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that a hostile projectile does to this player. More...
 
virtual void ModifyHitNPC (Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
 Allows you to modify the damage, knockback, etc., that this player does to an NPC by swinging a melee weapon. More...
 
virtual void ModifyHitNPCWithProj (Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 Allows you to modify the damage, knockback, etc., that a projectile created by this player does to an NPC. More...
 
virtual void ModifyHitPvp (Item item, Player target, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that a melee weapon swung by this player does to an opponent player. More...
 
virtual void ModifyHitPvpWithProj (Projectile proj, Player target, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that a projectile created by this player does to an opponent player. More...
 
virtual void ModifyManaCost (Item item, ref float reduce, ref float mult)
 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. More...
 
virtual bool ModifyNurseHeal (NPC nurse, ref int health, ref bool removeDebuffs, ref string chatText)
 Called on the Client 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. More...
 
virtual void ModifyNursePrice (NPC nurse, int health, bool removeDebuffs, ref int price)
 Called on the Client while the nurse chat is displayed and after ModifyNurseHeal. Allows custom pricing for Nurse services. See https://terraria.gamepedia.com/Nurse for the default pricing. More...
 
virtual void ModifyScreenPosition ()
 Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place. More...
 
virtual void ModifyWeaponDamage (Item item, ref float add, ref float mult)
 Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts). More...
 
virtual void ModifyWeaponDamage (Item item, ref float add, ref float mult, ref float flat)
 Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts). More...
 
virtual void ModifyZoom (ref float zoom)
 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. More...
 
virtual void NaturalLifeRegen (ref float regen)
 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. More...
 
virtual void OnConsumeAmmo (Item weapon, Item ammo)
 Allows you to make things happen when ammo is consumed. Called before the ammo stack is reduced. More...
 
virtual void OnConsumeMana (Item item, int manaConsumed)
 Allows you to make stuff happen when a player consumes mana on use of an item. More...
 
virtual void OnEnterWorld (Player player)
 Called on the LocalPlayer when that player enters the world. SP and Client. Only called on the player who is entering. 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. More...
 
virtual void OnHitAnything (float x, float y, Entity victim)
 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. More...
 
virtual void OnHitByNPC (NPC npc, int damage, bool crit)
 Allows you to create special effects when an NPC hits this player (for example, inflicting debuffs). More...
 
virtual void OnHitByProjectile (Projectile proj, int damage, bool crit)
 Allows you to create special effects when a hostile projectile hits this player. More...
 
virtual void OnHitNPC (Item item, NPC target, int damage, float knockback, bool crit)
 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). More...
 
virtual void OnHitNPCWithProj (Projectile proj, NPC target, int damage, float knockback, bool crit)
 Allows you to create special effects when a projectile created by this player hits an NPC (for example, inflicting debuffs). More...
 
virtual void OnHitPvp (Item item, Player target, int damage, bool crit)
 Allows you to create special effects when this player's melee weapon hits an opponent player. More...
 
virtual void OnHitPvpWithProj (Projectile proj, Player target, int damage, bool crit)
 Allows you to create special effects when a projectile created by this player hits an opponent player. More...
 
virtual void OnMissingMana (Item item, int neededMana)
 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. More...
 
virtual void OnRespawn (Player player)
 Called when a player respawns in the world. More...
 
virtual void PlayerConnect (Player player)
 Called on clients when a player connects. More...
 
virtual void PlayerDisconnect (Player player)
 Called when a player disconnects. More...
 
virtual void PostBuyItem (NPC vendor, Item[] shopInventory, Item item)
 Called whenever the player buys an item from an NPC. More...
 
virtual void PostHurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
 Allows you to make anything happen when the player takes damage. More...
 
virtual void PostItemCheck ()
 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. More...
 
virtual void PostNurseHeal (NPC nurse, int health, bool removeDebuffs, int price)
 Called on the Client after the player heals themselves with the Nurse NPC. More...
 
virtual void PostSavePlayer ()
 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. More...
 
virtual void PostSellItem (NPC vendor, Item[] shopInventory, Item item)
 Called whenever the player sells an item to an NPC. More...
 
virtual void PostUpdate ()
 This is called at the very end of the Player.Update method. Final general update tasks can be placed here. More...
 
virtual void PostUpdateBuffs ()
 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. More...
 
virtual void PostUpdateEquips ()
 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. More...
 
virtual void PostUpdateMiscEffects ()
 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. More...
 
virtual void PostUpdateRunSpeeds ()
 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. More...
 
virtual bool PreHurt (bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
 This hook is called before every time the player takes damage. The pvp parameter is whether the damage was from another player. The quiet parameter determines whether the damage will be communicated to the server. The damage, hitDirection, and crit parameters can be modified. Set the customDamage parameter to true if you want to use your own damage formula (this parameter will disable automatically subtracting the player's defense from the damage). Set the playSound parameter to false to disable the player's hurt sound, and the genGore parameter to false to disable the dust particles that spawn. (These are useful for creating your own sound or gore.) The deathText parameter can be modified to change the player's death message if the player dies. Return false to stop the player from taking damage. Returns true by default. More...
 
virtual bool PreItemCheck ()
 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. More...
 
virtual bool PreKill (double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
 This hook is called whenever the player is about to be killed after reaching 0 health. Set the playSound parameter to false to stop the death sound from playing. Set the genGore parameter to false to stop the gore and dust from being created. (These are useful for creating your own sound or gore.) Return false to stop the player from being killed. Only return false if you know what you are doing! Returns true by default. More...
 
virtual void PreSaveCustomData ()
 Currently never gets called, so this is useless. More...
 
virtual void PreSavePlayer ()
 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. More...
 
virtual void PreUpdate ()
 This is called at the beginning of every tick update for this player, after checking whether the player exists. More...
 
virtual void PreUpdateBuffs ()
 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). More...
 
virtual void PreUpdateMovement ()
 This is called right before modifying the player's position based on velocity. Use this to make direct changes to the velocity. More...
 
virtual void ProcessTriggers (TriggersSet triggersSet)
 Use this to check on hotkeys you have registered. While SetControls is set even while in text entry mode, this hook is only called during gameplay. More...
 
virtual void ReceiveCustomBiomes (BinaryReader reader)
 Allows you to do things with the custom biome information you send between client and server. More...
 
virtual void ResetEffects ()
 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. More...
 
virtual TagCompound Save ()
 Allows you to save custom data for this player. Returns null by default. More...
 
virtual void SendClientChanges (ModPlayer clientPlayer)
 Allows you to sync any information that has changed between the server and client. Here, you should check the information you have copied in the clientClone parameter; if they differ between this player and the clientPlayer parameter, then you should send that information using NetMessage.SendData or ModPacket.Send. More...
 
virtual void SendCustomBiomes (BinaryWriter writer)
 Allows you to send custom biome information between client and server. More...
 
virtual void SetControls ()
 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. More...
 
virtual void SetupStartInventory (IList< Item > items)
 
virtual void SetupStartInventory (IList< Item > items, bool mediumcoreDeath)
 Allows you to modify the inventory newly created players or killed mediumcore players will start with. To add items to the player's inventory, create a new Item, call its SetDefaults method for whatever ID you want, call its Prefix method with a parameter of -1 if you want to give it a random prefix, then add it to the items list parameter. More...
 
virtual bool ShiftClickSlot (Item[] inventory, int context, int slot)
 Called whenever the player shift-clicks an item slot. This can be used to override default clicking behavior (ie. selling, trashing, moving items). More...
 
virtual bool Shoot (Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
 This is called before this player's weapon creates a projectile. You can use it to create special effects, such as changing the speed, changing the initial position, and/or firing multiple projectiles. Return false to stop the game from shooting the default projectile (do this if you manually spawn your own projectile). Returns true by default. More...
 
virtual void SyncPlayer (int toWho, int fromWho, bool newPlayer)
 Allows you to sync information about this player between server and client. The toWho and fromWho parameters correspond to the remoteClient/toClient and ignoreClient arguments, respectively, of NetMessage.SendData/ModPacket.Send. The newPlayer parameter is whether or not the player is joining the server (it is true on the joining client). More...
 
bool TypeEquals (ModPlayer other)
 
virtual void UpdateAutopause ()
 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. More...
 
virtual void UpdateBadLifeRegen ()
 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. More...
 
virtual void UpdateBiomes ()
 Allows you to set biome variables in your ModPlayer class based on tile counts. More...
 
virtual void UpdateBiomeVisuals ()
 Allows you to create special visual effects in the area around the player. For example, the blood moon's red filter on the screen or the slime rain's falling slime in the background. You must create classes that override Terraria.Graphics.Shaders.ScreenShaderData or Terraria.Graphics.Effects.CustomSky, add them in your mod's Load hook, then call Player.ManageSpecialBiomeVisuals. See the ExampleMod if you do not have access to the source code. More...
 
virtual void UpdateDead ()
 Similar to UpdateDead, except this is only called when the player is dead. If this is called, then ResetEffects will not be called. More...
 
virtual void UpdateEquips (ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
 Called after Update Accessories. More...
 
virtual void UpdateLifeRegen ()
 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. More...
 
virtual void UpdateVanityAccessories ()
 This is called after VanillaUpdateVanityAccessory() in player.UpdateEquips() More...
 
virtual float UseTimeMultiplier (Item item)
 Allows you to multiply an item's regular use time. Returns 1f by default. Values greater than 1 increase the item speed. More...
 

Properties

virtual bool CloneNewInstances [get]
 Whether each player gets a ModPlayer by cloning the ModPlayer added to the Mod or by creating a new ModPlayer object with the same type as the ModPlayer added to the Mod. The accessor returns true by default. Return false if you want to assign fields through the constructor. More...
 
Mod mod [get, set]
 The mod that added this type of ModPlayer. More...
 
string Name [get, set]
 The name of this ModPlayer. Used for distinguishing between multiple ModPlayers added by a single Mod, in addition to the argument passed to Player.GetModPlayer. More...
 
Player player [get, set]
 The Player instance that this ModPlayer instance is attached to. More...
 

Detailed Description

A ModPlayer instance represents an extension of a Player instance. 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.

Definition at line 15 of file ModPlayer.cs.

Member Function Documentation

◆ AnglerQuestReward()

virtual void Terraria.ModLoader.ModPlayer.AnglerQuestReward ( float  rareMultiplier,
List< Item >  rewardItems 
)
virtual

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.

Parameters
rareMultiplier
rewardItems

Definition at line 772 of file ModPlayer.cs.

772 {
773 }

◆ Autoload()

virtual bool Terraria.ModLoader.ModPlayer.Autoload ( ref string  name)
virtual

Allows you to automatically add a ModPlayer instead of using Mod.AddPlayer. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this to either force or stop an autoload, or change the name that identifies this type of ModPlayer.

Parameters
name
Returns

Definition at line 67 of file ModPlayer.cs.

67 {
68 return mod.Properties.Autoload;
69 }
ModProperties Properties
Definition: Mod.cs:52
Mod mod
The mod that added this type of ModPlayer.
Definition: ModPlayer.cs:20
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.ModPlayer.mod, and Terraria.ModLoader.Mod.Properties.

Referenced by Terraria.ModLoader.Mod.AutoloadPlayer().

+ Here is the caller graph for this function:

◆ CanBeHitByNPC()

virtual bool Terraria.ModLoader.ModPlayer.CanBeHitByNPC ( NPC  npc,
ref int  cooldownSlot 
)
virtual

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 to use (-1, 0, or 1), and defaults to -1.

Parameters
npc
cooldownSlot
Returns

Definition at line 694 of file ModPlayer.cs.

694 {
695 return true;
696 }

◆ CanBeHitByProjectile()

virtual bool Terraria.ModLoader.ModPlayer.CanBeHitByProjectile ( Projectile  proj)
virtual

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.

Parameters
proj
Returns

Definition at line 721 of file ModPlayer.cs.

721 {
722 return true;
723 }

◆ CanBuyItem()

virtual bool Terraria.ModLoader.ModPlayer.CanBuyItem ( NPC  vendor,
Item[]  shopInventory,
Item  item 
)
virtual

Return false to prevent a transaction. Called before the transaction.

Parameters
vendorThe NPC vendor.
shopInventoryThe current inventory of the NPC shop.
itemThe item the player is attempting to buy.
Returns

Definition at line 903 of file ModPlayer.cs.

903 {
904 return true;
905 }

Referenced by Terraria.ModLoader.PlayerHooks.CanBuyItem().

+ Here is the caller graph for this function:

◆ CanHitNPC()

virtual ? bool Terraria.ModLoader.ModPlayer.CanHitNPC ( Item  item,
NPC  target 
)
virtual

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.

Parameters
item
target
Returns

Definition at line 569 of file ModPlayer.cs.

569 {
570 return null;
571 }

◆ CanHitNPCWithProj()

virtual ? bool Terraria.ModLoader.ModPlayer.CanHitNPCWithProj ( Projectile  proj,
NPC  target 
)
virtual

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.

Parameters
proj
target
Returns

Definition at line 601 of file ModPlayer.cs.

601 {
602 return null;
603 }

◆ CanHitPvp()

virtual bool Terraria.ModLoader.ModPlayer.CanHitPvp ( Item  item,
Player  target 
)
virtual

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.

Parameters
item
target
Returns

Definition at line 634 of file ModPlayer.cs.

634 {
635 return true;
636 }

◆ CanHitPvpWithProj()

virtual bool Terraria.ModLoader.ModPlayer.CanHitPvpWithProj ( Projectile  proj,
Player  target 
)
virtual

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.

Parameters
proj
target
Returns

Definition at line 664 of file ModPlayer.cs.

664 {
665 return true;
666 }

◆ CanSellItem()

virtual bool Terraria.ModLoader.ModPlayer.CanSellItem ( NPC  vendor,
Item[]  shopInventory,
Item  item 
)
virtual

Return false to prevent a transaction. Called before the transaction.

Parameters
vendorThe NPC vendor.
shopInventoryThe current inventory of the NPC shop.
itemThe item the player is attempting to sell.
Returns

Definition at line 883 of file ModPlayer.cs.

883 {
884 return true;
885 }

Referenced by Terraria.ModLoader.PlayerHooks.CanSellItem().

+ Here is the caller graph for this function:

◆ CatchFish()

virtual void Terraria.ModLoader.ModPlayer.CatchFish ( Item  fishingRod,
Item  bait,
int  power,
int  liquidType,
int  poolSize,
int  worldLayer,
int  questFish,
ref int  caughtType,
ref bool  junk 
)
virtual

Allows you to change the item the player gains from catching a fish. The fishingRod and bait parameters refer to the said items in the player's inventory. The liquidType parameter is 0 if the player is fishing in water, 1 for lava, and 2 for honey. The poolSize parameter is the tile size of the pool the player is fishing in. The worldLayer parameter is 0 if the player is in the sky, 1 if the player is on the surface, 2 if the player is underground, 3 if the player is in the caverns, and 4 if the player is in the underworld. The questFish parameter is the item ID for the day's Angler quest. Modify the caughtType parameter to change the item the player catches. The junk parameter is whether the player catches junk; you can set this to true if you make the player catch a junk item, and is mostly used to pass information (has no effect on the game).

Parameters
fishingRod
bait
power
liquidType
poolSize
worldLayer
questFish
caughtType
junk

Definition at line 755 of file ModPlayer.cs.

755 {
756 }

◆ clientClone()

virtual void Terraria.ModLoader.ModPlayer.clientClone ( ModPlayer  clientClone)
virtual

Allows you to copy information about this player to the clientClone parameter. You should copy information that you intend to sync between server and client. This hook is called in the Player.clientClone method. See SendClientChanges for more info.

Parameters
clientClone

Definition at line 188 of file ModPlayer.cs.

188 {
189 }

◆ ConsumeAmmo()

virtual bool Terraria.ModLoader.ModPlayer.ConsumeAmmo ( Item  weapon,
Item  ammo 
)
virtual

Whether or not ammo will be consumed upon usage. Return false to stop the ammo from being depleted. Returns true by default. If false is returned, the OnConsumeAmmo hook is never called.

Parameters
weapon
ammo
Returns

Definition at line 517 of file ModPlayer.cs.

517 {
518 return true;
519 }

◆ CopyCustomBiomesTo()

virtual void Terraria.ModLoader.ModPlayer.CopyCustomBiomesTo ( Player  other)
virtual

In this hook, you should copy the custom biome variables from this player to the other player parameter. This hook is used to help with client/server syncing.

Parameters
other

Definition at line 161 of file ModPlayer.cs.

161 {
162 }

◆ CustomBiomesMatch()

virtual bool Terraria.ModLoader.ModPlayer.CustomBiomesMatch ( Player  other)
virtual

Whether or not this player and the other player parameter have the same custom biome variables. This hook is used to help with client/server syncing. Returns true by default.

Parameters
other
Returns

Definition at line 153 of file ModPlayer.cs.

153 {
154 return true;
155 }

◆ DrawEffects()

virtual void Terraria.ModLoader.ModPlayer.DrawEffects ( PlayerDrawInfo  drawInfo,
ref float  r,
ref float  g,
ref float  b,
ref float  a,
ref bool  fullBright 
)
virtual

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. Note that the fullBright parameter only works if r, g, b, and/or a is not equal to 1. Make sure to add the indexes of any dusts you create to Main.playerDrawDust, and the indexes of any gore you create to Main.playerDrawGore.

Parameters
drawInfo
r
g
b
a
fullBright

Definition at line 791 of file ModPlayer.cs.

791 {
792 }

◆ FrameEffects()

virtual void Terraria.ModLoader.ModPlayer.FrameEffects ( )
virtual

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.

Definition at line 320 of file ModPlayer.cs.

320 {
321 }

◆ GetDyeTraderReward()

virtual void Terraria.ModLoader.ModPlayer.GetDyeTraderReward ( List< int >  rewardPool)
virtual

Allows you to modify what items are possible for the player to earn when giving a Strange Plant to the Dye Trader.

Parameters
rewardPool

Definition at line 779 of file ModPlayer.cs.

779 {
780 }

◆ GetFishingLevel()

virtual void Terraria.ModLoader.ModPlayer.GetFishingLevel ( Item  fishingRod,
Item  bait,
ref int  fishingLevel 
)
virtual

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.

Parameters
fishingRod
bait
fishingLevel

Definition at line 764 of file ModPlayer.cs.

764 {
765 }

◆ GetHealLife()

virtual void Terraria.ModLoader.ModPlayer.GetHealLife ( Item  item,
bool  quickHeal,
ref int  healValue 
)
virtual

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.

Parameters
itemThe item.
quickHealWhether the item is being used through quick heal or not.
healValueThe amount of life being healed.

Definition at line 426 of file ModPlayer.cs.

426 {
427 }

◆ GetHealMana()

virtual void Terraria.ModLoader.ModPlayer.GetHealMana ( Item  item,
bool  quickHeal,
ref int  healValue 
)
virtual

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.

Parameters
itemThe item.
quickHealWhether the item is being used through quick heal or not.
healValueThe amount of mana being healed.

Definition at line 435 of file ModPlayer.cs.

435 {
436 }

◆ GetMapBackgroundImage()

virtual Texture2D Terraria.ModLoader.ModPlayer.GetMapBackgroundImage ( )
virtual

Allows you to change the background that displays when viewing the map. Return null if you do not want to change the background. Returns null by default.

Returns

Definition at line 211 of file ModPlayer.cs.

211 {
212 return null;
213 }

◆ GetWeaponCrit()

virtual void Terraria.ModLoader.ModPlayer.GetWeaponCrit ( Item  item,
ref int  crit 
)
virtual

Allows you to temporarily modify a weapon's crit chance based on player buffs, etc.

Parameters
itemThe item
critThe crit chance, ranging from 0 to 100

Definition at line 507 of file ModPlayer.cs.

507 {
508 }

◆ GetWeaponDamage()

virtual void Terraria.ModLoader.ModPlayer.GetWeaponDamage ( Item  item,
ref int  damage 
)
virtual

Allows you to temporarily modify a weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts).

Parameters
item
damage

Definition at line 471 of file ModPlayer.cs.

471 {
472 }

◆ GetWeaponKnockback()

virtual void Terraria.ModLoader.ModPlayer.GetWeaponKnockback ( Item  item,
ref float  knockback 
)
virtual

Allows you to temporarily modify a weapon's knockback based on player buffs, etc. This allows you to customize knockback beyond the Player class's limited fields.

Parameters
item
knockback

Definition at line 499 of file ModPlayer.cs.

499 {
500 }

◆ Hurt()

virtual void Terraria.ModLoader.ModPlayer.Hurt ( bool  pvp,
bool  quiet,
double  damage,
int  hitDirection,
bool  crit 
)
virtual

Allows you to make anything happen right before damage is subtracted from the player's health.

Parameters
pvp
quiet
damage
hitDirection
crit

Definition at line 349 of file ModPlayer.cs.

349 {
350 }

◆ Initialize()

virtual void Terraria.ModLoader.ModPlayer.Initialize ( )
virtual

Called whenever the player is loaded (on the player selection screen). This can be used to initialize data structures, etc.

Definition at line 74 of file ModPlayer.cs.

74 {
75 }

◆ Kill()

virtual void Terraria.ModLoader.ModPlayer.Kill ( double  damage,
int  hitDirection,
bool  pvp,
PlayerDeathReason  damageSource 
)
virtual

Allows you to make anything happen when the player dies.

Parameters
damage
hitDirection
pvp
damageSource

Definition at line 385 of file ModPlayer.cs.

385 {
386 }

◆ Load()

virtual void Terraria.ModLoader.ModPlayer.Load ( TagCompound  tag)
virtual

Allows you to load custom data you have saved for this player.

Parameters
tag

Definition at line 107 of file ModPlayer.cs.

107 {
108 }

◆ LoadLegacy()

virtual void Terraria.ModLoader.ModPlayer.LoadLegacy ( BinaryReader  reader)
virtual

Allows you to load pre-v0.9 custom data you have saved for this player.

Parameters
reader

Definition at line 114 of file ModPlayer.cs.

114 {
115 }

◆ MeleeEffects()

virtual void Terraria.ModLoader.ModPlayer.MeleeEffects ( Item  item,
Rectangle  hitbox 
)
virtual

Allows you to give this player's melee weapon special effects, such as creating light or dust.

Parameters
item
hitbox

Definition at line 551 of file ModPlayer.cs.

551 {
552 }

◆ MeleeSpeedMultiplier()

virtual float Terraria.ModLoader.ModPlayer.MeleeSpeedMultiplier ( Item  item)
virtual

Allows you to multiply an item's regular melee speed. Returns 1f by default. Values greater than 1 increase the item speed.

Parameters
itemThe item.
Returns
The amount you wish to multiply with.

Definition at line 416 of file ModPlayer.cs.

416 {
417 return 1f;
418 }

◆ ModifyDrawHeadLayers()

virtual void Terraria.ModLoader.ModPlayer.ModifyDrawHeadLayers ( List< PlayerHeadLayer layers)
virtual

Allows you to modify the drawing of the player head on the minimap. This is done by removing from, adding to, or rearranging the list, by setting some of the layers' visible field to false, etc.

Parameters
layers

Definition at line 812 of file ModPlayer.cs.

812 {
813 }

◆ ModifyDrawInfo()

virtual void Terraria.ModLoader.ModPlayer.ModifyDrawInfo ( ref PlayerDrawInfo  drawInfo)
virtual

Allows you to modify the drawing parameters of the player before drawing begins.

Parameters
drawInfo

Definition at line 798 of file ModPlayer.cs.

798 {
799 }

Referenced by Terraria.ModLoader.PlayerHooks.ModifyDrawInfo().

+ Here is the caller graph for this function:

◆ ModifyDrawLayers()

virtual void Terraria.ModLoader.ModPlayer.ModifyDrawLayers ( List< PlayerLayer layers)
virtual

Allows you to modify the drawing of the player. This is done by removing from, adding to, or rearranging the list, by setting some of the layers' visible field to false, etc.

Parameters
layers

Definition at line 805 of file ModPlayer.cs.

805 {
806 }

◆ ModifyHitByNPC()

virtual void Terraria.ModLoader.ModPlayer.ModifyHitByNPC ( NPC  npc,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that an NPC does to this player.

Parameters
npc
damage
crit

Definition at line 704 of file ModPlayer.cs.

704 {
705 }

◆ ModifyHitByProjectile()

virtual void Terraria.ModLoader.ModPlayer.ModifyHitByProjectile ( Projectile  proj,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that a hostile projectile does to this player.

Parameters
proj
damage
crit

Definition at line 731 of file ModPlayer.cs.

731 {
732 }

◆ ModifyHitNPC()

virtual void Terraria.ModLoader.ModPlayer.ModifyHitNPC ( Item  item,
NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit 
)
virtual

Allows you to modify the damage, knockback, etc., that this player does to an NPC by swinging a melee weapon.

Parameters
item
target
damage
knockback
crit

Definition at line 581 of file ModPlayer.cs.

581 {
582 }

◆ ModifyHitNPCWithProj()

virtual void Terraria.ModLoader.ModPlayer.ModifyHitNPCWithProj ( Projectile  proj,
NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit,
ref int  hitDirection 
)
virtual

Allows you to modify the damage, knockback, etc., that a projectile created by this player does to an NPC.

Parameters
proj
target
damage
knockback
crit
hitDirection

Definition at line 614 of file ModPlayer.cs.

614 {
615 }

◆ ModifyHitPvp()

virtual void Terraria.ModLoader.ModPlayer.ModifyHitPvp ( Item  item,
Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that a melee weapon swung by this player does to an opponent player.

Parameters
item
target
damage
crit

Definition at line 645 of file ModPlayer.cs.

645 {
646 }

◆ ModifyHitPvpWithProj()

virtual void Terraria.ModLoader.ModPlayer.ModifyHitPvpWithProj ( Projectile  proj,
Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that a projectile created by this player does to an opponent player.

Parameters
proj
target
damage
crit

Definition at line 675 of file ModPlayer.cs.

675 {
676 }

◆ ModifyManaCost()

virtual void Terraria.ModLoader.ModPlayer.ModifyManaCost ( Item  item,
ref float  reduce,
ref float  mult 
)
virtual

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.

Parameters
itemThe item being used.
reduceUsed for decreasingly stacking buffs (most common). Only ever use -= on this field.
multUse to directly multiply the item's effective mana cost. Good for debuffs, or things which should stack separately (eg meteor armor set bonus).

Definition at line 444 of file ModPlayer.cs.

444 {
445 }

◆ ModifyNurseHeal()

virtual bool Terraria.ModLoader.ModPlayer.ModifyNurseHeal ( NPC  nurse,
ref int  health,
ref bool  removeDebuffs,
ref string  chatText 
)
virtual

Called on the Client 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.

Parameters
nurseThe Nurse NPC instance.
healthHow much health the player gains.
removeDebuffsIf set to false, debuffs will not be healed.
chatTextSet this to the Nurse chat text that will display if healing is prevented.
Returns
True by default. False to prevent nurse services.

Definition at line 915 of file ModPlayer.cs.

915 {
916 return true;
917 }

◆ ModifyNursePrice()

virtual void Terraria.ModLoader.ModPlayer.ModifyNursePrice ( NPC  nurse,
int  health,
bool  removeDebuffs,
ref int  price 
)
virtual

Called on the Client while the nurse chat is displayed and after ModifyNurseHeal. Allows custom pricing for Nurse services. See https://terraria.gamepedia.com/Nurse for the default pricing.

Parameters
nurseThe Nurse NPC instance.
healthHow much health the player gains.
removeDebuffsWhether or not debuffs will be healed.
price

Definition at line 926 of file ModPlayer.cs.

926 {
927 }

◆ ModifyScreenPosition()

virtual void Terraria.ModLoader.ModPlayer.ModifyScreenPosition ( )
virtual

Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place.

Definition at line 818 of file ModPlayer.cs.

818 {
819 }

◆ ModifyWeaponDamage() [1/2]

virtual void Terraria.ModLoader.ModPlayer.ModifyWeaponDamage ( Item  item,
ref float  add,
ref float  mult 
)
virtual

Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts).

Parameters
itemThe item being used
addUsed for additively stacking buffs (most common). Only ever use += on this field.
multUse to directly multiply the player's effective damage. Good for debuffs, or things which should stack separately (eg ammo type buffs)

Definition at line 481 of file ModPlayer.cs.

481 {
482 }

◆ ModifyWeaponDamage() [2/2]

virtual void Terraria.ModLoader.ModPlayer.ModifyWeaponDamage ( Item  item,
ref float  add,
ref float  mult,
ref float  flat 
)
virtual

Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts).

Parameters
itemThe item being used
addUsed for additively stacking buffs (most common). Only ever use += on this field. Things with effects like "5% increased MyDamageClass damage" would use this: add += 0.05f
multUse to directly multiply the player's effective damage. Good for debuffs, or things which should stack separately (eg ammo type buffs)
flatThis is a flat damage bonus that will be added after add and mult are applied. It facilitates effects like "4 more damage from weapons"

Definition at line 491 of file ModPlayer.cs.

491 {
492 }

◆ ModifyZoom()

virtual void Terraria.ModLoader.ModPlayer.ModifyZoom ( ref float  zoom)
virtual

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.

Parameters
zoom

Definition at line 825 of file ModPlayer.cs.

825 {
826 }

◆ NaturalLifeRegen()

virtual void Terraria.ModLoader.ModPlayer.NaturalLifeRegen ( ref float  regen)
virtual

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.

Parameters
regen

Definition at line 231 of file ModPlayer.cs.

231 {
232 }

◆ OnConsumeAmmo()

virtual void Terraria.ModLoader.ModPlayer.OnConsumeAmmo ( Item  weapon,
Item  ammo 
)
virtual

Allows you to make things happen when ammo is consumed. Called before the ammo stack is reduced.

Parameters
weapon
ammo
Returns

Definition at line 528 of file ModPlayer.cs.

528 {
529 }

◆ OnConsumeMana()

virtual void Terraria.ModLoader.ModPlayer.OnConsumeMana ( Item  item,
int  manaConsumed 
)
virtual

Allows you to make stuff happen when a player consumes mana on use of an item.

Parameters
itemThe item being used.
manaConsumedThe mana consumed from the player.

Definition at line 462 of file ModPlayer.cs.

462 {
463 }

◆ OnEnterWorld()

virtual void Terraria.ModLoader.ModPlayer.OnEnterWorld ( Player  player)
virtual

Called on the LocalPlayer when that player enters the world. SP and Client. Only called on the player who is entering. 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.

Parameters
playerThe player that entered the world.

Definition at line 846 of file ModPlayer.cs.

846 {
847 }

◆ OnHitAnything()

virtual void Terraria.ModLoader.ModPlayer.OnHitAnything ( float  x,
float  y,
Entity  victim 
)
virtual

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.

Parameters
x
y
victim

Definition at line 560 of file ModPlayer.cs.

560 {
561 }

◆ OnHitByNPC()

virtual void Terraria.ModLoader.ModPlayer.OnHitByNPC ( NPC  npc,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when an NPC hits this player (for example, inflicting debuffs).

Parameters
npc
damage
crit

Definition at line 713 of file ModPlayer.cs.

713 {
714 }

◆ OnHitByProjectile()

virtual void Terraria.ModLoader.ModPlayer.OnHitByProjectile ( Projectile  proj,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when a hostile projectile hits this player.

Parameters
proj
damage
crit

Definition at line 740 of file ModPlayer.cs.

740 {
741 }

◆ OnHitNPC()

virtual void Terraria.ModLoader.ModPlayer.OnHitNPC ( Item  item,
NPC  target,
int  damage,
float  knockback,
bool  crit 
)
virtual

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).

Parameters
item
target
damage
knockback
crit

Definition at line 592 of file ModPlayer.cs.

592 {
593 }

◆ OnHitNPCWithProj()

virtual void Terraria.ModLoader.ModPlayer.OnHitNPCWithProj ( Projectile  proj,
NPC  target,
int  damage,
float  knockback,
bool  crit 
)
virtual

Allows you to create special effects when a projectile created by this player hits an NPC (for example, inflicting debuffs).

Parameters
proj
target
damage
knockback
crit

Definition at line 625 of file ModPlayer.cs.

625 {
626 }

◆ OnHitPvp()

virtual void Terraria.ModLoader.ModPlayer.OnHitPvp ( Item  item,
Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when this player's melee weapon hits an opponent player.

Parameters
item
target
damage
crit

Definition at line 655 of file ModPlayer.cs.

655 {
656 }

◆ OnHitPvpWithProj()

virtual void Terraria.ModLoader.ModPlayer.OnHitPvpWithProj ( Projectile  proj,
Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when a projectile created by this player hits an opponent player.

Parameters
proj
target
damage
crit

Definition at line 685 of file ModPlayer.cs.

685 {
686 }

◆ OnMissingMana()

virtual void Terraria.ModLoader.ModPlayer.OnMissingMana ( Item  item,
int  neededMana 
)
virtual

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.

Parameters
itemThe item being used.
neededManaThe mana needed to use the item.

Definition at line 454 of file ModPlayer.cs.

454 {
455 }

◆ OnRespawn()

virtual void Terraria.ModLoader.ModPlayer.OnRespawn ( Player  player)
virtual

Called when a player respawns in the world.

Parameters
playerThe player that respawns

Definition at line 853 of file ModPlayer.cs.

853 {
854 }

◆ PlayerConnect()

virtual void Terraria.ModLoader.ModPlayer.PlayerConnect ( Player  player)
virtual

Called on clients when a player connects.

Parameters
playerThe player that connected.

Definition at line 832 of file ModPlayer.cs.

832 {
833 }

◆ PlayerDisconnect()

virtual void Terraria.ModLoader.ModPlayer.PlayerDisconnect ( Player  player)
virtual

Called when a player disconnects.

Parameters
playerThe player that disconnected.

Definition at line 839 of file ModPlayer.cs.

839 {
840 }

◆ PostBuyItem()

virtual void Terraria.ModLoader.ModPlayer.PostBuyItem ( NPC  vendor,
Item[]  shopInventory,
Item  item 
)
virtual

Called whenever the player buys an item from an NPC.

Parameters
vendorThe NPC vendor.
shopInventoryThe current inventory of the NPC shop.
itemThe item the player just purchased.

Definition at line 893 of file ModPlayer.cs.

893 {
894 }

Referenced by Terraria.ModLoader.PlayerHooks.PostBuyItem().

+ Here is the caller graph for this function:

◆ PostHurt()

virtual void Terraria.ModLoader.ModPlayer.PostHurt ( bool  pvp,
bool  quiet,
double  damage,
int  hitDirection,
bool  crit 
)
virtual

Allows you to make anything happen when the player takes damage.

Parameters
pvp
quiet
damage
hitDirection
crit

Definition at line 360 of file ModPlayer.cs.

360 {
361 }

◆ PostItemCheck()

virtual void Terraria.ModLoader.ModPlayer.PostItemCheck ( )
virtual

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.

Definition at line 399 of file ModPlayer.cs.

399 {
400 }

◆ PostNurseHeal()

virtual void Terraria.ModLoader.ModPlayer.PostNurseHeal ( NPC  nurse,
int  health,
bool  removeDebuffs,
int  price 
)
virtual

Called on the Client after the player heals themselves with the Nurse NPC.

Parameters
nurseThe Nurse npc providing the heal.
healthHow much health the player gained.

///

Parameters
removeDebuffsWhether or not debuffs were healed.
priceThe price the player paid in copper coins.

Definition at line 936 of file ModPlayer.cs.

936 {
937 }

Referenced by Terraria.ModLoader.PlayerHooks.PostNurseHeal().

+ Here is the caller graph for this function:

◆ PostSavePlayer()

virtual void Terraria.ModLoader.ModPlayer.PostSavePlayer ( )
virtual

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.

Definition at line 139 of file ModPlayer.cs.

139 {
140 }

◆ PostSellItem()

virtual void Terraria.ModLoader.ModPlayer.PostSellItem ( NPC  vendor,
Item[]  shopInventory,
Item  item 
)
virtual

Called whenever the player sells an item to an NPC.

Parameters
vendorThe NPC vendor.
shopInventoryThe current inventory of the NPC shop.
itemThe item the player just sold.

Definition at line 873 of file ModPlayer.cs.

873 {
874 }

Referenced by Terraria.ModLoader.PlayerHooks.PostSellItem().

+ Here is the caller graph for this function:

◆ PostUpdate()

virtual void Terraria.ModLoader.ModPlayer.PostUpdate ( )
virtual

This is called at the very end of the Player.Update method. Final general update tasks can be placed here.

Definition at line 308 of file ModPlayer.cs.

308 {
309 }

◆ PostUpdateBuffs()

virtual void Terraria.ModLoader.ModPlayer.PostUpdateBuffs ( )
virtual

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.

Definition at line 269 of file ModPlayer.cs.

269 {
270 }

◆ PostUpdateEquips()

virtual void Terraria.ModLoader.ModPlayer.PostUpdateEquips ( )
virtual

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.

Definition at line 284 of file ModPlayer.cs.

284 {
285 }

◆ PostUpdateMiscEffects()

virtual void Terraria.ModLoader.ModPlayer.PostUpdateMiscEffects ( )
virtual

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.

Definition at line 290 of file ModPlayer.cs.

290 {
291 }

◆ PostUpdateRunSpeeds()

virtual void Terraria.ModLoader.ModPlayer.PostUpdateRunSpeeds ( )
virtual

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.

Definition at line 296 of file ModPlayer.cs.

296 {
297 }

◆ PreHurt()

virtual bool Terraria.ModLoader.ModPlayer.PreHurt ( bool  pvp,
bool  quiet,
ref int  damage,
ref int  hitDirection,
ref bool  crit,
ref bool  customDamage,
ref bool  playSound,
ref bool  genGore,
ref PlayerDeathReason  damageSource 
)
virtual

This hook is called before every time the player takes damage. The pvp parameter is whether the damage was from another player. The quiet parameter determines whether the damage will be communicated to the server. The damage, hitDirection, and crit parameters can be modified. Set the customDamage parameter to true if you want to use your own damage formula (this parameter will disable automatically subtracting the player's defense from the damage). Set the playSound parameter to false to disable the player's hurt sound, and the genGore parameter to false to disable the dust particles that spawn. (These are useful for creating your own sound or gore.) The deathText parameter can be modified to change the player's death message if the player dies. Return false to stop the player from taking damage. Returns true by default.

Parameters
pvp
quiet
damage
hitDirection
crit
customDamage
playSound
genGore
damageSource
Returns

Definition at line 336 of file ModPlayer.cs.

337 {
338 return true;
339 }

◆ PreItemCheck()

virtual bool Terraria.ModLoader.ModPlayer.PreItemCheck ( )
virtual

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.

Returns

Definition at line 392 of file ModPlayer.cs.

392 {
393 return true;
394 }

◆ PreKill()

virtual bool Terraria.ModLoader.ModPlayer.PreKill ( double  damage,
int  hitDirection,
bool  pvp,
ref bool  playSound,
ref bool  genGore,
ref PlayerDeathReason  damageSource 
)
virtual

This hook is called whenever the player is about to be killed after reaching 0 health. Set the playSound parameter to false to stop the death sound from playing. Set the genGore parameter to false to stop the gore and dust from being created. (These are useful for creating your own sound or gore.) Return false to stop the player from being killed. Only return false if you know what you are doing! Returns true by default.

Parameters
damage
hitDirection
pvp
playSound
genGore
damageSource
Returns

Definition at line 373 of file ModPlayer.cs.

374 {
375 return true;
376 }

◆ PreSaveCustomData()

virtual void Terraria.ModLoader.ModPlayer.PreSaveCustomData ( )
virtual

Currently never gets called, so this is useless.

Definition at line 92 of file ModPlayer.cs.

92 {
93 }

◆ PreSavePlayer()

virtual void Terraria.ModLoader.ModPlayer.PreSavePlayer ( )
virtual

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.

Definition at line 133 of file ModPlayer.cs.

133 {
134 }

◆ PreUpdate()

virtual void Terraria.ModLoader.ModPlayer.PreUpdate ( )
virtual

This is called at the beginning of every tick update for this player, after checking whether the player exists.

Definition at line 244 of file ModPlayer.cs.

244 {
245 }

◆ PreUpdateBuffs()

virtual void Terraria.ModLoader.ModPlayer.PreUpdateBuffs ( )
virtual

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).

Definition at line 263 of file ModPlayer.cs.

263 {
264 }

◆ PreUpdateMovement()

virtual void Terraria.ModLoader.ModPlayer.PreUpdateMovement ( )
virtual

This is called right before modifying the player's position based on velocity. Use this to make direct changes to the velocity.

Definition at line 302 of file ModPlayer.cs.

302 {
303 }

◆ ProcessTriggers()

virtual void Terraria.ModLoader.ModPlayer.ProcessTriggers ( TriggersSet  triggersSet)
virtual

Use this to check on hotkeys you have registered. While SetControls is set even while in text entry mode, this hook is only called during gameplay.

Parameters
triggersSet

Definition at line 251 of file ModPlayer.cs.

251 {
252 }

◆ ReceiveCustomBiomes()

virtual void Terraria.ModLoader.ModPlayer.ReceiveCustomBiomes ( BinaryReader  reader)
virtual

Allows you to do things with the custom biome information you send between client and server.

Parameters
reader

Definition at line 175 of file ModPlayer.cs.

175 {
176 }

Referenced by Terraria.ModLoader.PlayerHooks.ReceiveCustomBiomes().

+ Here is the caller graph for this function:

◆ ResetEffects()

virtual void Terraria.ModLoader.ModPlayer.ResetEffects ( )
virtual

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.

Definition at line 80 of file ModPlayer.cs.

80 {
81 }

◆ Save()

virtual TagCompound Terraria.ModLoader.ModPlayer.Save ( )
virtual

Allows you to save custom data for this player. Returns null by default.

Returns

Definition at line 99 of file ModPlayer.cs.

99 {
100 return null;
101 }

◆ SendClientChanges()

virtual void Terraria.ModLoader.ModPlayer.SendClientChanges ( ModPlayer  clientPlayer)
virtual

Allows you to sync any information that has changed between the server and client. Here, you should check the information you have copied in the clientClone parameter; if they differ between this player and the clientPlayer parameter, then you should send that information using NetMessage.SendData or ModPacket.Send.

Parameters
clientPlayer

Definition at line 204 of file ModPlayer.cs.

204 {
205 }

◆ SendCustomBiomes()

virtual void Terraria.ModLoader.ModPlayer.SendCustomBiomes ( BinaryWriter  writer)
virtual

Allows you to send custom biome information between client and server.

Parameters
writer

Definition at line 168 of file ModPlayer.cs.

168 {
169 }

Referenced by Terraria.ModLoader.PlayerHooks.SendCustomBiomes().

+ Here is the caller graph for this function:

◆ SetControls()

virtual void Terraria.ModLoader.ModPlayer.SetControls ( )
virtual

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.

Definition at line 257 of file ModPlayer.cs.

257 {
258 }

◆ SetupStartInventory() [1/2]

virtual void Terraria.ModLoader.ModPlayer.SetupStartInventory ( IList< Item >  items)
virtual

Definition at line 127 of file ModPlayer.cs.

127 {
128 }

◆ SetupStartInventory() [2/2]

virtual void Terraria.ModLoader.ModPlayer.SetupStartInventory ( IList< Item >  items,
bool  mediumcoreDeath 
)
virtual

Allows you to modify the inventory newly created players or killed mediumcore players will start with. To add items to the player's inventory, create a new Item, call its SetDefaults method for whatever ID you want, call its Prefix method with a parameter of -1 if you want to give it a random prefix, then add it to the items list parameter.

Parameters
items
mediumcoreDeathIf true, the inventory is being setup for a character that dies in mediumcore rather than a newly created player.

Definition at line 122 of file ModPlayer.cs.

122 {
123 }

◆ ShiftClickSlot()

virtual bool Terraria.ModLoader.ModPlayer.ShiftClickSlot ( Item[]  inventory,
int  context,
int  slot 
)
virtual

Called whenever the player shift-clicks an item slot. This can be used to override default clicking behavior (ie. selling, trashing, moving items).

Parameters
inventoryThe array of items the slot is part of.
contextThe Terraria.UI.ItemSlot.Context of the inventory.
slotThe index in the inventory of the clicked slot.
Returns
Whether or not to block the default code (sell, trash, move, etc) from running. Returns false by default.

Definition at line 863 of file ModPlayer.cs.

863 {
864 return false;
865 }

◆ Shoot()

virtual bool Terraria.ModLoader.ModPlayer.Shoot ( Item  item,
ref Vector2  position,
ref float  speedX,
ref float  speedY,
ref int  type,
ref int  damage,
ref float  knockBack 
)
virtual

This is called before this player's weapon creates a projectile. You can use it to create special effects, such as changing the speed, changing the initial position, and/or firing multiple projectiles. Return false to stop the game from shooting the default projectile (do this if you manually spawn your own projectile). Returns true by default.

Parameters
item
position
speedX
speedY
type
damage
knockBack
Returns

Definition at line 542 of file ModPlayer.cs.

542 {
543 return true;
544 }

◆ SyncPlayer()

virtual void Terraria.ModLoader.ModPlayer.SyncPlayer ( int  toWho,
int  fromWho,
bool  newPlayer 
)
virtual

Allows you to sync information about this player between server and client. The toWho and fromWho parameters correspond to the remoteClient/toClient and ignoreClient arguments, respectively, of NetMessage.SendData/ModPacket.Send. The newPlayer parameter is whether or not the player is joining the server (it is true on the joining client).

Parameters
toWho
fromWho
newPlayer

Definition at line 197 of file ModPlayer.cs.

197 {
198 }

◆ TypeEquals()

bool Terraria.ModLoader.ModPlayer.TypeEquals ( ModPlayer  other)

Definition at line 53 of file ModPlayer.cs.

53 {
54 return mod == other.mod && Name == other.Name;
55 }
string Name
The name of this ModPlayer. Used for distinguishing between multiple ModPlayers added by a single Mod...
Definition: ModPlayer.cs:28

References Terraria.ModLoader.ModPlayer.mod, and Terraria.ModLoader.ModPlayer.Name.

◆ UpdateAutopause()

virtual void Terraria.ModLoader.ModPlayer.UpdateAutopause ( )
virtual

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.

Definition at line 238 of file ModPlayer.cs.

238 {
239 }

◆ UpdateBadLifeRegen()

virtual void Terraria.ModLoader.ModPlayer.UpdateBadLifeRegen ( )
virtual

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.

Definition at line 218 of file ModPlayer.cs.

218 {
219 }

◆ UpdateBiomes()

virtual void Terraria.ModLoader.ModPlayer.UpdateBiomes ( )
virtual

Allows you to set biome variables in your ModPlayer class based on tile counts.

Definition at line 145 of file ModPlayer.cs.

145 {
146 }

◆ UpdateBiomeVisuals()

virtual void Terraria.ModLoader.ModPlayer.UpdateBiomeVisuals ( )
virtual

Allows you to create special visual effects in the area around the player. For example, the blood moon's red filter on the screen or the slime rain's falling slime in the background. You must create classes that override Terraria.Graphics.Shaders.ScreenShaderData or Terraria.Graphics.Effects.CustomSky, add them in your mod's Load hook, then call Player.ManageSpecialBiomeVisuals. See the ExampleMod if you do not have access to the source code.

Definition at line 181 of file ModPlayer.cs.

181 {
182 }

◆ UpdateDead()

virtual void Terraria.ModLoader.ModPlayer.UpdateDead ( )
virtual

Similar to UpdateDead, except this is only called when the player is dead. If this is called, then ResetEffects will not be called.

Definition at line 86 of file ModPlayer.cs.

86 {
87 }

◆ UpdateEquips()

virtual void Terraria.ModLoader.ModPlayer.UpdateEquips ( ref bool  wallSpeedBuff,
ref bool  tileSpeedBuff,
ref bool  tileRangeBuff 
)
virtual

Called after Update Accessories.

Parameters
wallSpeedBuff
tileSpeedBuff
tileRangeBuff

Definition at line 278 of file ModPlayer.cs.

278 {
279 }

◆ UpdateLifeRegen()

virtual void Terraria.ModLoader.ModPlayer.UpdateLifeRegen ( )
virtual

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.

Definition at line 224 of file ModPlayer.cs.

224 {
225 }

◆ UpdateVanityAccessories()

virtual void Terraria.ModLoader.ModPlayer.UpdateVanityAccessories ( )
virtual

This is called after VanillaUpdateVanityAccessory() in player.UpdateEquips()

Definition at line 314 of file ModPlayer.cs.

314 {
315 }

◆ UseTimeMultiplier()

virtual float Terraria.ModLoader.ModPlayer.UseTimeMultiplier ( Item  item)
virtual

Allows you to multiply an item's regular use time. Returns 1f by default. Values greater than 1 increase the item speed.

Parameters
itemThe item.
Returns
The amount you wish to multiply with.

Definition at line 407 of file ModPlayer.cs.

407 {
408 return 1f;
409 }

Property Documentation

◆ CloneNewInstances

virtual bool Terraria.ModLoader.ModPlayer.CloneNewInstances
get

Whether each player gets a ModPlayer by cloning the ModPlayer added to the Mod or by creating a new ModPlayer object with the same type as the ModPlayer added to the Mod. The accessor returns true by default. Return false if you want to assign fields through the constructor.

Definition at line 60 of file ModPlayer.cs.

◆ mod

Mod Terraria.ModLoader.ModPlayer.mod
getset

The mod that added this type of ModPlayer.

Definition at line 20 of file ModPlayer.cs.

20 {
21 get;
22 internal set;
23 }

Referenced by Terraria.ModLoader.ModPlayer.Autoload(), Terraria.ModLoader.PlayerHooks.SendCustomBiomes(), and Terraria.ModLoader.ModPlayer.TypeEquals().

◆ Name

string Terraria.ModLoader.ModPlayer.Name
getset

The name of this ModPlayer. Used for distinguishing between multiple ModPlayers added by a single Mod, in addition to the argument passed to Player.GetModPlayer.

Definition at line 28 of file ModPlayer.cs.

28 {
29 get;
30 internal set;
31 }

Referenced by Terraria.ModLoader.Mod.AutoloadPlayer(), Terraria.ModLoader.PlayerHooks.SendCustomBiomes(), and Terraria.ModLoader.ModPlayer.TypeEquals().

◆ player

Player Terraria.ModLoader.ModPlayer.player
getset

The Player instance that this ModPlayer instance is attached to.

Definition at line 36 of file ModPlayer.cs.

36 {
37 get;
38 internal set;
39 }