1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
5using System.Collections.ObjectModel;
8using Terraria.Utilities;
34 internal int instanceIndex;
39 public virtual bool Autoload(ref
string name) {
83 var copy = (
GlobalItem)Activator.CreateInstance(GetType());
87 copy.instanceIndex = instanceIndex;
116 public virtual bool?
PrefixChance(Item item,
int pre, UnifiedRandom rand) =>
null;
133 public virtual void UseStyle(Item item, Player player) {
139 public virtual void HoldStyle(Item item, Player player) {
145 public virtual void HoldItem(Item item, Player player) {
171 public virtual void GetHealLife(Item item, Player player,
bool quickHeal, ref
int healValue) {
181 public virtual void GetHealMana(Item item, Player player,
bool quickHeal, ref
int healValue) {
191 public virtual void ModifyManaCost(Item item, Player player, ref
float reduce, ref
float mult) {
202 public virtual void OnMissingMana(Item item, Player player,
int neededMana) {
211 public virtual void OnConsumeMana(Item item, Player player,
int manaConsumed) {
224 [Obsolete(
"Use ModifyWeaponDamage",
true)]
235 [Obsolete(
"Use ModifyWeaponDamage overload with the additional flat parameter")]
247 public virtual void ModifyWeaponDamage(Item item, Player player, ref
float add, ref
float mult, ref
float flat) {
287 public virtual void PickAmmo(Item weapon, Item ammo, Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback) {
290 [Obsolete(
"PickAmmo now has a weapon parameter that represents the item using the ammo.")]
291 public virtual void PickAmmo(Item item, Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback) {
321 public 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) {
328 public virtual void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref
bool noHitbox) {
334 public virtual void MeleeEffects(Item item, Player player, Rectangle hitbox) {
340 public virtual bool?
CanHitNPC(Item item, Player player, NPC target) {
347 public virtual void ModifyHitNPC(Item item, Player player, NPC target, ref
int damage, ref
float knockBack, ref
bool crit) {
353 public virtual void OnHitNPC(Item item, Player player, NPC target,
int damage,
float knockBack,
bool crit) {
359 public virtual bool CanHitPvp(Item item, Player player, Player target) {
366 public virtual void ModifyHitPvp(Item item, Player player, Player target, ref
int damage, ref
bool crit) {
372 public virtual void OnHitPvp(Item item, Player player, Player target,
int damage,
bool crit) {
378 public virtual bool UseItem(Item item, Player player) {
443 public virtual string IsArmorSet(Item head, Item body, Item legs) {
466 headItem.SetDefaults(
Item.headType[head],
true);
470 bodyItem.SetDefaults(
Item.bodyType[body],
true);
474 legItem.SetDefaults(
Item.legType[legs],
true);
476 return IsArmorSet(headItem, bodyItem, legItem);
517 public virtual void SetMatch(
int armorSlot,
int type,
bool male, ref
int equipSlot, ref
bool robes) {
563 public virtual bool ReforgePrice(Item item, ref
int reforgePrice, ref
bool canApplyDiscount) {
577 [method: Obsolete(
"PreReforge now returns a bool to control whether the reforge takes place. For now, use NewPreReforge")]
595 public virtual void DrawHands(
int body, ref
bool drawHands, ref
bool drawArms) {
603 public virtual void DrawHair(
int head, ref
bool drawHair, ref
bool drawAltHair) {
629 public virtual bool DrawLegs(
int legs,
int shoes) {
639 ref
int glowMask, ref Color glowMaskColor) {
647 public virtual void ArmorArmGlowMask(
int slot, Player drawPlayer,
float shadow, ref
int glowMask, ref Color color) {
653 public virtual void VerticalWingSpeeds(Item item, Player player, ref
float ascentWhenFalling, ref
float ascentWhenRising,
654 ref
float maxCanAscendMultiplier, ref
float maxAscentMultiplier, ref
float constantAscend) {
671 public virtual bool WingUpdate(
int wings, Player player,
bool inUse) {
678 public virtual void Update(Item item, ref
float gravity, ref
float maxFallSpeed) {
697 public virtual void GrabRange(Item item, Player player, ref
int grabRange) {
703 public virtual bool GrabStyle(Item item, Player player) {
710 public virtual bool CanPickup(Item item, Player player) {
717 public virtual bool OnPickup(Item item, Player player) {
724 public virtual bool ItemSpace(Item item, Player player) {
731 public virtual Color?
GetAlpha(Item item, Color lightColor) {
738 public virtual bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref
float rotation, ref
float scale,
int whoAmI) {
745 public virtual void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor,
float rotation,
float scale,
int whoAmI) {
751 public virtual bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame,
752 Color drawColor, Color itemColor, Vector2 origin,
float scale) {
759 public virtual void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame,
760 Color drawColor, Color itemColor, Vector2 origin,
float scale) {
803 public virtual void ExtractinatorUse(
int extractType, ref
int resultType, ref
int resultStack) {
828 public virtual void AnglerChat(
int type, ref
string chat, ref
string catchLocation) {
840 public virtual void OnCraft(Item item, Recipe recipe) {
851 public virtual bool PreDrawTooltip(Item item, ReadOnlyCollection<TooltipLine> lines, ref
int x, ref
int y) {
860 public virtual void PostDrawTooltip(Item item, ReadOnlyCollection<DrawableTooltipLine> lines) {
This class allows you to modify and use hooks for all items, including vanilla items....
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.
virtual void NetSend(Item item, BinaryWriter writer)
Allows you to send custom data for the given item between client and server.
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 a...
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 dra...
virtual void GrabRange(Item item, Player player, ref int grabRange)
Allows you to modify how close an item must be to the player in order to move towards the player.
virtual void OpenVanillaBag(string context, Player player, int arg)
Allows you to make vanilla bags drop your own items in addition to the default items....
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 f...
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.
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....
virtual void HoldStyle(Item item, Player player)
Allows you to modify the location and rotation of the item the player is currently holding.
virtual void UpdateEquip(Item item, Player player)
Allows you to give effects to armors and accessories, such as increased damage.
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 ...
virtual void OnCraft(Item item, Recipe recipe)
Allows you to make anything happen when the player crafts the given item using the given recipe.
virtual void Load(Item item, TagCompound tag)
Allows you to load custom data that you have saved for the given item.
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....
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 curr...
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...
virtual bool CanBurnInLava(Item item)
Returns whether or not this item burns when it is thrown into lava despite item.rare not being 0....
virtual float UseTimeMultiplier(Item item, Player player)
Allows you to change the effective useTime of an item.
virtual bool DrawHead(int head)
Return false to hide the player's head when a head armor is worn. Returns true by default....
virtual void GetWeaponKnockback(Item item, Player player, ref float knockback)
Allows you to temporarily modify this weapon's knockback based on player buffs, etc....
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....
virtual void UpdateInventory(Item item, Player player)
Allows you to make things happen when an item is in the player's inventory (for example,...
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 ...
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...
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...
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.
virtual void NetReceive(Item item, BinaryReader reader)
virtual bool InstancePerEntity
Whether to create a new GlobalItem instance for every Item that exists. Useful for storing informatio...
virtual void PreReforge(Item item)
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 ...
virtual void OnConsumeItem(Item item, Player player)
Allows you to make things happen when this item is consumed. Called before the item stack is reduced.
virtual 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 alter...
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 ...
string Name
The name of this GlobalItem instance.
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 f...
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...
virtual bool Autoload(ref string name)
Allows you to automatically load a GlobalItem instead of using Mod.AddGlobalItem. Return true to allo...
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...
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.
virtual bool IsAnglerQuestAvailable(int type)
Whether or not specific conditions have been satisfied for the Angler to be able to request the given...
virtual void CaughtFishStack(int type, ref int stack)
Allows you to modify how many of an item a player obtains when the player fishes that item.
virtual 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 PreDraw...
virtual TagCompound Save(Item item)
Allows you to save custom data for the given item. Only called when NeedsCustomSaving returns true....
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 thi...
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...
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 ba...
virtual float MeleeSpeedMultiplier(Item item, Player player)
Allows you to change the effective useAnimation of an item.
virtual void LoadLegacy(Item item, BinaryReader reader)
Allows you to load pre-v0.9 custom data that you have saved for the given item.
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...
virtual void PostReforge(Item item)
This hook gets called immediately after an item gets reforged by the Goblin Tinkerer....
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,...
virtual void PickAmmo(Item item, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
virtual bool CloneNewInstances
Whether instances of this GlobalItem are created through Clone or constructor (by default implementat...
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 a...
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...
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....
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.
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...
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 buff...
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.
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...
virtual void PostUpdate(Item item)
Allows you to make things happen when an item is lying in the world. This will always be called,...
virtual bool NewPreReforge(Item item)
This hook gets called when the player clicks on the reforge button and can afford the reforge....
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...
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 i...
virtual bool CanRightClick(Item item)
Returns whether or not an item does something when right-clicked in the inventory....
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....
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...
virtual bool NeedsSaving(Item item)
Whether or not the given item needs to save custom data. Returning false will save on the memory used...
virtual GlobalItem Clone()
Returns a clone of this GlobalItem. By default this will return a memberwise clone; you will want to ...
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.
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....
virtual bool CanPickup(Item item, Player player)
Allows you to determine whether or not the item can be picked up
virtual void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat)
Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for ...
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,...
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 Swo...
virtual int ChoosePrefix(Item item, UnifiedRandom rand)
Allows you to manually choose what prefix an item will get.
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 i...
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....
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 ...
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 mo...
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 ...
virtual void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox)
Changes the hitbox of a melee weapon when it is used.
virtual void AddRecipes()
This is essentially the same as Mod.AddRecipes or ModItem.AddRecipes. Use whichever method makes orga...
virtual void SetDefaults(Item item)
Allows you to set the properties of any and every item that gets created.
virtual bool ConsumeItem(Item item, Player player)
If the item is consumable and this returns true, then the item will be consumed upon usage....
virtual void UseStyle(Item item, Player player)
Allows you to modify the location and rotation of any item in its use animation.
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 st...
virtual void HorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration)
Allows you to modify the horizontal flight speed and acceleration of wings.
virtual GlobalItem NewInstance(Item item)
Create a new instance of this GlobalItem for an Item instance. Called at the end of Item....
virtual bool AllowPrefix(Item item, int pre)
Force a re-roll of a prefix by returning false.
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....
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 giv...
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.
virtual GlobalItem Clone(Item item, Item itemClone)
Create a copy of this instanced GlobalItem. Called when an item is cloned. Defaults to NewInstance(it...
virtual void VerticalWingSpeeds(Item item, Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
Allows you to modify the speeds at which you rise and fall when wings are equipped.
virtual bool DrawLegs(int legs, int shoes)
Return false to hide the player's legs when a leg armor or shoe accessory is worn....
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,...
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.
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....
virtual void MeleeEffects(Item item, Player player, Rectangle hitbox)
Allows you to give melee weapons special effects, such as creating light or dust.
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....
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 ...
virtual bool DrawBody(int body)
Return false to hide the player's body when a body armor is worn. Returns true by default....
virtual void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult)
Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for ...
GlobalItem Instance(Item item)
Mod mod
The mod to which this GlobalItem belongs.
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....
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...