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

This class allows you to modify and use hooks for all items, both vanilla and modded.
To use it, simply create a new class deriving from this one. Implementations will be registered automatically. More...

Inherits GlobalType< Item, GlobalItem >.

Inherited by UnloadedGlobalItem.

Public Member Functions

virtual void AddRecipes ()
 Override this method to add Recipes to the game.
The Basic Recipes Guideteaches how to add new recipes to the game and how to manipulate existing recipes.

 
virtual bool AllowPrefix (Item item, int pre)
 Force a re-roll of a prefix by returning false.
 
virtual bool AltFunctionUse (Item item, Player player)
 
virtual void AnglerChat (int type, ref string chat, ref string catchLocation)
 Allows you to set what the Angler says when the Quest button is clicked in his chat. The chat parameter is his dialogue, and catchLocation should be set to "Caught at [location]" for the given type. More...
 
virtual void ArmorArmGlowMask (int slot, Player drawPlayer, float shadow, ref int glowMask, ref Color color)
 Allows you to modify which glow mask and in what color is drawn on the player's arms. Note that this is only called for body armor. More...
 
virtual void ArmorSetShadows (Player player, string set)
 Allows you to determine special visual effects a vanity has on the player without having to code them yourself. More...
 
virtual bool CanAccessoryBeEquippedWith (Item equippedItem, Item incomingItem, Player player)
 Allows you to prevent similar accessories from being equipped multiple times. For example, vanilla Wings. Return false to have the currently equipped item swapped with the incoming item - ie both can't be equipped at same time.
 
virtual ? bool CanAutoReuseItem (Item item, Player player)
 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 CanBeChosenAsAmmo (Item ammo, Item weapon, Player player)
 Whether or not the given ammo item is valid for the given weapon; called on the ammo. If this, or CanChooseAmmo on the weapon, returns false, then the ammo will not be valid for this weapon.
By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid.
If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called. More...
 
virtual bool CanBeConsumedAsAmmo (Item ammo, Item weapon, Player player)
 Whether or not the given ammo item will be consumed; called on the ammo.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called. More...
 
virtual ? bool CanCatchNPC (Item item, NPC target, Player player)
 Allows you to determine whether the given item can catch the given NPC.
Return true or false to say the given NPC 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 an NPC-catching 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 CanChooseAmmo (Item weapon, Item ammo, Player player)
 Whether or not the given ammo item is valid for the given weapon; called on the weapon. If this, or CanBeChosenAsAmmo on the ammo, returns false, then the ammo will not be valid for this weapon.
By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid.
If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called. More...
 
virtual bool CanConsumeAmmo (Item weapon, Item ammo, Player player)
 Whether or not the given ammo item will be consumed; called on the weapon.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called. More...
 
virtual ? bool CanConsumeBait (Player player, Item bait)
 Allows you to choose if a given bait will be consumed by a given player Not consuming will always take priority over forced consumption More...
 
virtual bool CanEquipAccessory (Item item, Player player, int slot, bool modded)
 Allows you to disallow the player from equipping an accessory. Return false to disallow equipping the accessory. Returns true by default. More...
 
virtual ? bool CanHitNPC (Item item, Player player, NPC target)
 Allows you to determine whether a melee weapon can hit the given NPC when swung. Return true to allow hitting the target, return false to block the weapon from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default.
 
virtual bool CanHitPvp (Item item, Player player, Player target)
 Allows you to determine whether a melee weapon can hit the given opponent player when swung. Return false to block the weapon from hitting the target. Returns true by default.
 
virtual ? bool CanMeleeAttackCollideWithNPC (Item item, Rectangle meleeAttackHitbox, Player player, NPC target)
 Allows you to determine whether a melee weapon can collide with the given NPC when swung.
Use CanHitNPC(Item, Player, NPC) instead for Flymeal-type effects. More...
 
virtual bool CanPickup (Item item, Player player)
 Allows you to determine whether or not the item can be picked up
 
virtual bool CanReforge (Item item)
 This hook gets called when the player clicks on the reforge button and can afford the reforge. Returns whether the reforge will take place. If false is returned by the ModItem or any GlobalItem, the item will not be reforged, the cost to reforge will not be paid, and PreRefoge and PostReforge hooks will not be called. Reforging preserves modded data on the item.
 
virtual bool CanResearch (Item item)
 Allows you to prevent an item from being researched by returning false. True is the default behavior. More...
 
virtual bool CanRightClick (Item item)
 Returns whether or not an item does something when right-clicked in the inventory. Returns false by default.
 
virtual bool CanShoot (Item item, Player player)
 Allows you to prevent an item from shooting a projectile on use. Returns true by default. More...
 
virtual bool CanStack (Item destination, Item source)
 Allows you to prevent items from stacking.
This is only called when two items of the same type attempt to stack.
This is usually not called for coins and ammo in the inventory/UI.
This covers all scenarios, if you just need to change in-world stacking behavior, use CanStackInWorld. More...
 
virtual bool CanStackInWorld (Item destination, Item source)
 Allows you to prevent items from stacking in the world.
This is only called when two items of the same type attempt to stack. More...
 
virtual bool CanUseItem (Item item, Player player)
 Returns whether or not any item can be used. Returns true by default. The inability to use a specific item overrides this, so use this to stop an item from being used.
 
virtual void CaughtFishStack (int type, ref int stack)
 Allows you to modify how many of an item a player obtains when the player fishes that item.
 
virtual int ChoosePrefix (Item item, UnifiedRandom rand)
 Allows you to manually choose what prefix an item will get. More...
 
virtual bool ConsumeItem (Item item, Player player)
 If the item is consumable and this returns true, then the item will be consumed upon usage. Returns true by default. If false is returned, the OnConsumeItem hook is never called.
 
virtual void DrawArmorColor (EquipType type, int slot, Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor)
 Allows you to modify the colors in which the player's armor and their surrounding accessories are drawn, in addition to which glow mask and in what color is drawn. More...
 
virtual void ExtractinatorUse (int extractType, int extractinatorBlockType, ref int resultType, ref int resultStack)
 Allows you to modify what item, and in what quantity, is obtained when an item of the given type is fed into the Extractinator. Use ItemID.Sets.ExtractinatorMode to allow an item to be fed into the Extractinator. An extractType of 0 represents the default extraction (Silt and Slush). 0, ItemID.DesertFossil, ItemID.OldShoe, and ItemID.LavaMoss are vanilla extraction types. Modded types by convention will correspond to the iconic item of the extraction type. The Extractinator wiki pagehas more info. By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator. Use extractinatorBlockType to provide different behavior for TileID.ChlorophyteExtractinator if desired. If the Chlorophyte Extractinator item swapping behavior is desired, see the example in TorchExtractinatorGlobalItem.cs. This method is not instanced. More...
 
virtual ? Color GetAlpha (Item item, Color lightColor)
 Allows you to determine the color and transparency in which an item is drawn. Return null to use the default color (normally light color). Returns null by default.
 
virtual void GetHealLife (Item item, Player player, 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, Player player, 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 GrabRange (Item item, Player player, ref int grabRange)
 Allows you to modify how close an item must be to the player in order to move towards the player.
 
virtual bool GrabStyle (Item item, Player player)
 Allows you to modify the way an item moves towards the player. Return false to allow the vanilla grab style to take place. Returns false by default.
 
virtual void HoldItem (Item item, Player player)
 Allows you to make things happen when the player is holding an item (for example, torches make light and water candles increase spawn rate).
 
virtual void HoldItemFrame (Item item, Player player)
 Allows you to modify the player's animation when the player is holding an item.
 
virtual ? Vector2 HoldoutOffset (int type)
 Allows you to determine the offset of an item's sprite when used by the player. This is only used for items with a useStyle of 5 that aren't staves. Return null to use the item's default holdout offset; returns null by default. More...
 
virtual ? Vector2 HoldoutOrigin (int type)
 Allows you to determine the point on an item's sprite that the player holds onto when using the item. The origin is from the bottom left corner of the sprite. This is only used for staves with a useStyle of 5. Return null to use the item's default holdout origin; returns null by default. More...
 
virtual void HoldStyle (Item item, Player player, Rectangle heldItemFrame)
 Allows you to modify the location and rotation of the item the player is currently holding. More...
 
virtual void HorizontalWingSpeeds (Item item, Player player, ref float speed, ref float acceleration)
 Allows you to modify the horizontal flight speed and acceleration of wings.
 
virtual bool IsAnglerQuestAvailable (int type)
 Whether or not specific conditions have been satisfied for the Angler to be able to request the given item. (For example, Hardmode.) Returns true by default. More...
 
virtual string IsArmorSet (Item head, Item body, Item legs)
 Allows you to determine whether the player is wearing an armor set, and return a name for this set. If there is no armor set, return the empty string. Returns the empty string by default. More...
 
virtual string IsVanitySet (int head, int body, int legs)
 Returns whether or not the head armor, body armor, and leg armor textures make up a set. This hook is used for the PreUpdateVanitySet, UpdateVanitySet, and ArmorSetShadows hooks, and will use items in the social slots if they exist. By default this will return the same value as the IsArmorSet hook, so you will not have to use this hook unless you want vanity effects to be entirely separate from armor sets. More...
 
virtual bool ItemSpace (Item item, Player player)
 Return true to specify that the item can be picked up despite not having enough room in inventory. Useful for something like hearts or experience items. Use in conjunction with OnPickup to actually consume the item and handle it.
 
virtual void LoadData (Item item, TagCompound tag)
 Allows you to load custom data that you have saved for this item.
Try to write defensive loading code that won't crash if something's missing. More...
 
virtual void MeleeEffects (Item item, Player player, Rectangle hitbox)
 Allows you to give melee weapons special effects, such as creating light or dust.
 
virtual void ModifyHitNPC (Item item, Player player, NPC target, ref NPC.HitModifiers modifiers)
 Allows you to modify the damage, knockback, etc., that a melee weapon does to an NPC.
This method is only called on the on the client of the player holding the weapon.

 
virtual void ModifyHitPvp (Item item, Player player, Player target, ref Player.HurtModifiers modifiers)
 Allows you to modify the damage, etc., that a melee weapon does to a player.
 
virtual void ModifyItemLoot (Item item, ItemLoot itemLoot)
 Allows you to add and modify the loot items that spawn from bag items when opened.
The Basic NPC Drops and Loot 1.4 Guideexplains how to use the ModNPC.ModifyNPCLoot(NPCLoot) hook to modify NPC loot as well as this hook. A common usage is to use this hook and ModNPC.ModifyNPCLoot(NPCLoot) to edit non-expert exclusive drops for bosses.
This hook only runs once per item type during mod loading, any dynamic behavior must be contained in the rules themselves.
This hook is not instanced. More...
 
virtual void ModifyItemScale (Item item, Player player, ref float scale)
 Allows you to dynamically modify the given item's size for the given player, similarly to the effect of the Titan Glove.

Do not modify Item.scale, modify the scale parameter. More...
 
virtual void ModifyManaCost (Item item, Player player, 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.

Do not modify Item.mana, modify the reduce and mult parameters. More...
 
virtual void ModifyResearchSorting (Item item, ref ContentSamples.CreativeHelper.ItemGroup itemGroup)
 Allows you to set an item's sorting group in Journey Mode's duplication menu. This is useful for setting custom item types that group well together, or whenever the default vanilla sorting doesn't sort the way you want it. Note that this affects the order of the item in the listing, not which filters the item satisfies. More...
 
virtual void ModifyShootStats (Item item, Player player, 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.
These parameters will be provided to Shoot(Item, Player, EntitySource_ItemUse_WithAmmo, Vector2, Vector2, int, int, float) where the projectile will actually be spawned. More...
 
virtual void ModifyTooltips (Item item, List< TooltipLine > tooltips)
 Allows you to modify all the tooltips that display for the given item. See here for information about TooltipLine. To hide tooltips, please use TooltipLine.Hide and defensive coding.
 
virtual void ModifyWeaponCrit (Item item, Player player, 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.

Do not modify Item.crit, modify the crit parameter. More...
 
virtual void ModifyWeaponDamage (Item item, Player player, 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.

Do not modify Item.damage, modify the damage parameter. More...
 
virtual void ModifyWeaponKnockback (Item item, Player player, 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.

Do not modify Item.knockBack, modify the knockback parameter. More...
 
virtual bool NeedsAmmo (Item item, Player player)
 Whether or not having no ammo prevents an item that uses ammo from shooting. Return false to allow shooting with no ammo in the inventory, in which case the item will act as if the default ammo for it is being used. Returns true by default.
 
virtual void NetReceive (Item item, BinaryReader reader)
 
virtual void NetSend (Item item, BinaryWriter writer)
 
virtual void OnCatchNPC (Item item, NPC npc, Player player, 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, Player player)
 Allows you to make things happen when the given ammo is consumed by the given weapon. Called by the 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 OnConsumedAsAmmo (Item ammo, Item weapon, Player player)
 Allows you to make things happen when the given ammo is consumed by the given weapon. Called by the ammo.
Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place. More...
 
virtual void OnConsumeItem (Item item, Player player)
 Allows you to make things happen when this item is consumed. Called before the item stack is reduced.
 
virtual void OnConsumeMana (Item item, Player player, int manaConsumed)
 Allows you to make stuff happen when a player consumes mana on use of an item. More...
 
virtual void OnCreated (Item item, ItemCreationContext context)
 Called when the item is created. The context parameter indicates the context of the item creation and can be used in logic for the desired effect. Known ItemCreationContext include: InitializationItemCreationContext, BuyItemCreationContext, JourneyDuplicationItemCreationContext, and RecipeItemCreationContext. Some of these provide additional context such as how RecipeItemCreationContext includes the items consumed to craft the item .
 
virtual void OnHitNPC (Item item, Player player, NPC target, NPC.HitInfo hit, int damageDone)
 Allows you to create special effects when a melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads).
 
virtual void OnHitPvp (Item item, Player player, Player target, Player.HurtInfo hurtInfo)
 Allows you to create special effects when a melee weapon hits a player.
Called on local, server and remote clients.

 
virtual void OnMissingMana (Item item, Player player, int neededMana)
 Allows you to make stuff happen when a player doesn't have enough mana for an 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, Player player)
 Allows you to make special things happen when the player picks up an item. Return false to stop the item from being added to the player's inventory; returns true by default.
 
virtual void OnResearched (Item item, bool fullyResearched)
 Allows you to create custom behavior when an item is accepted by the Research function More...
 
virtual void OnSpawn (Item item, IEntitySource source)
 Gets called when any item spawns in world
 
virtual void OnStack (Item destination, Item source, int numToTransfer)
 Allows you to make things happen when items stack together.
This hook is called before the items are transferred from source to destination More...
 
virtual void PickAmmo (Item weapon, Item ammo, Player player, ref int type, ref float speed, ref StatModifier damage, ref float knockback)
 Allows you to modify various properties of the projectile created by a weapon based on the ammo it is using. More...
 
virtual void PostDrawInInventory (Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
 
virtual void PostDrawInWorld (Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
 
virtual void PostDrawTooltip (Item item, ReadOnlyCollection< DrawableTooltipLine > lines)
 Allows you to do things after this item's tooltip is drawn. The lines contain draw information as this is ran after drawing the tooltip. More...
 
virtual void PostDrawTooltipLine (Item item, DrawableTooltipLine line)
 Allows you to do things after a tooltip line of this item is drawn. The line contains draw info. More...
 
virtual void PostReforge (Item item)
 This hook gets called immediately after an item gets reforged by the Goblin Tinkerer. Useful for modifying modded data based on the reforge result.
 
virtual void PostUpdate (Item item)
 Allows you to make things happen when an item is lying in the world. This will always be called, even when the item is being grabbed by a player. This hook should be used for adding light, or for increasing the age of less valuable items.
 
virtual bool PreDrawInInventory (Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
 
virtual bool PreDrawInWorld (Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
 
virtual bool PreDrawTooltip (Item item, ReadOnlyCollection< TooltipLine > lines, ref int x, ref int y)
 Allows you to do things before this item's tooltip is drawn. More...
 
virtual bool PreDrawTooltipLine (Item item, DrawableTooltipLine line, ref int yOffset)
 Allows you to do things before a tooltip line of this item is drawn. The line contains draw info. More...
 
virtual ? bool PrefixChance (Item item, int pre, UnifiedRandom rand)
 To prevent putting the item in the tinkerer slot, return false when pre is -3. To prevent rolling of a prefix on spawn, return false when pre is -1. To force rolling of a prefix on spawn, return true when pre is -1. More...
 
virtual void PreReforge (Item item)
 This hook gets called immediately before an item gets reforged by the Goblin Tinkerer.
 
virtual void PreUpdateVanitySet (Player player, string set)
 Allows you to create special effects (such as the necro armor's hurt noise) when the player wears the vanity set with the given name returned by IsVanitySet. This hook is called regardless of whether the player is frozen in any way. More...
 
virtual bool ReforgePrice (Item item, ref int reforgePrice, ref bool canApplyDiscount)
 Returns if the normal reforge pricing is applied. If true or false is returned and the price is altered, the price will equal the altered price. The passed reforge price equals the item.value. Vanilla pricing will apply 20% discount if applicable and then price the reforge at a third of that value.
 
virtual void RightClick (Item item, Player player)
 Allows you to make things happen when an item is right-clicked in the inventory. Useful for goodie bags.
 
virtual void SaveData (Item item, TagCompound tag)
 Allows you to save custom data for this item.

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 SetMatch (int armorSlot, int type, bool male, ref int equipSlot, ref bool robes)
 Allows you to modify the equipment that the player appears to be wearing. More...
 
sealed override void SetupContent ()
 
virtual bool Shoot (Item item, Player player, 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.
This method is called after the ModifyShootStats hook has had a chance to adjust the spawn parameters. More...
 
virtual void SplitStack (Item destination, Item source, int numToTransfer)
 Allows you to make things happen when an item stack is split. This hook is called before the stack values are modified. More...
 
virtual void Update (Item item, ref float gravity, ref float maxFallSpeed)
 Allows you to customize an item's movement when lying in the world. Note that this will not be called if the item is currently being grabbed by a player.
 
virtual void UpdateAccessory (Item item, Player player, bool hideVisual)
 Allows you to give effects to accessories. The hideVisual parameter is whether the player has marked the accessory slot to be hidden from being drawn on the player.
 
virtual void UpdateArmorSet (Player player, string set)
 Allows you to give set bonuses to your armor set with the given name. The set name will be the same as returned by IsArmorSet. More...
 
virtual void UpdateEquip (Item item, Player player)
 Allows you to give effects to armors and accessories, such as increased damage.
 
virtual void UpdateInfoAccessory (Item item, Player player)
 Allows you to set information accessory fields with the passed in player argument. This hook should only be used for information accessory fields such as the Radar, Lifeform Analyzer, and others. Using it for other fields will likely cause weird side-effects.
 
virtual void UpdateInventory (Item item, Player player)
 Allows you to make things happen when an item is in the player's inventory. This should NOT be used for information accessories; use

See also
UpdateInfoAccessory

for those instead.

 
virtual void UpdateVanity (Item item, Player player)
 Allows you to give effects to this accessory when equipped in a vanity slot. Vanilla uses this for boot effects, wings and merman/werewolf visual flags
 
virtual void UpdateVanitySet (Player player, string set)
 Allows you to create special effects (such as dust) when the player wears the vanity set with the given name returned by IsVanitySet. This hook will only be called if the player is not frozen in any way. More...
 
virtual void UseAnimation (Item item, Player player)
 Allows you to make things happen when an item's use animation starts.
 
virtual float UseAnimationMultiplier (Item item, Player player)
 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 ? bool UseItem (Item item, Player player)
 Allows you to make things happen when an item is used. The return value controls whether or not ApplyItemTime will be called for the player.
Return true if the item actually did something, to force itemTime.
Return false to keep itemTime at 0.
Return null for vanilla behavior.
 
virtual void UseItemFrame (Item item, Player player)
 Allows you to modify the player's animation when an item is being used.
 
virtual void UseItemHitbox (Item item, Player player, ref Rectangle hitbox, ref bool noHitbox)
 Changes the hitbox of a melee weapon when it is used.
 
virtual float UseSpeedMultiplier (Item item, Player player)
 Allows you to safely change both useTime and useAnimation while keeping the values relative to each other.
Useful for status effects. More...
 
virtual void UseStyle (Item item, Player player, Rectangle heldItemFrame)
 Allows you to modify the location and rotation of any item in its use animation. More...
 
virtual float UseTimeMultiplier (Item item, Player player)
 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...
 
virtual void VerticalWingSpeeds (Item item, Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
 Allows you to modify the speeds at which you rise and fall when wings are equipped.
 
virtual bool WingUpdate (int wings, Player player, bool inUse)
 Allows for Wings to do various things while in use. "inUse" is whether or not the jump button is currently pressed. Called when wings visually appear on the player. Use to animate wings, create dusts, invoke sounds, and create lights. False will keep everything the same. True, you need to handle all animations in your own code. More...
 
- Public Member Functions inherited from GlobalType< Item, GlobalItem >
virtual bool AppliesToEntity (TEntity entity, bool lateInstantiation)
 Use this to control whether or not this global should be run on the provided entity instance.
More...
 
virtual TGlobal Clone (TEntity? from, TEntity to)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
TGlobal Instance (TEntity entity)
 
virtual ? TGlobal NewInstance (TEntity target)
 Only called if GlobalType<TGlobal>.InstancePerEntity and AppliesToEntity(target , ...) are both true.

Returning null is permitted but not recommended over AppliesToEntity for performance reasons.
Only return null when the global is disabled based on some runtime property (eg world seed). More...
 
virtual void SetDefaults (TEntity entity)
 Allows you to set the properties of any and every instance that gets created.
 

Protected Member Functions

sealed override void Register ()
 
override void ValidateType ()
 
- Protected Member Functions inherited from GlobalType< Item, GlobalItem >
override void Register ()
 If you make a new ModType, seal this override.
 
override void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties
 

Additional Inherited Members

- Static Public Member Functions inherited from GlobalType< Item, GlobalItem >
static TResult GetGlobal< TResult > (int entityType, ReadOnlySpan< TGlobal > entityGlobals)
 
static TResult GetGlobal< TResult > (int entityType, ReadOnlySpan< TGlobal > entityGlobals, TResult baseInstance)
 
static bool TryGetGlobal< TResult > (int entityType, ReadOnlySpan< TGlobal > entityGlobals, out TResult result)
 
static bool TryGetGlobal< TResult > (int entityType, ReadOnlySpan< TGlobal > entityGlobals, TResult baseInstance, out TResult result)
 
- Properties inherited from GlobalType< Item, GlobalItem >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone or via the default constructor Defaults to false (default constructor).
 
abstract bool ConditionallyAppliesToEntities [get]
 Whether this global applies to some entities but not others
 
sealed override bool ConditionallyAppliesToEntities [get]
 Whether this global applies to some entities but not others.
True if the type overrides AppliesToEntity(TEntity, bool)
 
virtual bool InstancePerEntity [get]
 Whether to create a new instance of this Global for every entity that exists. Useful for storing information on an entity. Defaults to false. Return true if you need to store information (have non-static fields).
 
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]
 
short PerEntityIndex [get, set]
 Index of this global in a IEntityWithGlobals<TGlobal>.EntityGlobals array
-1 if this global does not have a SlotPerEntity
 
virtual bool SlotPerEntity [get]
 If true, the global will be assigned a PerEntityIndex at load time, which can be used to access the instance in the IEntityWithGlobals<TGlobal>.EntityGlobals array.
If false, the global will be a singleton applying to all entities
 
short StaticIndex [get, set]
 Index of this global in the list of all globals of the same type, in registration order
 

Detailed Description

This class allows you to modify and use hooks for all items, both vanilla and modded.
To use it, simply create a new class deriving from this one. Implementations will be registered automatically.

Member Function Documentation

◆ AnglerChat()

virtual void GlobalItem.AnglerChat ( int  type,
ref string  chat,
ref string  catchLocation 
)
virtual

Allows you to set what the Angler says when the Quest button is clicked in his chat. The chat parameter is his dialogue, and catchLocation should be set to "Caught at [location]" for the given type.

This method is not instanced.

◆ ArmorArmGlowMask()

virtual void GlobalItem.ArmorArmGlowMask ( int  slot,
Player  drawPlayer,
float  shadow,
ref int  glowMask,
ref Color  color 
)
virtual

Allows you to modify which glow mask and in what color is drawn on the player's arms. Note that this is only called for body armor.

This method is not instanced.

◆ ArmorSetShadows()

virtual void GlobalItem.ArmorSetShadows ( Player  player,
string  set 
)
virtual

Allows you to determine special visual effects a vanity has on the player without having to code them yourself.

This method is not instanced.

player.armorEffectDrawShadow = true;

◆ CanAutoReuseItem()

virtual ? bool GlobalItem.CanAutoReuseItem ( Item  item,
Player  player 
)
virtual

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.

Parameters
itemThe item.
playerThe player.

◆ CanBeChosenAsAmmo()

virtual ? bool GlobalItem.CanBeChosenAsAmmo ( Item  ammo,
Item  weapon,
Player  player 
)
virtual

Whether or not the given ammo item is valid for the given weapon; called on the ammo. If this, or CanChooseAmmo on the weapon, returns false, then the ammo will not be valid for this weapon.
By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid.
If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called.

Parameters
ammoThe ammo that this hook is being called for.
weaponThe weapon attempting to select the ammo.
playerThe player which the weapon and this potential ammo belong to.
Returns

◆ CanBeConsumedAsAmmo()

virtual bool GlobalItem.CanBeConsumedAsAmmo ( Item  ammo,
Item  weapon,
Player  player 
)
virtual

Whether or not the given ammo item will be consumed; called on the ammo.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called.

Parameters
ammoThe ammo that this hook is being called for.
weaponThe weapon attempting to consume the ammo.
playerThe player which the weapon and this ammo belong to.
Returns

◆ CanCatchNPC()

virtual ? bool GlobalItem.CanCatchNPC ( Item  item,
NPC  target,
Player  player 
)
virtual

Allows you to determine whether the given item can catch the given NPC.
Return true or false to say the given NPC 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 an NPC-catching 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.

Parameters
itemThe item with which the player is trying to catch the target NPC.
targetThe NPC the player is trying to catch.
playerThe player attempting to catch the NPC.
Returns

◆ CanChooseAmmo()

virtual ? bool GlobalItem.CanChooseAmmo ( Item  weapon,
Item  ammo,
Player  player 
)
virtual

Whether or not the given ammo item is valid for the given weapon; called on the weapon. If this, or CanBeChosenAsAmmo on the ammo, returns false, then the ammo will not be valid for this weapon.
By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid.
If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called.

Parameters
weaponThe weapon that this hook is being called for.
ammoThe ammo that the weapon is attempting to select.
playerThe player which this weapon and the potential ammo belong to.
Returns

◆ CanConsumeAmmo()

virtual bool GlobalItem.CanConsumeAmmo ( Item  weapon,
Item  ammo,
Player  player 
)
virtual

Whether or not the given ammo item will be consumed; called on the weapon.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called.

Parameters
weaponThe weapon that this hook is being called for.
ammoThe ammo that the weapon is attempting to consume.
playerThe player which this weapon and the ammo belong to.
Returns

◆ CanConsumeBait()

virtual ? bool GlobalItem.CanConsumeBait ( Player  player,
Item  bait 
)
virtual

Allows you to choose if a given bait will be consumed by a given player Not consuming will always take priority over forced consumption

Parameters
baitThe bait being used
playerThe player using the item

◆ CanEquipAccessory()

virtual bool GlobalItem.CanEquipAccessory ( Item  item,
Player  player,
int  slot,
bool  modded 
)
virtual

Allows you to disallow the player from equipping an accessory. Return false to disallow equipping the accessory. Returns true by default.

Parameters
itemThe item that is attempting to equip.
playerThe player.
slotThe inventory slot that the item is attempting to occupy.
moddedIf the inventory slot index is for modded slots.

◆ CanMeleeAttackCollideWithNPC()

virtual ? bool GlobalItem.CanMeleeAttackCollideWithNPC ( Item  item,
Rectangle  meleeAttackHitbox,
Player  player,
NPC  target 
)
virtual

Allows you to determine whether a melee weapon can collide with the given NPC when swung.
Use CanHitNPC(Item, Player, NPC) instead for Flymeal-type effects.

Parameters
itemThe weapon item the player is holding.
meleeAttackHitboxHitbox of melee attack.
playerThe player wielding this item.
targetThe target npc.
Returns
Return true to allow colliding with target, return false to block the weapon from colliding with target, and return null to use the vanilla code for whether the target can be colliding. Returns null by default.

◆ CanResearch()

virtual bool GlobalItem.CanResearch ( Item  item)
virtual

Allows you to prevent an item from being researched by returning false. True is the default behavior.

Parameters
itemThe item being researched

◆ CanShoot()

virtual bool GlobalItem.CanShoot ( Item  item,
Player  player 
)
virtual

Allows you to prevent an item from shooting a projectile on use. Returns true by default.

Parameters
itemThe item being used.
playerThe player using the item.
Returns

◆ CanStack()

virtual bool GlobalItem.CanStack ( Item  destination,
Item  source 
)
virtual

Allows you to prevent items from stacking.
This is only called when two items of the same type attempt to stack.
This is usually not called for coins and ammo in the inventory/UI.
This covers all scenarios, if you just need to change in-world stacking behavior, use CanStackInWorld.

Parameters
destinationThe item instance that source will attempt to stack onto
sourceThe item instance being stacked onto destination
Returns
Whether or not the items are allowed to stack

◆ CanStackInWorld()

virtual bool GlobalItem.CanStackInWorld ( Item  destination,
Item  source 
)
virtual

Allows you to prevent items from stacking in the world.
This is only called when two items of the same type attempt to stack.

Parameters
destinationThe item instance that source will attempt to stack onto
sourceThe item instance being stacked onto destination
Returns
Whether or not the items are allowed to stack

◆ ChoosePrefix()

virtual int GlobalItem.ChoosePrefix ( Item  item,
UnifiedRandom  rand 
)
virtual

Allows you to manually choose what prefix an item will get.

Returns
The ID of the prefix to give the item, -1 to use default vanilla behavior

◆ DrawArmorColor()

virtual void GlobalItem.DrawArmorColor ( EquipType  type,
int  slot,
Player  drawPlayer,
float  shadow,
ref Color  color,
ref int  glowMask,
ref Color  glowMaskColor 
)
virtual

Allows you to modify the colors in which the player's armor and their surrounding accessories are drawn, in addition to which glow mask and in what color is drawn.

This method is not instanced.

◆ ExtractinatorUse()

virtual void GlobalItem.ExtractinatorUse ( int  extractType,
int  extractinatorBlockType,
ref int  resultType,
ref int  resultStack 
)
virtual

Allows you to modify what item, and in what quantity, is obtained when an item of the given type is fed into the Extractinator. Use ItemID.Sets.ExtractinatorMode to allow an item to be fed into the Extractinator. An extractType of 0 represents the default extraction (Silt and Slush). 0, ItemID.DesertFossil, ItemID.OldShoe, and ItemID.LavaMoss are vanilla extraction types. Modded types by convention will correspond to the iconic item of the extraction type. The Extractinator wiki pagehas more info. By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator. Use extractinatorBlockType to provide different behavior for TileID.ChlorophyteExtractinator if desired. If the Chlorophyte Extractinator item swapping behavior is desired, see the example in TorchExtractinatorGlobalItem.cs. This method is not instanced.

Parameters
extractTypeThe extractinator type corresponding to the items being processed
extractinatorBlockTypeWhich Extractinator tile is being used, TileID.Extractinator or TileID.ChlorophyteExtractinator.
resultTypeType of the result.
resultStackThe result stack.

◆ GetHealLife()

virtual void GlobalItem.GetHealLife ( Item  item,
Player  player,
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 Item.healLife value.

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

◆ GetHealMana()

virtual void GlobalItem.GetHealMana ( Item  item,
Player  player,
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 Item.healMana value.

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

◆ HoldoutOffset()

virtual ? Vector2 GlobalItem.HoldoutOffset ( int  type)
virtual

Allows you to determine the offset of an item's sprite when used by the player. This is only used for items with a useStyle of 5 that aren't staves. Return null to use the item's default holdout offset; returns null by default.

This method is not instanced.

return new Vector2(10, 0);

◆ HoldoutOrigin()

virtual ? Vector2 GlobalItem.HoldoutOrigin ( int  type)
virtual

Allows you to determine the point on an item's sprite that the player holds onto when using the item. The origin is from the bottom left corner of the sprite. This is only used for staves with a useStyle of 5. Return null to use the item's default holdout origin; returns null by default.

This method is not instanced.

◆ HoldStyle()

virtual void GlobalItem.HoldStyle ( Item  item,
Player  player,
Rectangle  heldItemFrame 
)
virtual

Allows you to modify the location and rotation of the item the player is currently holding.

Parameters
itemThe item.
playerThe player.
heldItemFrameThe source rectangle for the held item's texture.

◆ IsAnglerQuestAvailable()

virtual bool GlobalItem.IsAnglerQuestAvailable ( int  type)
virtual

Whether or not specific conditions have been satisfied for the Angler to be able to request the given item. (For example, Hardmode.) Returns true by default.

This method is not instanced.

◆ IsArmorSet()

virtual string GlobalItem.IsArmorSet ( Item  head,
Item  body,
Item  legs 
)
virtual

Allows you to determine whether the player is wearing an armor set, and return a name for this set. If there is no armor set, return the empty string. Returns the empty string by default.

This method is not instanced.

◆ IsVanitySet()

virtual string GlobalItem.IsVanitySet ( int  head,
int  body,
int  legs 
)
virtual

Returns whether or not the head armor, body armor, and leg armor textures make up a set. This hook is used for the PreUpdateVanitySet, UpdateVanitySet, and ArmorSetShadows hooks, and will use items in the social slots if they exist. By default this will return the same value as the IsArmorSet hook, so you will not have to use this hook unless you want vanity effects to be entirely separate from armor sets.

This method is not instanced.

◆ LoadData()

virtual void GlobalItem.LoadData ( Item  item,
TagCompound  tag 
)
virtual

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

Parameters
itemThe item.
tagThe TagCompound to load data from.

Reimplemented in UnloadedGlobalItem.

◆ ModifyItemLoot()

virtual void GlobalItem.ModifyItemLoot ( Item  item,
ItemLoot  itemLoot 
)
virtual

Allows you to add and modify the loot items that spawn from bag items when opened.
The Basic NPC Drops and Loot 1.4 Guideexplains how to use the ModNPC.ModifyNPCLoot(NPCLoot) hook to modify NPC loot as well as this hook. A common usage is to use this hook and ModNPC.ModifyNPCLoot(NPCLoot) to edit non-expert exclusive drops for bosses.
This hook only runs once per item type during mod loading, any dynamic behavior must be contained in the rules themselves.
This hook is not instanced.

Parameters
itemA default item of the type being opened, not the actual item instance
itemLootA reference to the item drop database for this item type

◆ ModifyItemScale()

virtual void GlobalItem.ModifyItemScale ( Item  item,
Player  player,
ref float  scale 
)
virtual

Allows you to dynamically modify the given item's size for the given player, similarly to the effect of the Titan Glove.

Do not modify Item.scale, modify the scale parameter.

Parameters
itemThe item to modify the scale of.
playerThe player wielding the given item.
scaleThe scale multiplier to be applied to the given item.
Will be 1.1 if the Titan Glove is equipped, and 1 otherwise.

◆ ModifyManaCost()

virtual void GlobalItem.ModifyManaCost ( Item  item,
Player  player,
ref float  reduce,
ref float  mult 
)
virtual

Allows you to temporarily modify the amount of mana an item will consume on use, based on player buffs, accessories, etc. This is only called for items with a mana value.

Do not modify Item.mana, modify the reduce and mult parameters.

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

◆ ModifyResearchSorting()

virtual void GlobalItem.ModifyResearchSorting ( Item  item,
ref ContentSamples.CreativeHelper.ItemGroup  itemGroup 
)
virtual

Allows you to set an item's sorting group in Journey Mode's duplication menu. This is useful for setting custom item types that group well together, or whenever the default vanilla sorting doesn't sort the way you want it. Note that this affects the order of the item in the listing, not which filters the item satisfies.

Parameters
itemThe item being used
itemGroupThe item group this item is being assigned to

◆ ModifyShootStats()

virtual void GlobalItem.ModifyShootStats ( Item  item,
Player  player,
ref Vector2  position,
ref Vector2  velocity,
ref int  type,
ref int  damage,
ref float  knockback 
)
virtual

Allows you to modify the position, velocity, type, damage and/or knockback of a projectile being shot by an item.
These parameters will be provided to Shoot(Item, Player, EntitySource_ItemUse_WithAmmo, Vector2, Vector2, int, int, float) where the projectile will actually be spawned.

Parameters
itemThe item being used.
playerThe player using the item.
positionThe center position of the projectile.
velocityThe velocity of the projectile.
typeThe ID of the projectile.
damageThe damage of the projectile.
knockbackThe knockback of the projectile.

◆ ModifyWeaponCrit()

virtual void GlobalItem.ModifyWeaponCrit ( Item  item,
Player  player,
ref float  crit 
)
virtual

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.

Do not modify Item.crit, modify the crit parameter.

Parameters
itemThe item being used.
playerThe player using the item.
critThe total crit chance of the item after all normal crit chance calculations.

◆ ModifyWeaponDamage()

virtual void GlobalItem.ModifyWeaponDamage ( Item  item,
Player  player,
ref StatModifier  damage 
)
virtual

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.

Do not modify Item.damage, modify the damage parameter.

Parameters
itemThe item being used.
playerThe player using the item.
damageThe StatModifier object representing the totality of the various modifiers to be applied to the item's base damage.

◆ ModifyWeaponKnockback()

virtual void GlobalItem.ModifyWeaponKnockback ( Item  item,
Player  player,
ref StatModifier  knockback 
)
virtual

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.

Do not modify Item.knockBack, modify the knockback parameter.

Parameters
itemThe item being used.
playerThe player using the item.
knockbackThe StatModifier object representing the totality of the various modifiers to be applied to the item's base knockback.

◆ OnCatchNPC()

virtual void GlobalItem.OnCatchNPC ( Item  item,
NPC  npc,
Player  player,
bool  failed 
)
virtual

Allows you to make things happen when the given item attempts to catch the given NPC.

Parameters
itemThe item used to catch the given NPC.
npcThe NPC which the player attempted to catch.
playerThe player attempting to catch the given NPC.
failedWhether or not the given NPC has been successfully caught.

◆ OnConsumeAmmo()

virtual void GlobalItem.OnConsumeAmmo ( Item  weapon,
Item  ammo,
Player  player 
)
virtual

Allows you to make things happen when the given ammo is consumed by the given weapon. Called by the weapon.
Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place.

Parameters
weaponThe currently-active weapon.
ammoThe ammo that the given weapon is currently using.
playerThe player which the given weapon and the given ammo belong to.

◆ OnConsumedAsAmmo()

virtual void GlobalItem.OnConsumedAsAmmo ( Item  ammo,
Item  weapon,
Player  player 
)
virtual

Allows you to make things happen when the given ammo is consumed by the given weapon. Called by the ammo.
Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place.

Parameters
ammoThe currently-active ammo.
weaponThe weapon that is currently using the given ammo.
playerThe player which the given weapon and the given ammo belong to.

◆ OnConsumeMana()

virtual void GlobalItem.OnConsumeMana ( Item  item,
Player  player,
int  manaConsumed 
)
virtual

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

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

◆ OnMissingMana()

virtual void GlobalItem.OnMissingMana ( Item  item,
Player  player,
int  neededMana 
)
virtual

Allows you to make stuff happen when a player doesn't have enough mana for an item they are trying to use. If the player has high enough mana after this hook runs, mana consumption will happen normally. Only runs once per item use.

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

◆ OnResearched()

virtual void GlobalItem.OnResearched ( Item  item,
bool  fullyResearched 
)
virtual

Allows you to create custom behavior when an item is accepted by the Research function

Parameters
itemThe item being researched
fullyResearchedTrue if the item was completely researched, and is ready to be duplicated, false if only partially researched.

◆ OnStack()

virtual void GlobalItem.OnStack ( Item  destination,
Item  source,
int  numToTransfer 
)
virtual

Allows you to make things happen when items stack together.
This hook is called before the items are transferred from source to destination

Parameters
destinationThe item instance that source will attempt to stack onto
sourceThe item instance being stacked onto destination
numToTransferThe quantity of source that will be transferred to destination

◆ PickAmmo()

virtual void GlobalItem.PickAmmo ( Item  weapon,
Item  ammo,
Player  player,
ref int  type,
ref float  speed,
ref StatModifier  damage,
ref float  knockback 
)
virtual

Allows you to modify various properties of the projectile created by a weapon based on the ammo it is using.

Parameters
weaponThe item that is using the given ammo.
ammoThe ammo item being used by the given weapon.
playerThe player using the item.
typeThe ID of the fired projectile.
speedThe speed of the fired projectile.
damageThe damage modifier for the projectile.
Total weapon damage is included as Flat damage.
Be careful not to apply flat or base damage bonuses which are already applied to the weapon.
knockbackThe knockback of the fired projectile.

◆ PostDrawTooltip()

virtual void GlobalItem.PostDrawTooltip ( Item  item,
ReadOnlyCollection< DrawableTooltipLine lines 
)
virtual

Allows you to do things after this item's tooltip is drawn. The lines contain draw information as this is ran after drawing the tooltip.

Parameters
itemThe item
linesThe tooltip lines for this item

◆ PostDrawTooltipLine()

virtual void GlobalItem.PostDrawTooltipLine ( Item  item,
DrawableTooltipLine  line 
)
virtual

Allows you to do things after a tooltip line of this item is drawn. The line contains draw info.

Parameters
itemThe item
lineThe line that was drawn

◆ PreDrawTooltip()

virtual bool GlobalItem.PreDrawTooltip ( Item  item,
ReadOnlyCollection< TooltipLine lines,
ref int  x,
ref int  y 
)
virtual

Allows you to do things before this item's tooltip is drawn.

Parameters
itemThe item
linesThe tooltip lines for this item
xThe top X position for this tooltip. It is where the first line starts drawing
yThe top Y position for this tooltip. It is where the first line starts drawing
Returns
Whether or not to draw this tooltip

◆ PreDrawTooltipLine()

virtual bool GlobalItem.PreDrawTooltipLine ( Item  item,
DrawableTooltipLine  line,
ref int  yOffset 
)
virtual

Allows you to do things before a tooltip line of this item is drawn. The line contains draw info.

Parameters
itemThe item
lineThe line that would be drawn
yOffsetThe Y offset added for next tooltip lines
Returns
Whether or not to draw this tooltip line

◆ PrefixChance()

virtual ? bool GlobalItem.PrefixChance ( Item  item,
int  pre,
UnifiedRandom  rand 
)
virtual

To prevent putting the item in the tinkerer slot, return false when pre is -3. To prevent rolling of a prefix on spawn, return false when pre is -1. To force rolling of a prefix on spawn, return true when pre is -1.

To reduce the probability of a prefix on spawn (pre == -1) to X%, return false 100-4X % of the time. To increase the probability of a prefix on spawn (pre == -1) to X%, return true (4X-100)/3 % of the time.

To delete a prefix from an item when the item is loaded, return false when pre is the prefix you want to delete. Use AllowPrefix to prevent rolling of a certain prefix.

Parameters
item
preThe prefix being applied to the item, or the roll mode. -1 is when the item is naturally generated in a chest, crafted, purchased from an NPC, looted from a grab bag (excluding presents), or dropped by a slain enemy (if it's spawned with prefixGiven: -1). -2 is when the item is rolled in the tinkerer. -3 determines if the item can be placed in the tinkerer slot.
rand
Returns

◆ PreUpdateVanitySet()

virtual void GlobalItem.PreUpdateVanitySet ( Player  player,
string  set 
)
virtual

Allows you to create special effects (such as the necro armor's hurt noise) when the player wears the vanity set with the given name returned by IsVanitySet. This hook is called regardless of whether the player is frozen in any way.

This method is not instanced.

◆ SaveData()

virtual void GlobalItem.SaveData ( Item  item,
TagCompound  tag 
)
virtual

Allows you to save custom data for this item.

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
itemThe item.
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 in UnloadedGlobalItem.

◆ SetMatch()

virtual void GlobalItem.SetMatch ( int  armorSlot,
int  type,
bool  male,
ref int  equipSlot,
ref bool  robes 
)
virtual

Allows you to modify the equipment that the player appears to be wearing.

Note that type and equipSlot are not the same as the item type of the armor the player will appear to be wearing. Worn equipment has a separate set of IDs. You can find the vanilla equipment IDs by looking at the headSlot, bodySlot, and legSlot fields for items, and modded equipment IDs by looking at EquipLoader.

This method is not instanced.

Parameters
armorSlothead armor (0), body armor (1) or leg armor (2).
typeThe equipment texture ID of the item that the player is wearing.
maleTrue if the player is male.
equipSlotThe altered equipment texture ID for the legs (armorSlot 1 and 2) or head (armorSlot 0)
robesSet to true if you modify equipSlot when armorSlot == 1 to set Player.wearsRobe, otherwise ignore it

◆ Shoot()

virtual bool GlobalItem.Shoot ( Item  item,
Player  player,
EntitySource_ItemUse_WithAmmo  source,
Vector2  position,
Vector2  velocity,
int  type,
int  damage,
float  knockback 
)
virtual

Allows you to modify an item's shooting mechanism. Return false to prevent vanilla's shooting code from running. Returns true by default.
This method is called after the ModifyShootStats hook has had a chance to adjust the spawn parameters.

Parameters
itemThe item being used.
playerThe player using the item.
sourceThe projectile source's information.
positionThe center position of the projectile.
velocityThe velocity of the projectile.
typeThe ID of the projectile.
damageThe damage of the projectile.
knockbackThe knockback of the projectile.

◆ SplitStack()

virtual void GlobalItem.SplitStack ( Item  destination,
Item  source,
int  numToTransfer 
)
virtual

Allows you to make things happen when an item stack is split. This hook is called before the stack values are modified.

Parameters
destinationThe item instance that source will transfer items to, and is usually a clone of source .
This parameter's stack will always be zero.
sourceThe item instance being stacked onto destination
numToTransferThe quantity of source that will be transferred to to destination

◆ UpdateArmorSet()

virtual void GlobalItem.UpdateArmorSet ( Player  player,
string  set 
)
virtual

Allows you to give set bonuses to your armor set with the given name. The set name will be the same as returned by IsArmorSet.

This method is not instanced.

◆ UpdateVanitySet()

virtual void GlobalItem.UpdateVanitySet ( Player  player,
string  set 
)
virtual

Allows you to create special effects (such as dust) when the player wears the vanity set with the given name returned by IsVanitySet. This hook will only be called if the player is not frozen in any way.

This method is not instanced.

◆ UseAnimationMultiplier()

virtual float GlobalItem.UseAnimationMultiplier ( Item  item,
Player  player 
)
virtual

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.

Returns
The multiplier on the animation time. 1f by default. Values greater than 1 increase the item animation's length.

◆ UseSpeedMultiplier()

virtual float GlobalItem.UseSpeedMultiplier ( Item  item,
Player  player 
)
virtual

Allows you to safely change both useTime and useAnimation while keeping the values relative to each other.
Useful for status effects.

Returns
The multiplier on the use speed. 1f by default. Values greater than 1 increase the overall item speed.

◆ UseStyle()

virtual void GlobalItem.UseStyle ( Item  item,
Player  player,
Rectangle  heldItemFrame 
)
virtual

Allows you to modify the location and rotation of any item in its use animation.

Parameters
itemThe item.
playerThe player.
heldItemFrameThe source rectangle for the held item's texture.

◆ UseTimeMultiplier()

virtual float GlobalItem.UseTimeMultiplier ( Item  item,
Player  player 
)
virtual

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.

Returns
The multiplier on the usage time. 1f by default. Values greater than 1 increase the item use's length.

◆ WingUpdate()

virtual bool GlobalItem.WingUpdate ( int  wings,
Player  player,
bool  inUse 
)
virtual

Allows for Wings to do various things while in use. "inUse" is whether or not the jump button is currently pressed. Called when wings visually appear on the player. Use to animate wings, create dusts, invoke sounds, and create lights. False will keep everything the same. True, you need to handle all animations in your own code.

This method is not instanced.