Terraria ModLoader  0.10.1.5
A framework for 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...

+ Collaboration diagram for Terraria.ModLoader.GlobalItem:

Public Member Functions

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 Autoload (ref string name)
 Allows you to automatically load a GlobalItem instead of using Mod.AddGlobalItem. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name. 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 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 ()
 Returns a clone of this GlobalItem. By default this will return a memberwise clone; you will want to override this if your GlobalItem contains object references. Only called if CloneNewInstances && InstancePerEntity More...
 
virtual GlobalItem Clone (Item item, Item itemClone)
 Create a copy of this instanced GlobalItem. Called when an item is cloned. Defaults to NewInstance(item) More...
 
virtual bool ConsumeAmmo (Item item, Player player)
 Whether or not ammo will be consumed upon usage. Called both by the gun and by the ammo; if at least one 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 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. 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. 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. More...
 
virtual bool DrawHead (int head)
 Return false to hide the player's head when a head armor is worn. Returns true by default. 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. 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 GetWeaponCrit (Item item, Player player, ref int crit)
 Allows you to temporarily modify this weapon's crit chance based on player buffs, etc. Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. If you use a custom damage class, the crit value will equal item.crit Vanilla checks classes in this order: melee, ranged, magic, thrown, and summon cannot crit. So if you set both melee class and another class to true, only the melee crit will actually be used. More...
 
virtual void GetWeaponDamage (Item item, Player player, ref int damage)
 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). Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. Vanilla checks classes in this order: melee, ranged, magic, thrown, summon So if you set both melee class and another class to true, only the melee damage will actually be used. More...
 
virtual void GetWeaponKnockback (Item item, Player player, ref float knockback)
 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. Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. Vanilla checks classes in this order: melee, ranged, magic, thrown, summon So if you set both melee class and another class to true, only the melee knockback will actually be used. 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 bool HoldItemFrame (Item item, Player player)
 Allows you to modify the player's animation when the player is holding an item. Return true if you modify the player's animation. Returns false by default. 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)
 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 LoadLegacy (Item item, BinaryReader reader)
 Allows you to load pre-v0.9 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 float MeleeSpeedMultiplier (Item item, Player player)
 Allows you to change the effective useAnimation of an item. 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 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 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 GlobalItem NewInstance (Item item)
 Create a new instance of this GlobalItem for an Item instance. Called at the end of Item.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields More...
 
virtual bool NewPreReforge (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 OnConsumeAmmo (Item item, Player player)
 Allows you to make things happen when ammo is consumed. Called both by the gun and 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 OnCraft (Item item, Recipe recipe)
 Allows you to make anything happen when the player crafts the given item using the given recipe. More...
 
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 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", "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 item, 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 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", "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 PreReforge (Item item)
 
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...
 
virtual bool Shoot (Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
 This is called before the weapon creates a projectile. You can use it to create special effects, such as changing the speed, changing the initial position, and/or firing multiple projectiles. Return false to stop the game from shooting the default projectile (do this if you manually spawn your own projectile). Returns true by default. More...
 
virtual void 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 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 bool UseItem (Item item, Player player)
 Allows you to make things happen when an item is used. Return true if using the item actually does stuff. Returns false by default. More...
 
virtual bool UseItemFrame (Item item, Player player)
 Allows you to modify the player's animation when an item is being used. Return true if you modify the player's animation. Returns false by default. 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 void UseStyle (Item item, Player player)
 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. 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 Attributes

virtual bool CloneNewInstances => false
 Whether instances of this GlobalItem are created through Clone or constructor (by default implementations of NewInstance and Clone(Item, Item)). Defaults to false (using default constructor). More...
 
virtual bool InstancePerEntity => false
 Whether to create a new GlobalItem instance for every Item that exists. Useful for storing information on an item. Defaults to false. Return true if you need to store information (have non-static fields). More...
 

Properties

Mod mod [get, set]
 The mod to which this GlobalItem belongs. More...
 
string Name [get, set]
 The name of this GlobalItem 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.

Definition at line 15 of file GlobalItem.cs.

Member Function Documentation

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.

Definition at line 338 of file GlobalItem.cs.

338  {
339  return false;
340  }
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.

Definition at line 745 of file GlobalItem.cs.

745  {
746  }
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.

Definition at line 571 of file GlobalItem.cs.

571  {
572  }
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;

Definition at line 426 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.ArmorSetShadows().

426  {
427  }

+ Here is the caller graph for this function:

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

Allows you to automatically load a GlobalItem instead of using Mod.AddGlobalItem. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name.

Definition at line 39 of file GlobalItem.cs.

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

39  {
40  return mod.Properties.Autoload;
41  }
Mod mod
The mod to which this GlobalItem belongs.
Definition: GlobalItem.cs:20
ModProperties Properties
Definition: Mod.cs:49
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

+ Here is the caller graph for this function:

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

Definition at line 709 of file GlobalItem.cs.

709  {
710  return true;
711  }
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.

Definition at line 264 of file GlobalItem.cs.

264  {
265  return null;
266  }
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.

Definition at line 283 of file GlobalItem.cs.

283  {
284  return true;
285  }
virtual bool Terraria.ModLoader.GlobalItem.CanPickup ( Item  item,
Player  player 
)
virtual

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

Definition at line 627 of file GlobalItem.cs.

627  {
628  return true;
629  }
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.

Definition at line 447 of file GlobalItem.cs.

447  {
448  return false;
449  }
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.

Definition at line 108 of file GlobalItem.cs.

108  {
109  return true;
110  }
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.

Definition at line 726 of file GlobalItem.cs.

726  {
727  }
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

Definition at line 101 of file GlobalItem.cs.

101  {
102  return -1;
103  }
virtual GlobalItem Terraria.ModLoader.GlobalItem.Clone ( )
virtual

Returns a clone of this GlobalItem. By default this will return a memberwise clone; you will want to override this if your GlobalItem contains object references. Only called if CloneNewInstances && InstancePerEntity

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

Create a copy of this instanced GlobalItem. Called when an item is cloned. Defaults to NewInstance(item)

Parameters
itemThe item being cloned
itemCloneThe new item
virtual bool Terraria.ModLoader.GlobalItem.ConsumeAmmo ( Item  item,
Player  player 
)
virtual

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

Definition at line 222 of file GlobalItem.cs.

222  {
223  return true;
224  }
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.

Definition at line 310 of file GlobalItem.cs.

310  {
311  return true;
312  }
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.

Definition at line 562 of file GlobalItem.cs.

563  {
564  }
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.

This method is not instanced.

Definition at line 544 of file GlobalItem.cs.

544  {
545  return true;
546  }
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.

This method is not instanced.

Definition at line 527 of file GlobalItem.cs.

527  {
528  }
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.

This method is not instanced.

Definition at line 519 of file GlobalItem.cs.

519  {
520  }
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.

This method is not instanced.

Definition at line 535 of file GlobalItem.cs.

535  {
536  return true;
537  }
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.

This method is not instanced.

Definition at line 553 of file GlobalItem.cs.

553  {
554  return true;
555  }
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.

Definition at line 720 of file GlobalItem.cs.

720  {
721  }
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.

Definition at line 648 of file GlobalItem.cs.

648  {
649  return null;
650  }
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.

Definition at line 153 of file GlobalItem.cs.

153  {
154  }
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.

Definition at line 163 of file GlobalItem.cs.

163  {
164  }
virtual void Terraria.ModLoader.GlobalItem.GetWeaponCrit ( Item  item,
Player  player,
ref int  crit 
)
virtual

Allows you to temporarily modify this weapon's crit chance based on player buffs, etc. Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. If you use a custom damage class, the crit value will equal item.crit Vanilla checks classes in this order: melee, ranged, magic, thrown, and summon cannot crit. So if you set both melee class and another class to true, only the melee crit will actually be used.

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

Definition at line 203 of file GlobalItem.cs.

203  {
204  }
virtual void Terraria.ModLoader.GlobalItem.GetWeaponDamage ( Item  item,
Player  player,
ref int  damage 
)
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). Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. Vanilla checks classes in this order: melee, ranged, magic, thrown, summon So if you set both melee class and another class to true, only the melee damage will actually be used.

Parameters
itemThe item being used
playerThe player using the item
damageThe damage

Definition at line 176 of file GlobalItem.cs.

176  {
177  }
virtual void Terraria.ModLoader.GlobalItem.GetWeaponKnockback ( Item  item,
Player  player,
ref float  knockback 
)
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. Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. Vanilla checks classes in this order: melee, ranged, magic, thrown, summon So if you set both melee class and another class to true, only the melee knockback will actually be used.

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

Definition at line 189 of file GlobalItem.cs.

189  {
190  }
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.

Definition at line 614 of file GlobalItem.cs.

614  {
615  }
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.

Definition at line 620 of file GlobalItem.cs.

620  {
621  return false;
622  }
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).

Definition at line 127 of file GlobalItem.cs.

127  {
128  }
virtual bool Terraria.ModLoader.GlobalItem.HoldItemFrame ( Item  item,
Player  player 
)
virtual

Allows you to modify the player's animation when the player is holding an item. Return true if you modify the player's animation. Returns false by default.

Definition at line 331 of file GlobalItem.cs.

331  {
332  return false;
333  }
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);

Definition at line 688 of file GlobalItem.cs.

688  {
689  return null;
690  }
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.

Definition at line 699 of file GlobalItem.cs.

699  {
700  return null;
701  }
virtual void Terraria.ModLoader.GlobalItem.HoldStyle ( Item  item,
Player  player 
)
virtual

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

Definition at line 121 of file GlobalItem.cs.

121  {
122  }
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.

Definition at line 584 of file GlobalItem.cs.

584  {
585  }
GlobalItem Terraria.ModLoader.GlobalItem.Instance ( Item  item)

Referenced by Terraria.ModLoader.IO.ItemIO.Load().

+ Here is the caller graph for this function:

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.

Definition at line 735 of file GlobalItem.cs.

735  {
736  return true;
737  }
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.

Definition at line 367 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.UpdateArmorSet().

367  {
368  return "";
369  }

+ Here is the caller graph for this function:

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.

Definition at line 387 of file GlobalItem.cs.

References Terraria.ModLoader.Item.

Referenced by Terraria.ModLoader.ItemLoader.ArmorSetShadows(), Terraria.ModLoader.ItemLoader.PreUpdateVanitySet(), and Terraria.ModLoader.ItemLoader.UpdateVanitySet().

387  {
388  Item headItem = new Item();
389  if (head >= 0) {
390  headItem.SetDefaults(Item.headType[head], true);
391  }
392  Item bodyItem = new Item();
393  if (body >= 0) {
394  bodyItem.SetDefaults(Item.bodyType[body], true);
395  }
396  Item legItem = new Item();
397  if (legs >= 0) {
398  legItem.SetDefaults(Item.legType[legs], true);
399  }
400  return IsArmorSet(headItem, bodyItem, legItem);
401  }
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...
Definition: GlobalItem.cs:367

+ Here is the caller graph for this function:

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.

Definition at line 641 of file GlobalItem.cs.

641  {
642  return false;
643  }
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.

Definition at line 816 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.IO.ItemIO.Load().

816  {
817  }

+ Here is the caller graph for this function:

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

Allows you to load pre-v0.9 custom data that you have saved for the given item.

Definition at line 822 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.IO.ItemIO.LoadLegacy().

822  {
823  }

+ Here is the caller graph for this function:

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.

Definition at line 258 of file GlobalItem.cs.

258  {
259  }
virtual float Terraria.ModLoader.GlobalItem.MeleeSpeedMultiplier ( Item  item,
Player  player 
)
virtual

Allows you to change the effective useAnimation of an item.

Returns
The multiplier on the animation speed. 1f by default.

Definition at line 142 of file GlobalItem.cs.

142  {
143  return 1f;
144  }
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.

Definition at line 271 of file GlobalItem.cs.

271  {
272  }
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.

Definition at line 290 of file GlobalItem.cs.

290  {
291  }
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.

Definition at line 796 of file GlobalItem.cs.

796  {
797  }
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).

Definition at line 802 of file GlobalItem.cs.

802  {
803  return false;
804  }
virtual void Terraria.ModLoader.GlobalItem.NetReceive ( Item  item,
BinaryReader  reader 
)
virtual

Definition at line 834 of file GlobalItem.cs.

834  {
835  }
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.

Definition at line 828 of file GlobalItem.cs.

828  {
829  }
virtual GlobalItem Terraria.ModLoader.GlobalItem.NewInstance ( Item  item)
virtual

Create a new instance of this GlobalItem for an Item instance. Called at the end of Item.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields

Definition at line 79 of file GlobalItem.cs.

79  {
81  return Clone();
82 
83  var copy = (GlobalItem)Activator.CreateInstance(GetType());
84  copy.mod = mod;
85  copy.Name = Name;
86  copy.index = index; //not necessary, but consistency
87  copy.instanceIndex = instanceIndex;//shouldn't be used, but someone might
88  return copy;
89  }
virtual GlobalItem Clone()
Returns a clone of this GlobalItem. By default this will return a memberwise clone; you will want to ...
Mod mod
The mod to which this GlobalItem belongs.
Definition: GlobalItem.cs:20
virtual bool CloneNewInstances
Whether instances of this GlobalItem are created through Clone or constructor (by default implementat...
Definition: GlobalItem.cs:56
virtual string Name
Stores the name of the mod. This name serves as the mod&#39;s identification, and also helps with saving ...
Definition: Mod.cs:39
string Name
The name of this GlobalItem instance.
Definition: GlobalItem.cs:28
virtual bool Terraria.ModLoader.GlobalItem.NewPreReforge ( 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.

Definition at line 496 of file GlobalItem.cs.

496  {
497  return true;
498  }
virtual void Terraria.ModLoader.GlobalItem.OnConsumeAmmo ( Item  item,
Player  player 
)
virtual

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

Definition at line 230 of file GlobalItem.cs.

230  {
231  }
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.

Definition at line 318 of file GlobalItem.cs.

318  {
319  }
virtual void Terraria.ModLoader.GlobalItem.OnCraft ( Item  item,
Recipe  recipe 
)
virtual

Allows you to make anything happen when the player crafts the given item using the given recipe.

Definition at line 751 of file GlobalItem.cs.

751  {
752  }
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).

Definition at line 277 of file GlobalItem.cs.

277  {
278  }
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.

Definition at line 296 of file GlobalItem.cs.

296  {
297  }
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.

Definition at line 634 of file GlobalItem.cs.

634  {
635  return true;
636  }
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", "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.

Definition at line 479 of file GlobalItem.cs.

479  {
480  }
virtual void Terraria.ModLoader.GlobalItem.PickAmmo ( Item  item,
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
itemThe ammo item
player
type
speed
damage
knockback

Definition at line 215 of file GlobalItem.cs.

215  {
216  }
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.

Definition at line 676 of file GlobalItem.cs.

677  {
678  }
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.

Definition at line 662 of file GlobalItem.cs.

662  {
663  }
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

Definition at line 771 of file GlobalItem.cs.

771  {
772  }
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

Definition at line 790 of file GlobalItem.cs.

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

Definition at line 510 of file GlobalItem.cs.

510  {
511  }
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.

Definition at line 608 of file GlobalItem.cs.

608  {
609  }
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.

Definition at line 668 of file GlobalItem.cs.

669  {
670  return true;
671  }
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.

Definition at line 655 of file GlobalItem.cs.

655  {
656  return true;
657  }
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

Definition at line 762 of file GlobalItem.cs.

762  {
763  return true;
764  }
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

Definition at line 781 of file GlobalItem.cs.

781  {
782  return true;
783  }
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", "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.

Definition at line 466 of file GlobalItem.cs.

466  {
467  return true;
468  }
virtual void Terraria.ModLoader.GlobalItem.PreReforge ( Item  item)
virtual

Definition at line 502 of file GlobalItem.cs.

502  {
503  NewPreReforge(item);
504  }
virtual bool NewPreReforge(Item item)
This hook gets called when the player clicks on the reforge button and can afford the reforge...
Definition: GlobalItem.cs:496
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.

Definition at line 409 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.PreUpdateVanitySet().

409  {
410  }

+ Here is the caller graph for this function:

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.

Definition at line 487 of file GlobalItem.cs.

487  {
488  return true;
489  }
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.

Definition at line 454 of file GlobalItem.cs.

454  {
455  }
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.

Definition at line 809 of file GlobalItem.cs.

809  {
810  return null;
811  }
virtual void Terraria.ModLoader.GlobalItem.SetDefaults ( Item  item)
virtual

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

Definition at line 94 of file GlobalItem.cs.

94  {
95  }
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

Definition at line 441 of file GlobalItem.cs.

441  {
442  }
virtual bool Terraria.ModLoader.GlobalItem.Shoot ( Item  item,
Player  player,
ref Vector2  position,
ref float  speedX,
ref float  speedY,
ref int  type,
ref int  damage,
ref float  knockBack 
)
virtual

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

Parameters
itemThe weapon item.
playerThe player.
positionThe shoot spawn position.
speedXThe speed x calculated from shootSpeed and mouse position.
speedYThe speed y calculated from shootSpeed and mouse position.
typeThe projectile type chosen by ammo and weapon.
damageThe projectile damage.
knockBackThe projectile knock back.
Returns

Definition at line 245 of file GlobalItem.cs.

245  {
246  return true;
247  }
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.

Definition at line 602 of file GlobalItem.cs.

602  {
603  }
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.

Definition at line 357 of file GlobalItem.cs.

357  {
358  }
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.

Definition at line 377 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.UpdateArmorSet().

377  {
378  }

+ Here is the caller graph for this function:

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

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

Definition at line 351 of file GlobalItem.cs.

351  {
352  }
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).

Definition at line 345 of file GlobalItem.cs.

345  {
346  }
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.

Definition at line 417 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.UpdateVanitySet().

417  {
418  }

+ Here is the caller graph for this function:

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

Allows you to make things happen when an item is used. Return true if using the item actually does stuff. Returns false by default.

Definition at line 302 of file GlobalItem.cs.

302  {
303  return false;
304  }
virtual bool Terraria.ModLoader.GlobalItem.UseItemFrame ( Item  item,
Player  player 
)
virtual

Allows you to modify the player's animation when an item is being used. Return true if you modify the player's animation. Returns false by default.

Definition at line 324 of file GlobalItem.cs.

324  {
325  return false;
326  }
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.

Definition at line 252 of file GlobalItem.cs.

252  {
253  }
virtual void Terraria.ModLoader.GlobalItem.UseStyle ( Item  item,
Player  player 
)
virtual

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

Definition at line 115 of file GlobalItem.cs.

115  {
116  }
virtual float Terraria.ModLoader.GlobalItem.UseTimeMultiplier ( Item  item,
Player  player 
)
virtual

Allows you to change the effective useTime of an item.

Returns
The multiplier on the usage speed. 1f by default.

Definition at line 134 of file GlobalItem.cs.

134  {
135  return 1f;
136  }
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.

Definition at line 577 of file GlobalItem.cs.

578  {
579  }
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.

Definition at line 595 of file GlobalItem.cs.

595  {
596  return false;
597  }

Member Data Documentation

virtual bool Terraria.ModLoader.GlobalItem.CloneNewInstances => false

Whether instances of this GlobalItem are created through Clone or constructor (by default implementations of NewInstance and Clone(Item, Item)). Defaults to false (using default constructor).

Definition at line 56 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.HasMethod().

virtual bool Terraria.ModLoader.GlobalItem.InstancePerEntity => false

Whether to create a new GlobalItem instance for every Item that exists. Useful for storing information on an item. Defaults to false. Return true if you need to store information (have non-static fields).

Definition at line 48 of file GlobalItem.cs.

Referenced by Terraria.ModLoader.ItemLoader.HasMethod().

Property Documentation

Mod Terraria.ModLoader.GlobalItem.mod
getset
string Terraria.ModLoader.GlobalItem.Name
getset

The name of this GlobalItem instance.

Definition at line 28 of file GlobalItem.cs.

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