GlobalItem
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.
Methods
- Autoload(System.String@)()
- 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.
- Clone(Terraria.Item,Terraria.Item)()
- Create a copy of this instanced GlobalItem. Called when an item is cloned. Defaults to NewInstance(item)
- NewInstance(Terraria.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
- SetDefaults(Terraria.Item)()
- Allows you to set the properties of any and every item that gets created.
- ChoosePrefix(Terraria.Item,Terraria.Utilities.UnifiedRandom)()
- Allows you to manually choose what prefix an item will get.
- CanUseItem(Terraria.Item,Terraria.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.
- UseStyle(Terraria.Item,Terraria.Player)()
- Allows you to modify the location and rotation of any item in its use animation.
- HoldStyle(Terraria.Item,Terraria.Player)()
- Allows you to modify the location and rotation of the item the player is currently holding.
- HoldItem(Terraria.Item,Terraria.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).
- UseTimeMultiplier(Terraria.Item,Terraria.Player)()
- Allows you to change the effective useTime of an item.
- MeleeSpeedMultiplier(Terraria.Item,Terraria.Player)()
- Allows you to change the effective useAnimation of an item.
- GetHealLife(Terraria.Item,Terraria.Player,System.Boolean,System.Int32@)()
- 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.
- GetHealMana(Terraria.Item,Terraria.Player,System.Boolean,System.Int32@)()
- 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.
- GetWeaponDamage(Terraria.Item,Terraria.Player,System.Int32@)()
- 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.
- GetWeaponKnockback(Terraria.Item,Terraria.Player,System.Single@)()
- 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.
- GetWeaponCrit(Terraria.Item,Terraria.Player,System.Int32@)()
- 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.
- PickAmmo(Terraria.Item,Terraria.Player,System.Int32@,System.Single@,System.Int32@,System.Single@)()
- Allows you to modify the projectile created by a weapon based on the ammo it is using.
- ConsumeAmmo(Terraria.Item,Terraria.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.
- OnConsumeAmmo(Terraria.Item,Terraria.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.
- Shoot(Terraria.Item,Terraria.Player,Microsoft.Xna.Framework.Vector2@,System.Single@,System.Single@,System.Int32@,System.Int32@,System.Single@)()
- 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.
- UseItemHitbox(Terraria.Item,Terraria.Player,Microsoft.Xna.Framework.Rectangle@,System.Boolean@)()
- Changes the hitbox of a melee weapon when it is used.
- MeleeEffects(Terraria.Item,Terraria.Player,Microsoft.Xna.Framework.Rectangle)()
- Allows you to give melee weapons special effects, such as creating light or dust.
- CanHitNPC(Terraria.Item,Terraria.Player,Terraria.NPC)()
- 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.
- ModifyHitNPC(Terraria.Item,Terraria.Player,Terraria.NPC,System.Int32@,System.Single@,System.Boolean@)()
- Allows you to modify the damage, knockback, etc., that a melee weapon does to an NPC.
- OnHitNPC(Terraria.Item,Terraria.Player,Terraria.NPC,System.Int32,System.Single,System.Boolean)()
- Allows you to create special effects when a melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads).
- CanHitPvp(Terraria.Item,Terraria.Player,Terraria.Player)()
- 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.
- ModifyHitPvp(Terraria.Item,Terraria.Player,Terraria.Player,System.Int32@,System.Boolean@)()
- Allows you to modify the damage, etc., that a melee weapon does to a player.
- OnHitPvp(Terraria.Item,Terraria.Player,Terraria.Player,System.Int32,System.Boolean)()
- Allows you to create special effects when a melee weapon hits a player.
- UseItem(Terraria.Item,Terraria.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.
- ConsumeItem(Terraria.Item,Terraria.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.
- OnConsumeItem(Terraria.Item,Terraria.Player)()
- Allows you to make things happen when this item is consumed. Called before the item stack is reduced.
- UseItemFrame(Terraria.Item,Terraria.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.
- HoldItemFrame(Terraria.Item,Terraria.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.
- AltFunctionUse(Terraria.Item,Terraria.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.
- UpdateInventory(Terraria.Item,Terraria.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).
- UpdateEquip(Terraria.Item,Terraria.Player)()
- Allows you to give effects to armors and accessories, such as increased damage.
- UpdateAccessory(Terraria.Item,Terraria.Player,System.Boolean)()
- 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.
- IsArmorSet(Terraria.Item,Terraria.Item,Terraria.Item)()
- 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.
- UpdateArmorSet(Terraria.Player,System.String)()
- 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.
- IsVanitySet(System.Int32,System.Int32,System.Int32)()
- 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.
- PreUpdateVanitySet(Terraria.Player,System.String)()
- 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.
- UpdateVanitySet(Terraria.Player,System.String)()
- 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.
- ArmorSetShadows(Terraria.Player,System.String)()
- Allows you to determine special visual effects a vanity has on the player without having to code them yourself. This method is not instanced.
- SetMatch(System.Int32,System.Int32,System.Boolean,System.Int32@,System.Boolean@)()
- 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.
- CanRightClick(Terraria.Item)()
- Returns whether or not an item does something when right-clicked in the inventory. Returns false by default.
- RightClick(Terraria.Item,Terraria.Player)()
- Allows you to make things happen when an item is right-clicked in the inventory. Useful for goodie bags.
- PreOpenVanillaBag(System.String,Terraria.Player,System.Int32)()
- 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.
- OpenVanillaBag(System.String,Terraria.Player,System.Int32)()
- 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.
- ReforgePrice(Terraria.Item,System.Int32@,System.Boolean@)()
- 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.
- NewPreReforge(Terraria.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.
- PostReforge(Terraria.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.
- DrawHands(System.Int32,System.Boolean@,System.Boolean@)()
- 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.
- DrawHair(System.Int32,System.Boolean@,System.Boolean@)()
- 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.
- DrawHead(System.Int32)()
- Return false to hide the player's head when a head armor is worn. Returns true by default. This method is not instanced.
- DrawBody(System.Int32)()
- Return false to hide the player's body when a body armor is worn. Returns true by default. This method is not instanced.
- DrawLegs(System.Int32,System.Int32)()
- 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.
- DrawArmorColor(Terraria.ModLoader.EquipType,System.Int32,Terraria.Player,System.Single,Microsoft.Xna.Framework.Color@,System.Int32@,Microsoft.Xna.Framework.Color@)()
- 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.
- ArmorArmGlowMask(System.Int32,Terraria.Player,System.Single,System.Int32@,Microsoft.Xna.Framework.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. This method is not instanced.
- VerticalWingSpeeds(Terraria.Item,Terraria.Player,System.Single@,System.Single@,System.Single@,System.Single@,System.Single@)()
- Allows you to modify the speeds at which you rise and fall when wings are equipped.
- HorizontalWingSpeeds(Terraria.Item,Terraria.Player,System.Single@,System.Single@)()
- Allows you to modify the horizontal flight speed and acceleration of wings.
- WingUpdate(System.Int32,Terraria.Player,System.Boolean)()
- 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.
- Update(Terraria.Item,System.Single@,System.Single@)()
- 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.
- PostUpdate(Terraria.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.
- GrabRange(Terraria.Item,Terraria.Player,System.Int32@)()
- Allows you to modify how close an item must be to the player in order to move towards the player.
- GrabStyle(Terraria.Item,Terraria.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.
- CanPickup(Terraria.Item,Terraria.Player)()
- Allows you to determine whether or not the item can be picked up
- OnPickup(Terraria.Item,Terraria.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.
- ItemSpace(Terraria.Item,Terraria.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.
- GetAlpha(Terraria.Item,Microsoft.Xna.Framework.Color)()
- 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.
- PreDrawInWorld(Terraria.Item,Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Single@,System.Single@,System.Int32)()
- 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.
- PostDrawInWorld(Terraria.Item,Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Single,System.Single,System.Int32)()
- Allows you to draw things in front of an item. This method is called even if PreDrawInWorld returns false.
- PreDrawInInventory(Terraria.Item,Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,Microsoft.Xna.Framework.Rectangle,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Vector2,System.Single)()
- 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.
- PostDrawInInventory(Terraria.Item,Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,Microsoft.Xna.Framework.Rectangle,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Vector2,System.Single)()
- Allows you to draw things in front of an item in the inventory. This method is called even if PreDrawInInventory returns false.
- HoldoutOffset(System.Int32)()
- 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.
- HoldoutOrigin(System.Int32)()
- 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.
- CanEquipAccessory(Terraria.Item,Terraria.Player,System.Int32)()
- Allows you to disallow the player from equipping an accessory. Return false to disallow equipping the accessory. Returns true by default.
- ExtractinatorUse(System.Int32,System.Int32@,System.Int32@)()
- 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.
- CaughtFishStack(System.Int32,System.Int32@)()
- Allows you to modify how many of an item a player obtains when the player fishes that item.
- IsAnglerQuestAvailable(System.Int32)()
- 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.
- AnglerChat(System.Int32,System.String@,System.String@)()
- 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.
- OnCraft(Terraria.Item,Terraria.Recipe)()
- Allows you to make anything happen when the player crafts the given item using the given recipe.
- PreDrawTooltip(Terraria.Item,System.Collections.ObjectModel.ReadOnlyCollection{Terraria.ModLoader.TooltipLine},System.Int32@,System.Int32@)()
- Allows you to do things before this item's tooltip is drawn.
- PostDrawTooltip(Terraria.Item,System.Collections.ObjectModel.ReadOnlyCollection{Terraria.ModLoader.DrawableTooltipLine})()
- 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.
- PreDrawTooltipLine(Terraria.Item,Terraria.ModLoader.DrawableTooltipLine,System.Int32@)()
- Allows you to do things before a tooltip line of this item is drawn. The line contains draw info.
- PostDrawTooltipLine(Terraria.Item,Terraria.ModLoader.DrawableTooltipLine)()
- Allows you to do things after a tooltip line of this item is drawn. The line contains draw info.
- ModifyTooltips(Terraria.Item,System.Collections.Generic.List{Terraria.ModLoader.TooltipLine})()
- Allows you to modify all the tooltips that display for the given item. See here for information about TooltipLine.
- NeedsSaving(Terraria.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).
- Save(Terraria.Item)()
- Allows you to save custom data for the given item. Only called when NeedsCustomSaving returns true. Returns false by default.
- Load(Terraria.Item,Terraria.ModLoader.IO.TagCompound)()
- Allows you to load custom data that you have saved for the given item.
- LoadLegacy(Terraria.Item,System.IO.BinaryReader)()
- Allows you to load pre-v0.9 custom data that you have saved for the given item.
- NetSend(Terraria.Item,System.IO.BinaryWriter)()
- Allows you to send custom data for the given item between client and server.
- NetReceive(Terraria.Item,System.IO.BinaryReader)()