tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.GlobalItem Class Reference

This class allows you to modify and use hooks for all items, including vanilla items. Create an instance of an overriding class then call Mod.AddGlobalItem to use this. More...

Inherits Terraria.ModLoader.GlobalType< Item >.

Inherited by Terraria.ModLoader.Default.UnloadedGlobalItem.

Public Member Functions

virtual void AddRecipes ()
 This is essentially the same as Mod.AddRecipes or ModItem.AddRecipes. Use whichever method makes organizational sense for your mod. More...
 
virtual bool AllowPrefix (Item item, int pre)
 Force a re-roll of a prefix by returning false. More...
 
virtual bool AltFunctionUse (Item item, Player player)
 Allows you to make an item usable by right-clicking. Returns false by default. When the item is used by right-clicking, player.altFunctionUse will be set to 2. More...
 
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 CanBeConsumedAsAmmo (Item ammo, Player player)
 Whether or not ammo will be consumed upon usage. Called by the ammo; if at least one of this and CanConsumeAmmo returns false then the ammo will not be used. By default returns true. If false is returned, the OnConsumeAmmo hook is never called. More...
 
virtual ? bool CanBurnInLava (Item item)
 Returns whether or not this item will burn in lava regardless of any conditions. Returns null by default (follow vanilla behaviour). More...
 
virtual bool CanConsumeAmmo (Item weapon, Player player)
 Whether or not ammo will be consumed upon usage. Called by the weapon; if at least one of this and CanBeConsumedAsAmmo returns false then the ammo will not be used. By default returns true. If false is returned, the OnConsumeAmmo hook is never called. More...
 
virtual bool CanEquipAccessory (Item item, Player player, int slot)
 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. More...
 
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. More...
 
virtual bool CanPickup (Item item, Player player)
 Allows you to determine whether or not the item can be picked up More...
 
virtual bool CanRightClick (Item item)
 Returns whether or not an item does something when right-clicked in the inventory. Returns false by default. More...
 
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 CanStackInWorld (Item item1, Item item2)
 Allows you to prevent vanilla 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. More...
 
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. More...
 
virtual int ChoosePrefix (Item item, UnifiedRandom rand)
 Allows you to manually choose what prefix an item will get. More...
 
virtual GlobalItem Clone (Item item, Item itemClone)
 Create a copy of this instanced GlobalItem. Called when an item is cloned. 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. More...
 
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 bool DrawBody (int body)
 Return false to hide the player's body when a body armor is worn. Returns true by default. "body" is the player's associated body equipment texture. This method is not instanced. More...
 
virtual void DrawHair (int head, ref bool drawHair, ref bool drawAltHair)
 Allows you to determine whether the player's hair or alt (hat) hair will be drawn when a head armor is worn. "head" is the player's associated head equipment texture. This method is not instanced. More...
 
virtual void DrawHands (int body, ref bool drawHands, ref bool drawArms)
 Allows you to determine whether the skin/shirt on the player's arms and hands are drawn when a body armor is worn. Note that if drawHands is false, the arms will not be drawn either. "body" is the player's associated body equipment texture. This method is not instanced. More...
 
virtual bool DrawHead (int head)
 Return false to hide the player's head when a head armor is worn. Returns true by default. "head" is the player's associated head equipment texture. This method is not instanced. More...
 
virtual bool DrawLegs (int legs, int shoes)
 Return false to hide the player's legs when a leg armor or shoe accessory is worn. Returns true by default. "legs" and "shoes" are the player's associated legs and shoes equipment textures. This method is not instanced. More...
 
virtual void ExtractinatorUse (int extractType, 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. An extractType of 0 represents the default extraction (Silt and Slush). By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator. 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. More...
 
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 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 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. More...
 
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. More...
 
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). More...
 
virtual void HoldItemFrame (Item item, Player player)
 Allows you to modify the player's animation when the player is holding an item. More...
 
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. More...
 
GlobalItem Instance (Item item)
 
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 ArmorSetShadow 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. More...
 
virtual void Load (Item item, TagCompound tag)
 Allows you to load custom data that you have saved for the given item. More...
 
virtual void MeleeEffects (Item item, Player player, Rectangle hitbox)
 Allows you to give melee weapons special effects, such as creating light or dust. More...
 
virtual void ModifyHitNPC (Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
 Allows you to modify the damage, knockback, etc., that a melee weapon does to an NPC. More...
 
virtual void ModifyHitPvp (Item item, Player player, Player target, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that a melee weapon does to a player. 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. 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. 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. 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. More...
 
virtual void ModifyWeaponCrit (Item item, Player player, ref int crit)
 Allows you to temporarily modify this weapon's crit chance based on player buffs, etc. More...
 
virtual void ModifyWeaponDamage (Item item, Player player, ref StatModifier damage, ref float flat)
 Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts). More...
 
virtual void ModifyWeaponKnockback (Item item, Player player, ref StatModifier knockback, ref float flat)
 Allows you to temporarily modify this weapon's knockback based on player buffs, etc. This allows you to customize knockback beyond the Player class's limited fields. More...
 
virtual bool NeedsSaving (Item item)
 Whether or not the given item needs to save custom data. Returning false will save on the memory used in saving an item, but returning true is necessary in order to save data across all items or vanilla items. Returns false by default. Note that the return value of this hook must be deterministic (randomness is not allowed). More...
 
virtual void NetReceive (Item item, BinaryReader reader)
 
virtual void NetSend (Item item, BinaryWriter writer)
 Allows you to send custom data for the given item between client and server. More...
 
virtual void OnConsumeAmmo (Item weapon, Player player)
 Allows you to make things happen when ammo is consumed. Called by the weapon.
Called before the ammo stack is reduced. More...
 
virtual void OnConsumedAsAmmo (Item ammo, Player player)
 Allows you to make things happen when ammo is consumed. Called by the ammo.
Called before the ammo stack is reduced. 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. More...
 
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 OnCreate (Item item, ItemCreationContext context)
 
virtual void OnHitNPC (Item item, Player player, NPC target, int damage, float knockBack, bool crit)
 Allows you to create special effects when a melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads). More...
 
virtual void OnHitPvp (Item item, Player player, Player target, int damage, bool crit)
 Allows you to create special effects when a melee weapon hits a player. More...
 
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. More...
 
virtual void OpenVanillaBag (string context, Player player, int arg)
 Allows you to make vanilla bags drop your own items in addition to the default items. This method will not be called if any other GlobalItem returns false for PreOpenVanillaBag. Context will either be "present", "bossBag", "crate", "lockBox", "obsidianLockBox", "herbBag", or "goodieBag". For boss bags and crates, arg will be set to the type of the item being opened. This method is also called for modded bossBags that are properly implemented. More...
 
virtual void PickAmmo (Item weapon, Item ammo, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
 Allows you to modify 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)
 Allows you to draw things in front of an item in the inventory. This method is called even if PreDrawInInventory returns false. More...
 
virtual void PostDrawInWorld (Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
 Allows you to draw things in front of an item. This method is called even if PreDrawInWorld returns false. More...
 
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. More...
 
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. More...
 
virtual bool PreDrawInInventory (Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
 Allows you to draw things behind an item in the inventory. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default. More...
 
virtual bool PreDrawInWorld (Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
 Allows you to draw things behind an item, or to modify the way an item is drawn in the world. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default. More...
 
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 bool PreOpenVanillaBag (string context, Player player, int arg)
 Allows you to make vanilla bags drop your own items and stop the default items from being dropped. Return false to stop the default items from being dropped; returns true by default. Context will either be "present", "bossBag", "crate", "lockBox", "obsidianLockBox", "herbBag", or "goodieBag". For boss bags and crates, arg will be set to the type of the item being opened. This method is also called for modded bossBags that are properly implemented. More...
 
virtual bool PreReforge (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, the PostReforge hook is never called. Reforging preserves modded data on the item. More...
 
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. More...
 
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. More...
 
virtual TagCompound Save (Item item)
 Allows you to save custom data for the given item. Only called when NeedsCustomSaving returns true. Returns false by default. More...
 
virtual void SetDefaults (Item item)
 Allows you to set the properties of any and every item that gets created. 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 ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual bool Shoot (Item item, Player player, ProjectileSource_Item_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 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. More...
 
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. More...
 
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. More...
 
virtual void UpdateInventory (Item item, Player player)
 Allows you to make things happen when an item is in the player's inventory (for example, how the cell phone makes information display). More...
 
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 More...
 
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. More...
 
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. More...
 
virtual void UseItemFrame (Item item, Player player)
 Allows you to modify the player's animation when an item is being used. More...
 
virtual void UseItemHitbox (Item item, Player player, ref Rectangle hitbox, ref bool noHitbox)
 Changes the hitbox of a melee weapon when it is used. More...
 
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. More...
 
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 Terraria.ModLoader.GlobalType< Item >
virtual bool AppliesToEntity (TEntity entity, bool lateInstantiation)
 Use this to control whether or not this global should be associated with the provided entity instance. More...
 
- Public Member Functions inherited from Terraria.ModLoader.ModType
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 void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Protected Member Functions

sealed override void Register ()
 If you make a new ModType, seal this override. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Terraria.ModLoader.GlobalType< Item >
static TResult GetGlobal< TEntity, TGlobal, TResult > (Instanced< TGlobal >[] globals, bool exactType)
 
static TResult GetGlobal< TEntity, TGlobal, TResult > (Instanced< TGlobal >[] globals, TResult baseInstance)
 
static T Instance< T > (Instanced< T >[] globals, ushort index)
 
static bool TryGetGlobal< TGlobal, TResult > (Instanced< TGlobal >[] globals, bool exactType, out TResult result)
 
static bool TryGetGlobal< TGlobal, TResult > (Instanced< TGlobal >[] globals, TResult baseInstance, out TResult result)
 
- Properties inherited from Terraria.ModLoader.GlobalType< Item >
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). More...
 
- Properties inherited from Terraria.ModLoader.ModType
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from Terraria.ModLoader.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...
 

Detailed Description

This class allows you to modify and use hooks for all items, including vanilla items. Create an instance of an overriding class then call Mod.AddGlobalItem to use this.

Member Function Documentation

◆ AddRecipes()

virtual void Terraria.ModLoader.GlobalItem.AddRecipes ( )
virtual

This is essentially the same as Mod.AddRecipes or ModItem.AddRecipes. Use whichever method makes organizational sense for your mod.

◆ AllowPrefix()

virtual bool Terraria.ModLoader.GlobalItem.AllowPrefix ( Item  item,
int  pre 
)
virtual

Force a re-roll of a prefix by returning false.

◆ AltFunctionUse()

virtual bool Terraria.ModLoader.GlobalItem.AltFunctionUse ( Item  item,
Player  player 
)
virtual

Allows you to make an item usable by right-clicking. Returns false by default. When the item is used by right-clicking, player.altFunctionUse will be set to 2.

◆ AnglerChat()

virtual void Terraria.ModLoader.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 Terraria.ModLoader.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 Terraria.ModLoader.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;

◆ CanBeConsumedAsAmmo()

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

Whether or not ammo will be consumed upon usage. Called by the ammo; if at least one of this and CanConsumeAmmo returns false then the ammo will not be used. By default returns true. If false is returned, the OnConsumeAmmo hook is never called.

Parameters
ammoThe ammo item
playerThe player consuming the ammo

◆ CanBurnInLava()

virtual ? bool Terraria.ModLoader.GlobalItem.CanBurnInLava ( Item  item)
virtual

Returns whether or not this item will burn in lava regardless of any conditions. Returns null by default (follow vanilla behaviour).

◆ CanConsumeAmmo()

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

Whether or not ammo will be consumed upon usage. Called by the weapon; if at least one of this and CanBeConsumedAsAmmo returns false then the ammo will not be used. By default returns true. If false is returned, the OnConsumeAmmo hook is never called.

Parameters
weaponThe item that the player is using
playerThe player using the item

◆ CanEquipAccessory()

virtual bool Terraria.ModLoader.GlobalItem.CanEquipAccessory ( Item  item,
Player  player,
int  slot 
)
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 attepting to equip.
playerThe player.
slotThe inventory slot that the item is attempting to occupy.

◆ CanHitNPC()

virtual ? bool Terraria.ModLoader.GlobalItem.CanHitNPC ( Item  item,
Player  player,
NPC  target 
)
virtual

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.

◆ CanHitPvp()

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

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.

◆ CanPickup()

virtual bool Terraria.ModLoader.GlobalItem.CanPickup ( Item  item,
Player  player 
)
virtual

Allows you to determine whether or not the item can be picked up

◆ CanRightClick()

virtual bool Terraria.ModLoader.GlobalItem.CanRightClick ( Item  item)
virtual

Returns whether or not an item does something when right-clicked in the inventory. Returns false by default.

◆ CanShoot()

virtual bool Terraria.ModLoader.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

◆ CanStackInWorld()

virtual bool Terraria.ModLoader.GlobalItem.CanStackInWorld ( Item  item1,
Item  item2 
)
virtual

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

Parameters
item1The item that is attempting to stack
item2The item that the other item is attempting to stack with
Returns
Whether or not the items are allowed to stack

◆ CanUseItem()

virtual bool Terraria.ModLoader.GlobalItem.CanUseItem ( Item  item,
Player  player 
)
virtual

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.

◆ CaughtFishStack()

virtual void Terraria.ModLoader.GlobalItem.CaughtFishStack ( int  type,
ref int  stack 
)
virtual

Allows you to modify how many of an item a player obtains when the player fishes that item.

◆ ChoosePrefix()

virtual int Terraria.ModLoader.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

◆ Clone()

virtual GlobalItem Terraria.ModLoader.GlobalItem.Clone ( Item  item,
Item  itemClone 
)
virtual

Create a copy of this instanced GlobalItem. Called when an item is cloned.

Parameters
itemThe item being cloned
itemCloneThe new item

Reimplemented in Terraria.ModLoader.Default.UnloadedGlobalItem.

◆ ConsumeItem()

virtual bool Terraria.ModLoader.GlobalItem.ConsumeItem ( Item  item,
Player  player 
)
virtual

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.

◆ DrawArmorColor()

virtual void Terraria.ModLoader.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.

◆ DrawBody()

virtual bool Terraria.ModLoader.GlobalItem.DrawBody ( int  body)
virtual

Return false to hide the player's body when a body armor is worn. Returns true by default. "body" is the player's associated body equipment texture. This method is not instanced.

◆ DrawHair()

virtual void Terraria.ModLoader.GlobalItem.DrawHair ( int  head,
ref bool  drawHair,
ref bool  drawAltHair 
)
virtual

Allows you to determine whether the player's hair or alt (hat) hair will be drawn when a head armor is worn. "head" is the player's associated head equipment texture. This method is not instanced.

◆ DrawHands()

virtual void Terraria.ModLoader.GlobalItem.DrawHands ( int  body,
ref bool  drawHands,
ref bool  drawArms 
)
virtual

Allows you to determine whether the skin/shirt on the player's arms and hands are drawn when a body armor is worn. Note that if drawHands is false, the arms will not be drawn either. "body" is the player's associated body equipment texture. This method is not instanced.

◆ DrawHead()

virtual bool Terraria.ModLoader.GlobalItem.DrawHead ( int  head)
virtual

Return false to hide the player's head when a head armor is worn. Returns true by default. "head" is the player's associated head equipment texture. This method is not instanced.

◆ DrawLegs()

virtual bool Terraria.ModLoader.GlobalItem.DrawLegs ( int  legs,
int  shoes 
)
virtual

Return false to hide the player's legs when a leg armor or shoe accessory is worn. Returns true by default. "legs" and "shoes" are the player's associated legs and shoes equipment textures. This method is not instanced.

◆ ExtractinatorUse()

virtual void Terraria.ModLoader.GlobalItem.ExtractinatorUse ( int  extractType,
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. An extractType of 0 represents the default extraction (Silt and Slush). By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator.

This method is not instanced.

◆ GetAlpha()

virtual ? Color Terraria.ModLoader.GlobalItem.GetAlpha ( Item  item,
Color  lightColor 
)
virtual

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.

◆ GetHealLife()

virtual void Terraria.ModLoader.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 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 Terraria.ModLoader.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 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.

◆ GrabRange()

virtual void Terraria.ModLoader.GlobalItem.GrabRange ( Item  item,
Player  player,
ref int  grabRange 
)
virtual

Allows you to modify how close an item must be to the player in order to move towards the player.

◆ GrabStyle()

virtual bool Terraria.ModLoader.GlobalItem.GrabStyle ( Item  item,
Player  player 
)
virtual

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.

◆ HoldItem()

virtual void Terraria.ModLoader.GlobalItem.HoldItem ( Item  item,
Player  player 
)
virtual

Allows you to make things happen when the player is holding an item (for example, torches make light and water candles increase spawn rate).

◆ HoldItemFrame()

virtual void Terraria.ModLoader.GlobalItem.HoldItemFrame ( Item  item,
Player  player 
)
virtual

Allows you to modify the player's animation when the player is holding an item.

◆ HoldoutOffset()

virtual ? Vector2 Terraria.ModLoader.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 Terraria.ModLoader.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 Terraria.ModLoader.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.

◆ HorizontalWingSpeeds()

virtual void Terraria.ModLoader.GlobalItem.HorizontalWingSpeeds ( Item  item,
Player  player,
ref float  speed,
ref float  acceleration 
)
virtual

Allows you to modify the horizontal flight speed and acceleration of wings.

◆ IsAnglerQuestAvailable()

virtual bool Terraria.ModLoader.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 Terraria.ModLoader.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 Terraria.ModLoader.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 ArmorSetShadow 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.

◆ ItemSpace()

virtual bool Terraria.ModLoader.GlobalItem.ItemSpace ( Item  item,
Player  player 
)
virtual

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.

◆ Load()

virtual void Terraria.ModLoader.GlobalItem.Load ( Item  item,
TagCompound  tag 
)
virtual

Allows you to load custom data that you have saved for the given item.

Reimplemented in Terraria.ModLoader.Default.UnloadedGlobalItem.

◆ MeleeEffects()

virtual void Terraria.ModLoader.GlobalItem.MeleeEffects ( Item  item,
Player  player,
Rectangle  hitbox 
)
virtual

Allows you to give melee weapons special effects, such as creating light or dust.

◆ ModifyHitNPC()

virtual void Terraria.ModLoader.GlobalItem.ModifyHitNPC ( Item  item,
Player  player,
NPC  target,
ref int  damage,
ref float  knockBack,
ref bool  crit 
)
virtual

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

◆ ModifyHitPvp()

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

Allows you to modify the damage, etc., that a melee weapon does to a player.

◆ ModifyManaCost()

virtual void Terraria.ModLoader.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.

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 Terraria.ModLoader.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.

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

◆ ModifyShootStats()

virtual void Terraria.ModLoader.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.

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.

◆ ModifyTooltips()

virtual void Terraria.ModLoader.GlobalItem.ModifyTooltips ( Item  item,
List< TooltipLine tooltips 
)
virtual

Allows you to modify all the tooltips that display for the given item. See here for information about TooltipLine.

◆ ModifyWeaponCrit()

virtual void Terraria.ModLoader.GlobalItem.ModifyWeaponCrit ( Item  item,
Player  player,
ref int  crit 
)
virtual

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

Parameters
itemThe item being used
playerThe player using the item
critThe critical strike chance

◆ ModifyWeaponDamage()

virtual void Terraria.ModLoader.GlobalItem.ModifyWeaponDamage ( Item  item,
Player  player,
ref StatModifier  damage,
ref float  flat 
)
virtual

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

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

◆ ModifyWeaponKnockback()

virtual void Terraria.ModLoader.GlobalItem.ModifyWeaponKnockback ( Item  item,
Player  player,
ref StatModifier  knockback,
ref float  flat 
)
virtual

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

Parameters
itemThe item being used
playerThe player using the item
knockbackThe knockback

◆ NeedsSaving()

virtual bool Terraria.ModLoader.GlobalItem.NeedsSaving ( Item  item)
virtual

Whether or not the given item needs to save custom data. Returning false will save on the memory used in saving an item, but returning true is necessary in order to save data across all items or vanilla items. Returns false by default. Note that the return value of this hook must be deterministic (randomness is not allowed).

Reimplemented in Terraria.ModLoader.Default.UnloadedGlobalItem.

◆ NetReceive()

virtual void Terraria.ModLoader.GlobalItem.NetReceive ( Item  item,
BinaryReader  reader 
)
virtual

◆ NetSend()

virtual void Terraria.ModLoader.GlobalItem.NetSend ( Item  item,
BinaryWriter  writer 
)
virtual

Allows you to send custom data for the given item between client and server.

◆ OnConsumeAmmo()

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

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

Parameters
weaponThe item that the player is using
playerThe player consuming the ammo

◆ OnConsumedAsAmmo()

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

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

Parameters
ammoThe ammo item
playerThe player consuming the ammo

◆ OnConsumeItem()

virtual void Terraria.ModLoader.GlobalItem.OnConsumeItem ( Item  item,
Player  player 
)
virtual

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

◆ OnConsumeMana()

virtual void Terraria.ModLoader.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.

◆ OnHitNPC()

virtual void Terraria.ModLoader.GlobalItem.OnHitNPC ( Item  item,
Player  player,
NPC  target,
int  damage,
float  knockBack,
bool  crit 
)
virtual

Allows you to create special effects when a melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads).

◆ OnHitPvp()

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

Allows you to create special effects when a melee weapon hits a player.

◆ OnMissingMana()

virtual void Terraria.ModLoader.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.

◆ OnPickup()

virtual bool Terraria.ModLoader.GlobalItem.OnPickup ( Item  item,
Player  player 
)
virtual

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.

◆ OpenVanillaBag()

virtual void Terraria.ModLoader.GlobalItem.OpenVanillaBag ( string  context,
Player  player,
int  arg 
)
virtual

Allows you to make vanilla bags drop your own items in addition to the default items. This method will not be called if any other GlobalItem returns false for PreOpenVanillaBag. Context will either be "present", "bossBag", "crate", "lockBox", "obsidianLockBox", "herbBag", or "goodieBag". For boss bags and crates, arg will be set to the type of the item being opened. This method is also called for modded bossBags that are properly implemented.

This method is not instanced.

◆ PickAmmo()

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

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

Parameters
weaponThe item that is using this ammo
ammoThe ammo item
playerThe player using the item
typeThe ID of the projectile shot
speedThe speed of the projectile shot
damageThe damage of the projectile shot
knockbackThe speed of the projectile shot

◆ PostDrawInInventory()

virtual void Terraria.ModLoader.GlobalItem.PostDrawInInventory ( Item  item,
SpriteBatch  spriteBatch,
Vector2  position,
Rectangle  frame,
Color  drawColor,
Color  itemColor,
Vector2  origin,
float  scale 
)
virtual

Allows you to draw things in front of an item in the inventory. This method is called even if PreDrawInInventory returns false.

◆ PostDrawInWorld()

virtual void Terraria.ModLoader.GlobalItem.PostDrawInWorld ( Item  item,
SpriteBatch  spriteBatch,
Color  lightColor,
Color  alphaColor,
float  rotation,
float  scale,
int  whoAmI 
)
virtual

Allows you to draw things in front of an item. This method is called even if PreDrawInWorld returns false.

◆ PostDrawTooltip()

virtual void Terraria.ModLoader.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 Terraria.ModLoader.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

◆ PostReforge()

virtual void Terraria.ModLoader.GlobalItem.PostReforge ( Item  item)
virtual

This hook gets called immediately after an item gets reforged by the Goblin Tinkerer. Useful for modifying modded data based on the reforge result.

◆ PostUpdate()

virtual void Terraria.ModLoader.GlobalItem.PostUpdate ( Item  item)
virtual

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.

◆ PreDrawInInventory()

virtual bool Terraria.ModLoader.GlobalItem.PreDrawInInventory ( Item  item,
SpriteBatch  spriteBatch,
Vector2  position,
Rectangle  frame,
Color  drawColor,
Color  itemColor,
Vector2  origin,
float  scale 
)
virtual

Allows you to draw things behind an item in the inventory. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default.

◆ PreDrawInWorld()

virtual bool Terraria.ModLoader.GlobalItem.PreDrawInWorld ( Item  item,
SpriteBatch  spriteBatch,
Color  lightColor,
Color  alphaColor,
ref float  rotation,
ref float  scale,
int  whoAmI 
)
virtual

Allows you to draw things behind an item, or to modify the way an item is drawn in the world. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default.

◆ PreDrawTooltip()

virtual bool Terraria.ModLoader.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 Terraria.ModLoader.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 Terraria.ModLoader.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
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.
Returns

◆ PreOpenVanillaBag()

virtual bool Terraria.ModLoader.GlobalItem.PreOpenVanillaBag ( string  context,
Player  player,
int  arg 
)
virtual

Allows you to make vanilla bags drop your own items and stop the default items from being dropped. Return false to stop the default items from being dropped; returns true by default. Context will either be "present", "bossBag", "crate", "lockBox", "obsidianLockBox", "herbBag", or "goodieBag". For boss bags and crates, arg will be set to the type of the item being opened. This method is also called for modded bossBags that are properly implemented.

This method is not instanced.

◆ PreReforge()

virtual bool Terraria.ModLoader.GlobalItem.PreReforge ( Item  item)
virtual

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, the PostReforge hook is never called. Reforging preserves modded data on the item.

◆ PreUpdateVanitySet()

virtual void Terraria.ModLoader.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.

◆ ReforgePrice()

virtual bool Terraria.ModLoader.GlobalItem.ReforgePrice ( Item  item,
ref int  reforgePrice,
ref bool  canApplyDiscount 
)
virtual

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.

◆ Register()

sealed override void Terraria.ModLoader.GlobalItem.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements Terraria.ModLoader.ModType.

◆ RightClick()

virtual void Terraria.ModLoader.GlobalItem.RightClick ( Item  item,
Player  player 
)
virtual

Allows you to make things happen when an item is right-clicked in the inventory. Useful for goodie bags.

◆ Save()

virtual TagCompound Terraria.ModLoader.GlobalItem.Save ( Item  item)
virtual

Allows you to save custom data for the given item. Only called when NeedsCustomSaving returns true. Returns false by default.

Reimplemented in Terraria.ModLoader.Default.UnloadedGlobalItem.

◆ SetDefaults()

virtual void Terraria.ModLoader.GlobalItem.SetDefaults ( Item  item)
virtual

Allows you to set the properties of any and every item that gets created.

◆ SetMatch()

virtual void Terraria.ModLoader.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.
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

◆ SetupContent()

sealed override void Terraria.ModLoader.GlobalItem.SetupContent ( )
virtual

If you make a new ModType, seal this override, and call SetStaticDefaults in it.

Reimplemented from Terraria.ModLoader.ModType.

◆ Shoot()

virtual bool Terraria.ModLoader.GlobalItem.Shoot ( Item  item,
Player  player,
ProjectileSource_Item_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.

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.

◆ Update()

virtual void Terraria.ModLoader.GlobalItem.Update ( Item  item,
ref float  gravity,
ref float  maxFallSpeed 
)
virtual

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.

◆ UpdateAccessory()

virtual void Terraria.ModLoader.GlobalItem.UpdateAccessory ( Item  item,
Player  player,
bool  hideVisual 
)
virtual

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.

◆ UpdateArmorSet()

virtual void Terraria.ModLoader.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.

◆ UpdateEquip()

virtual void Terraria.ModLoader.GlobalItem.UpdateEquip ( Item  item,
Player  player 
)
virtual

Allows you to give effects to armors and accessories, such as increased damage.

◆ UpdateInventory()

virtual void Terraria.ModLoader.GlobalItem.UpdateInventory ( Item  item,
Player  player 
)
virtual

Allows you to make things happen when an item is in the player's inventory (for example, how the cell phone makes information display).

◆ UpdateVanity()

virtual void Terraria.ModLoader.GlobalItem.UpdateVanity ( Item  item,
Player  player 
)
virtual

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

◆ UpdateVanitySet()

virtual void Terraria.ModLoader.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.

◆ UseAnimation()

virtual void Terraria.ModLoader.GlobalItem.UseAnimation ( Item  item,
Player  player 
)
virtual

Allows you to make things happen when an item's use animation starts.

◆ UseAnimationMultiplier()

virtual float Terraria.ModLoader.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.

◆ UseItem()

virtual ? bool Terraria.ModLoader.GlobalItem.UseItem ( Item  item,
Player  player 
)
virtual

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.

◆ UseItemFrame()

virtual void Terraria.ModLoader.GlobalItem.UseItemFrame ( Item  item,
Player  player 
)
virtual

Allows you to modify the player's animation when an item is being used.

◆ UseItemHitbox()

virtual void Terraria.ModLoader.GlobalItem.UseItemHitbox ( Item  item,
Player  player,
ref Rectangle  hitbox,
ref bool  noHitbox 
)
virtual

Changes the hitbox of a melee weapon when it is used.

◆ UseSpeedMultiplier()

virtual float Terraria.ModLoader.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 Terraria.ModLoader.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 Terraria.ModLoader.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.

◆ VerticalWingSpeeds()

virtual void Terraria.ModLoader.GlobalItem.VerticalWingSpeeds ( Item  item,
Player  player,
ref float  ascentWhenFalling,
ref float  ascentWhenRising,
ref float  maxCanAscendMultiplier,
ref float  maxAscentMultiplier,
ref float  constantAscend 
)
virtual

Allows you to modify the speeds at which you rise and fall when wings are equipped.

◆ WingUpdate()

virtual bool Terraria.ModLoader.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.