tModLoader v2024.11
A mod to make and play Terraria mods
ModAccessorySlotPlayer Class Reference

Inherits ModPlayer.

Classes

class  NetHandler
 

Public Member Functions

override void CopyClientState (ModPlayer targetCopy)
 
Allows you to copy information that you intend to sync between server and client to the targetCopy parameter.
You would then use the SendClientChanges hook to compare against that data and decide what needs synchronizing.
This hook is called with every call of the Player.clientClone method.

NOTE: For performance reasons, avoid deep cloning or copying any excessive information.
NOTE: Using Item.CopyNetStateTo is the recommended way of creating item snapshots. More...
 
void DropItems (IEntitySource itemSource)
 
override void LoadData (TagCompound tag)
 Allows you to load custom data that you have saved for this player.
Try to write defensive loading code that won't crash if something's missing. More...
 
override void SaveData (TagCompound tag)
 Allows you to save custom data for this player.

NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization.
NOTE: Try to only save data that isn't default values. More...
 
override 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...
 
override 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...
 
void UpdateDyes (bool socialSlots)
 Mirrors Player.UpdateDyes() for modded slots Runs On Player Select, so is Player instance sensitive!!!
 
override void UpdateEquips ()
 Runs a simplified version of Player.UpdateEquips for the Modded Accessory Slots More...
 
override void UpdateVisibleAccessories ()
 Updates functional slot visibility information on the player for Mod Slots, in a similar fashion to Player.UpdateVisibleAccessories() More...
 
override void UpdateVisibleVanityAccessories ()
 Updates vanity slot information on the player for Mod Slots, in a similar fashion to Player.UpdateVisibleAccessories() More...
 
- Public Member Functions inherited from ModPlayer
virtual IEnumerable< ItemAddMaterialsForCrafting (out ItemConsumedCallback itemConsumedCallback)
 Called when Recipe.FindRecipes is called or the player is crafting an item You can use this method to add items as the materials that may be used for crafting items More...
 
virtual IEnumerable< ItemAddStartingItems (bool mediumCoreDeath)
 Called when the player is created in the menu. You can use this method to add items to the player's starting inventory, as well as their inventory when they respawn in mediumcore. More...
 
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 void ArmorSetBonusActivated ()
 This is called when the player activates their armor set bonus by double tapping down (or up if Main.ReversedUpDownArmorSetBonuses is true). As an example, the Vortex armor uses this to toggle stealth mode. More...
 
virtual void ArmorSetBonusHeld (int holdTime)
 This is called when the player activates their armor set bonus by holding down (or up if Main.ReversedUpDownArmorSetBonuses is true) for some amount of time. The holdTime parameter indicates how many ticks the key has been held down for. As an example, the Stardust armor prior to 1.4.4 used to use this to set the location of the Stardust Guardian if holdTime was greater than 60. More...
 
virtual ? bool CanAutoReuseItem (Item item)
 Allows you to modify the autoswing (auto-reuse) behavior of any item without having to mess with Item.autoReuse.
Useful to create effects like the Feral Claws which makes melee weapons and whips auto-reusable.
Return true to enable autoswing (if not already enabled through autoReuse), return false to prevent autoswing. Returns null by default, which applies vanilla behavior. 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 (ImmunityCooldownID) to use, and defaults to -1 (ImmunityCooldownID.General). 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 CanCatchNPC (NPC target, Item item)
 Allows you to determine whether the given item can catch the given NPC.
Return true or false to say the target can or cannot be caught, respectively, regardless of vanilla rules.
Returns null by default, which allows vanilla's NPC catching rules to decide the target's fate.
If this returns false, CombinedHooks.OnCatchNPC is never called.

NOTE: this does not classify the given item as a catch tool, which is necessary for catching NPCs in the first place.
To do that, you will need to use the "CatchingTool" set in ItemID.Sets. More...
 
virtual bool CanConsumeAmmo (Item weapon, Item ammo)
 Whether or not the given ammo item will be consumed by this weapon.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo hook is never called. More...
 
virtual ? bool CanConsumeBait (Item bait)
 Choose if this bait will be consumed or not when used for fishing. return null for vanilla behavior. Not consuming will always take priority over forced consumption More...
 
virtual bool CanHitNPC (NPC target)
 Allows you to determine whether a player can hit the given NPC. Returns true by default. More...
 
virtual ? bool CanHitNPCWithItem (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 CanMeleeAttackCollideWithNPC (Item item, Rectangle meleeAttackHitbox, NPC target)
 Allows you to determine whether a player melee attack can collide the given NPC by swinging a melee weapon.
Use CanHitNPCWithItem(Item, NPC) instead for Guide Voodoo Doll-type effects. More...
 
virtual bool CanSellItem (NPC vendor, Item[] shopInventory, Item item)
 Return false to prevent a transaction. Called before the transaction. More...
 
virtual bool CanShoot (Item item)
 Allows you to prevent an item from shooting a projectile on use. Returns true by default. More...
 
virtual bool CanShowExtraJumpVisuals (ExtraJump jump)
 Return false to prevent ExtraJump.ShowVisuals(Player) from executing on jump .
By default, this hook returns whether the player is moving upwards with respect to Player.gravDir More...
 
virtual bool CanStartExtraJump (ExtraJump jump)
 An extra condition for whether an extra jump can be started. Returns true by default. More...
 
virtual bool CanUseItem (Item item)
 Return false to prevent an item from being used. By default returns true. More...
 
virtual void CatchFish (FishingAttempt attempt, ref int itemDrop, ref int npcSpawn, ref AdvancedPopupRequest sonar, ref Vector2 sonarPosition)
 Allows you to change the item or enemy the player gets when successfully catching an item or NPC. The Fishing Attempt structure contains most information about the vanilla event, including the Item Rod and Bait used by the player, the liquid it is being fished on, and so on. The Sonar and Sonar position fields allow you to change the text, color, velocity and position of the catch's name (be it item or NPC) freely More...
 
virtual bool ConsumableDodge (Player.HurtInfo info)
 Allows you to dodge damage for a player.
Vanilla examples include hallowed armor shadow dodge, and brain of confusion.
For dodges which are 'free' and should be used before triggering consumables, use FreeDodge instead.

Only runs on the local client of the player receiving the damage.
If dodge is determined on the local player, the hit will not be sent across the network.
You may need to send your own packet to synchronize the consumption of the effect, or application of the cooldown in multiplayer. More...
 
virtual void CopyClientState (ModPlayer targetCopy)
 
Allows you to copy information that you intend to sync between server and client to the targetCopy parameter.
You would then use the SendClientChanges hook to compare against that data and decide what needs synchronizing.
This hook is called with every call of the Player.clientClone method.

NOTE: For performance reasons, avoid deep cloning or copying any excessive information.
NOTE: Using Item.CopyNetStateTo is the recommended way of creating item snapshots. More...
 
virtual void DrawEffects (PlayerDrawSet 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 drawInfo.DustCache, and the indexes of any gore you create to drawInfo.GoreCache.
This will be called multiple times a frame if a player afterimage is being drawn. Check More...
 
virtual void EmitEnchantmentVisualsAt (Projectile projectile, Vector2 boxPosition, int boxWidth, int boxHeight)
 
virtual void ExtraJumpVisuals (ExtraJump jump)
 Effects that should appear while the player is performing an extra jump should happen here.
For example, the Sandstorm in a Bottle's dusts are spawned here.
 
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.
 
virtual bool FreeDodge (Player.HurtInfo info)
 Allows you to dodge damage for a player. Intended for guaranteed 'free' or random dodges.
Vanilla example is black belt.
For dodges which consume a stack/buff or have a cooldown, use ConsumableDodge instead.

Only runs on the local client of the player receiving the damage.
If dodge is determined on the local player, the hit will not be sent across the network.
If visual indication of the dodge is required on remote clients, you will need to send your own packet. 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 float 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 Item.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 Item.healMana value. More...
 
virtual void HideDrawLayers (PlayerDrawSet drawInfo)
 Allows you to modify the visibility of layers about to be drawn More...
 
virtual bool HoverSlot (Item[] inventory, int context, int slot)
 Called whenever the player hovers over an item slot. This can be used to override Main.cursorOverride
See ID.CursorOverrideID for cursor override style IDs More...
 
virtual bool ImmuneTo (PlayerDeathReason damageSource, int cooldownCounter, bool dodgeable)
 Allows you to make a player immune to damage from a certain source, or at a certain time.
Vanilla examples include shimmer and journey god mode.

Runs before dodges are used, or any damage calculations are performed.
Runs on all players, on all clients, so checking Player == Main.LocalPlayer is advisable.
If immunity is determined on the local player, the hit will not be sent across the network.

In pvp the hit will be sent regardless, and all clients will determine immunity independently, though it only really matters for the receiving player. 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...
 
delegate void ItemConsumedCallback (Item item, int index)
 An action to be invoked when an item is partially or fully consumed 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 LoadData (TagCompound tag)
 Allows you to load custom data that you have saved for this player.
Try to write defensive loading code that won't crash if something's missing. 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. This is typically used to implement a weapon enchantment, similar to flasks, frost armor, or magma stone effects. If implementing a weapon enchantment, also implement EmitEnchantmentVisualsAt(Projectile, Vector2, int, int) to support enchantment visuals for projectiles as well. More...
 
virtual void ModifyCaughtFish (Item fish)
 Allows you to modify the item caught by the fishing player, including stack More...
 
virtual void ModifyDrawInfo (ref PlayerDrawSet drawInfo)
 Allows you to modify the drawing parameters of the player before drawing begins. More...
 
virtual void ModifyDrawLayerOrdering (IDictionary< PlayerDrawLayer, PlayerDrawLayer.Position > positions)
 Allows you to reorder the player draw layers. This is called once at the end of mod loading, not during the game. Use with extreme caution, or risk breaking other mods. More...
 
virtual void ModifyExtraJumpDurationMultiplier (ExtraJump jump, ref float duration)
 Use this hook to modify the jump duration from an extra jump.
Vanilla's extra jumps use the following values: More...
 
virtual void ModifyFishingAttempt (ref FishingAttempt attempt)
 Allows you to change information about the ongoing fishing attempt before caught items/NPCs are decided, after all vanilla information has been gathered.
Will not be called if various conditions for getting a catch aren't met, meaning you can't modify those.
Setting FishingAttempt.rolledItemDrop or FishingAttempt.rolledEnemySpawn is not allowed and will be reset, use CatchFish for that. More...
 
virtual void ModifyHitByNPC (NPC npc, ref Player.HurtModifiers modifiers)
 Allows you to modify the damage, etc., that an NPC does to this player.
Runs on the local client.

 
virtual void ModifyHitByProjectile (Projectile proj, ref Player.HurtModifiers modifiers)
 Allows you to modify the damage, etc., that a hostile projectile does to this player.
Runs on the local client.

 
virtual void ModifyHitNPC (NPC target, ref NPC.HitModifiers modifiers)
 Allows you to modify the damage, knockback, etc that this player does to an NPC.
This method is only called on the on the local client.
More...
 
virtual void ModifyHitNPCWithItem (Item item, NPC target, ref NPC.HitModifiers modifiers)
 Allows you to modify the damage, knockback, etc., that this player does to an NPC by swinging a melee weapon.
This method is only called on the on the client of the player holding the weapon.
More...
 
virtual void ModifyHitNPCWithProj (Projectile proj, NPC target, ref NPC.HitModifiers modifiers)
 Allows you to modify the damage, knockback, etc., that a projectile created by this player does to an NPC. More...
 
virtual void ModifyHurt (ref Player.HurtModifiers modifiers)
 Allows you to adjust an instance of player taking damage.
Called on local, server and remote clients.
Only use this hook if you need to modify the hurt parameters in some way, eg consuming a buff which reduces the damage of the next hit.
Use OnHurt or PostHurt instead where possible.
The player will always take at least 1 damage. To prevent damage use ImmuneTo or FreeDodge

 
virtual void ModifyItemScale (Item item, ref float scale)
 Allows you to dynamically modify the given item's size for this player, similarly to the effect of the Titan Glove. More...
 
virtual void ModifyLuck (ref float luck)
 Allows you to modify a player's luck amount. 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 void ModifyMaxStats (out StatModifier health, out StatModifier mana)
 Allows you to modify the player's max stats. This hook runs after vanilla increases from the Life Crystal, Life Fruit and Mana Crystal are applied
NOTE: You should NOT modify Player.statLifeMax nor Player.statManaMax here. Use the health and mana parameters. Also note that unlike many other tModLoader hooks, the default implementation of this hook has code that will assign health and mana to StatModifier.Default. Take care to place base.ModifyMaxStats(out health, out mana); before any other code you add to this hook to avoid issues, if you use it. 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 the Nurse wiki pagefor the default pricing. More...
 
virtual void ModifyScreenPosition ()
 Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place.
Also consider using Main.instance.CameraModifiers.Add(CameraModifier); as shown in ExampleMods MinionBossBody for screen shakes.
 
virtual void ModifyShootStats (Item item, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback)
 Allows you to modify the position, velocity, type, damage and/or knockback of a projectile being shot by an item. More...
 
virtual void ModifyStartingInventory (IReadOnlyDictionary< string, List< Item > > itemsByMod, bool mediumCoreDeath)
 Allows you to modify the items that will be added to the player's inventory. Useful if you want to stop vanilla or other mods from adding an item. You can access a mod's items by using the mod's internal name as the indexer, such as: additions["ModName"]. To access vanilla items you can use "Terraria" as the index. More...
 
virtual void ModifyWeaponCrit (Item item, ref float crit)
 Allows you to dynamically modify a weapon's crit chance based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. More...
 
virtual void ModifyWeaponDamage (Item item, ref StatModifier damage)
 Allows you to dynamically modify a weapon's damage based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. More...
 
virtual void ModifyWeaponKnockback (Item item, ref StatModifier knockback)
 Allows you to dynamically modify a weapon's knockback based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. 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...
 
override ModPlayer NewInstance (Player entity)
 
virtual void OnCatchNPC (NPC npc, Item item, bool failed)
 Allows you to make things happen when the given item attempts to catch the given NPC. More...
 
virtual void OnConsumeAmmo (Item weapon, Item ammo)
 Allows you to make things happen when the given ammo is consumed by the given weapon.
Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place. 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 ()
 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 OnExtraJumpCleared (ExtraJump jump)
 This hook runs before the ExtraJumpState.Available flag for an extra jump is set to false in Player.Update(int) due to the jump being unavailable or when calling Player.ConsumeAllExtraJumps (vanilla calls it when a mount that blocks jumps is active) More...
 
virtual void OnExtraJumpEnded (ExtraJump jump)
 This hook runs before the ExtraJumpState.Active flag for an extra jump is set from true to false when the extra jump's duration has expired
This occurs when a grappling hook is thrown, the player grabs onto a rope, the jump's duration has finished and when the player's frozen, turned to stone or webbed. More...
 
virtual void OnExtraJumpRefreshed (ExtraJump jump)
 This hook runs before the ExtraJumpState.Available flag for an extra jump is set to true in Player.RefreshDoubleJumps
This occurs at the start of the grounded jump and while the player is grounded. More...
 
virtual void OnExtraJumpStarted (ExtraJump jump, ref bool playSound)
 Effects that should appear when the extra jump starts should happen here.
For example, the Cloud in a Bottle's initial puff of smoke is spawned here. 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.
Called on the local client.
More...
 
virtual void OnHitByNPC (NPC npc, Player.HurtInfo hurtInfo)
 Allows you to create special effects when an NPC hits this player (for example, inflicting debuffs).
Runs on the local client.

 
virtual void OnHitByProjectile (Projectile proj, Player.HurtInfo hurtInfo)
 Allows you to create special effects when a hostile projectile hits this player.
Runs on the local client.

 
virtual void OnHitNPC (NPC target, NPC.HitInfo hit, int damageDone)
 Allows you to create special effects when this player hits an NPC. More...
 
virtual void OnHitNPCWithItem (Item item, NPC target, NPC.HitInfo hit, int damageDone)
 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, NPC.HitInfo hit, int damageDone)
 Allows you to create special effects when a projectile created by this player hits an NPC (for example, inflicting debuffs). More...
 
virtual void OnHurt (Player.HurtInfo info)
 Allows you to make anything happen when the player takes damage.
Called on local, server and remote clients.
Called right before health is reduced.
 
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 bool OnPickup (Item item)
 Allows you to make special things happen when this player picks up an item. Return false to stop the item from being added to the player's inventory; returns true by default. More...
 
virtual void OnRespawn ()
 Called when a player respawns in the world.
 
virtual void PlayerConnect ()
 Called on clients when a player connects.
 
virtual void PlayerDisconnect ()
 Called when a player disconnects.
 
virtual void PostBuyItem (NPC vendor, Item[] shopInventory, Item item)
 Called whenever the player buys an item from an NPC. More...
 
virtual void PostHurt (Player.HurtInfo info)
 Allows you to make anything happen when the player takes damage.
Called on local, server and remote clients.
Only called if the player survives the hit.
 
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.
 
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.
 
virtual void PostSellItem (NPC vendor, Item[] shopInventory, Item item)
 Called whenever the player sells an item to an NPC. Note that item might be an item sold by the NPC, not an item to buy back. Check Item.buyOnce if relevant to your logic. More...
 
virtual void PostUpdate ()
 This is called at the very end of the Player.Update method. Final general update tasks can be placed here.
 
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.
 
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.
 
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.
 
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.
 
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 genDust, 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 genDust parameter to false to stop the dust from being created. These are useful for creating your own sound or dust to replace the normal death effects, such as how the Frost armor set spawns DustID.IceTorch instead of DustID.Blood. For mod compatibility, it is recommended to check if these values are true before setting them to true and spawning dust or playing sounds to avoid overlapping sounds and dust effects.

Return false to stop the player from being killed. Only return false if you know what you are doing! Returns true by default. More...
 
virtual bool PreModifyLuck (ref float luck)
 Called before vanilla makes any luck calculations. Return false to prevent vanilla from making their luck calculations. Returns true by default. More...
 
virtual void PreSaveCustomData ()
 Currently never gets called, so this is useless.
 
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.
 
virtual void PreUpdate ()
 This is called at the beginning of every tick update for this player, after checking whether the player exists.
This can be used to adjust timers and cooldowns.
 
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).
 
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.
 
virtual void ProcessTriggers (TriggersSet triggersSet)
 Use this to check on keybinds you have registered. While SetControls is set even while in text entry mode, this hook is only called during gameplay. Read ExampleKeybindPlayer.csfor examples and information on using this hook. More...
 
virtual void RefreshInfoAccessoriesFromTeamPlayers (Player otherPlayer)
 This is where you set any fields related to INFORMATION accessories based on the passed in player argument. Note that this hook is only called if all of the requirements for a "nearby teammate" is met, which is when the other player is on the same team and within a certain distance, determined by the following code: 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.
 
virtual void ResetInfoAccessories ()
 This is where you reset any fields related to INFORMATION accessories to their "default" states. This is identical to ResetEffects(); but should ONLY be used to reset info accessories. It will cause unintended side-effects if used with other fields. More...
 
virtual void SaveData (TagCompound tag)
 Allows you to save custom data for this player.

NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization.
NOTE: Try to only save data that isn't default values. 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 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.
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. 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, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
 Allows you to modify an item's shooting mechanism. Return false to prevent vanilla's shooting code from running. 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.
 
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.
 
virtual void UpdateDead ()
 Similar to ResetEffects, except this is only called when the player is dead. If this is called, then ResetEffects will not be called.
 
virtual void UpdateDyes ()
 Is called in Player.UpdateDyes(), including selection screen. Player Instance sensitive.
 
virtual void UpdateEquips ()
 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.
 
virtual void UpdateVisibleAccessories ()
 Is called in Player.Frame() after vanilla functional slots are evaluated, including selection screen to prepare and denote visible accessories. Player Instance sensitive. More...
 
virtual void UpdateVisibleVanityAccessories ()
 Is called in Player.Frame() after vanilla vanity slots are evaluated, including selection screen to prepare and denote visible accessories. Player Instance sensitive. More...
 
virtual float UseAnimationMultiplier (Item item)
 Allows you to change the effective useAnimation of an item.
Note that this hook may cause items' actions to run less or more times than they should per a single use. More...
 
virtual float UseSpeedMultiplier (Item item)
 Allows you to safely change both useTime and useAnimation while keeping the values relative to each other.
Useful for status effects. More...
 
virtual float UseTimeMultiplier (Item item)
 Allows you to change the effective useTime of an item.
Note that this hook may cause items' actions to run less or more times than they should per a single use. More...
 
- Public Member Functions inherited from ModType< Player, ModPlayer >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed.
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
 
abstract void Load (Mod mod)
 Called when loading the type. More...
 
abstract void Unload ()
 Called during unloading when needed. More...
 

Properties

int LoadedSlotCount [get]
 
int SlotCount [get]
 
- Properties inherited from ModPlayer
ushort Index [get, set]
 
Player Player [get]
 The Player instance that this ModPlayer instance is attached to.
 
- Properties inherited from ModType< Player, ModPlayer >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from IModType
string FullName [get]
 => $"{Mod.Name}/{Name}" More...
 
Mod Mod [get]
 The mod this belongs to. More...
 
string Name [get]
 The internal name of this instance. More...
 
- Properties inherited from IIndexed
ushort Index [get]
 

Additional Inherited Members

- Protected Member Functions inherited from ModPlayer
override Player CreateTemplateEntity ()
 
sealed override void Register ()
 If you make a new ModType, seal this override. More...
 
override void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 
- Protected Member Functions inherited from ModType< Player, ModPlayer >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 

Member Function Documentation

◆ CopyClientState()

override void ModAccessorySlotPlayer.CopyClientState ( ModPlayer  targetCopy)
virtual


Allows you to copy information that you intend to sync between server and client to the targetCopy parameter.
You would then use the SendClientChanges hook to compare against that data and decide what needs synchronizing.
This hook is called with every call of the Player.clientClone method.

NOTE: For performance reasons, avoid deep cloning or copying any excessive information.
NOTE: Using Item.CopyNetStateTo is the recommended way of creating item snapshots.

Parameters
targetCopy

Reimplemented from ModPlayer.

◆ LoadData()

override void ModAccessorySlotPlayer.LoadData ( TagCompound  tag)
virtual

Allows you to load custom data that you have saved for this player.
Try to write defensive loading code that won't crash if something's missing.

Parameters
tagThe TagCompound to load data from.

Reimplemented from ModPlayer.

◆ SaveData()

override void ModAccessorySlotPlayer.SaveData ( TagCompound  tag)
virtual

Allows you to save custom data for this player.

NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization.
NOTE: Try to only save data that isn't default values.

Parameters
tagThe TagCompound to save data into. Note that this is always empty by default, and is provided as an argument only for the sake of convenience and optimization.

Reimplemented from ModPlayer.

◆ SendClientChanges()

override void ModAccessorySlotPlayer.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

Reimplemented from ModPlayer.

◆ SyncPlayer()

override void ModAccessorySlotPlayer.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

Reimplemented from ModPlayer.

◆ UpdateEquips()

override void ModAccessorySlotPlayer.UpdateEquips ( )
virtual

Runs a simplified version of Player.UpdateEquips for the Modded Accessory Slots

Reimplemented from ModPlayer.

◆ UpdateVisibleAccessories()

override void ModAccessorySlotPlayer.UpdateVisibleAccessories ( )
virtual

Updates functional slot visibility information on the player for Mod Slots, in a similar fashion to Player.UpdateVisibleAccessories()

Reimplemented from ModPlayer.

◆ UpdateVisibleVanityAccessories()

override void ModAccessorySlotPlayer.UpdateVisibleVanityAccessories ( )
virtual

Updates vanity slot information on the player for Mod Slots, in a similar fashion to Player.UpdateVisibleAccessories()

Reimplemented from ModPlayer.