Terraria ModLoader  0.10.1.5
A framework for 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 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 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. 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 ModifyScreenPosition ()
 Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place. 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 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 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 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 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 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, 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 void SetupStartInventory (IList< Item > items)
 
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 or trashing 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. More...
 

Public Attributes

virtual bool CloneNewInstances => true
 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...
 

Properties

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

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 724 of file ModPlayer.cs.

724  {
725  }
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.

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

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

+ Here is the caller graph for this function:

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 646 of file ModPlayer.cs.

646  {
647  return true;
648  }
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 673 of file ModPlayer.cs.

673  {
674  return true;
675  }
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 521 of file ModPlayer.cs.

521  {
522  return null;
523  }
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 553 of file ModPlayer.cs.

553  {
554  return null;
555  }
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 586 of file ModPlayer.cs.

586  {
587  return true;
588  }
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 616 of file ModPlayer.cs.

616  {
617  return true;
618  }
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 707 of file ModPlayer.cs.

707  {
708  }
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  }
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 469 of file ModPlayer.cs.

469  {
470  return true;
471  }
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  }
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  }
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 743 of file ModPlayer.cs.

743  {
744  }
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  }
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 731 of file ModPlayer.cs.

731  {
732  }
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 716 of file ModPlayer.cs.

716  {
717  }
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  }
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  }
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  }
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 459 of file ModPlayer.cs.

459  {
460  }
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 443 of file ModPlayer.cs.

443  {
444  }
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 451 of file ModPlayer.cs.

451  {
452  }
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  }
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  }
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  }
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  }
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  }
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 503 of file ModPlayer.cs.

503  {
504  }
virtual float Terraria.ModLoader.ModPlayer.MeleeSpeedMultiplier ( Item  item)
virtual

Allows you to multiply an item's regular melee speed. Returns 1f by default.

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

Definition at line 416 of file ModPlayer.cs.

416  {
417  return 1f;
418  }
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 764 of file ModPlayer.cs.

764  {
765  }
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 750 of file ModPlayer.cs.

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

750  {
751  }

+ Here is the caller graph for this function:

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 757 of file ModPlayer.cs.

757  {
758  }
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 656 of file ModPlayer.cs.

656  {
657  }
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 683 of file ModPlayer.cs.

683  {
684  }
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 533 of file ModPlayer.cs.

533  {
534  }
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 566 of file ModPlayer.cs.

566  {
567  }
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 597 of file ModPlayer.cs.

597  {
598  }
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 627 of file ModPlayer.cs.

627  {
628  }
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 770 of file ModPlayer.cs.

770  {
771  }
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 777 of file ModPlayer.cs.

777  {
778  }
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  }
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 480 of file ModPlayer.cs.

480  {
481  }
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 798 of file ModPlayer.cs.

798  {
799  }
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 512 of file ModPlayer.cs.

512  {
513  }
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 665 of file ModPlayer.cs.

665  {
666  }
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 692 of file ModPlayer.cs.

692  {
693  }
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 544 of file ModPlayer.cs.

544  {
545  }
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 577 of file ModPlayer.cs.

577  {
578  }
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 607 of file ModPlayer.cs.

607  {
608  }
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 637 of file ModPlayer.cs.

637  {
638  }
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 805 of file ModPlayer.cs.

805  {
806  }
virtual void Terraria.ModLoader.ModPlayer.PlayerConnect ( Player  player)
virtual

Called on clients when a player connects.

Parameters
playerThe player that connected.

Definition at line 784 of file ModPlayer.cs.

784  {
785  }
virtual void Terraria.ModLoader.ModPlayer.PlayerDisconnect ( Player  player)
virtual

Called when a player disconnects.

Parameters
playerThe player that disconnected.

Definition at line 791 of file ModPlayer.cs.

791  {
792  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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.

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

175  {
176  }

+ Here is the caller graph for this function:

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

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

168  {
169  }

+ Here is the caller graph for this function:

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  }
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  }
virtual void Terraria.ModLoader.ModPlayer.SetupStartInventory ( IList< Item items)
virtual

Definition at line 127 of file ModPlayer.cs.

127  {
128  }
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 or trashing 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 and trash) from running. Returns false by default.

Definition at line 815 of file ModPlayer.cs.

815  {
816  return false;
817  }
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 494 of file ModPlayer.cs.

494  {
495  return true;
496  }
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  }
bool Terraria.ModLoader.ModPlayer.TypeEquals ( ModPlayer  other)

Definition at line 53 of file ModPlayer.cs.

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

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
Mod mod
The mod that added this type of ModPlayer.
Definition: ModPlayer.cs:20
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
virtual float Terraria.ModLoader.ModPlayer.UseTimeMultiplier ( Item  item)
virtual

Allows you to multiply an item's regular use time. Returns 1f by default.

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

Definition at line 407 of file ModPlayer.cs.

407  {
408  return 1f;
409  }

Member Data Documentation

virtual bool Terraria.ModLoader.ModPlayer.CloneNewInstances => true

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.

Property Documentation

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.

Referenced by Terraria.ModLoader.PlayerHooks.AddHook< F >(), Terraria.ModLoader.Mod.AddPlayer(), Terraria.ModLoader.PlayerHooks.SendCustomBiomes(), and Terraria.ModLoader.ModPlayer.TypeEquals().

Player Terraria.ModLoader.ModPlayer.player
getset

The Player instance that this ModPlayer instance is attached to.

Definition at line 36 of file ModPlayer.cs.