tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ModItem Class Reference

This class serves as a place for you to place all your properties and hooks for each item. Create instances of ModItem (preferably overriding this class) to pass as parameters to Mod.AddItem. More...

+ Collaboration diagram for Terraria.ModLoader.ModItem:

Public Member Functions

 ModItem ()
 
virtual void AddRecipes ()
 This is essentially the same as Mod.AddRecipes. Do note that this will be called for every instance of the overriding ModItem class that is added to the game. This allows you to avoid clutter in your overriding Mod class by adding recipes for which this item is the result. More...
 
virtual bool AllowPrefix (int pre)
 Force a re-roll of a prefix by returning false. More...
 
virtual bool AltFunctionUse (Player player)
 Allows you to make this item usable by right-clicking. Returns false by default. When this item is used by right-clicking, player.altFunctionUse will be set to 2. More...
 
virtual void AnglerQuestChat (ref string description, ref string catchLocation)
 Allows you to set what the Angler says when he requests for this item. The description parameter is his dialogue, and catchLocation should be set to "\n(Caught at [location])". More...
 
virtual void ArmorArmGlowMask (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. Also note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual void ArmorSetShadows (Player player)
 Allows you to determine special visual effects this vanity set has on the player without having to code them yourself. Note that this hook is only ever called through this item's associated equipment texture. Use the player.armorEffectDraw bools to activate the desired effects. More...
 
virtual void AutoDefaults ()
 Automatically sets certain defaults. Override this if you do not want the properties to be set for you. More...
 
virtual void AutoLightSelect (ref bool dryTorch, ref bool wetTorch, ref bool glowstick)
 Allows you to tell the game whether this item is a torch that cannot be placed in liquid, a torch that can be placed in liquid, or a glowstick. This information is used for when the player is holding down the auto-select hotkey. More...
 
virtual bool Autoload (ref string name)
 Allows you to automatically load an item instead of using Mod.AddItem. Return true to allow autoloading; by default returns the mod's autoload property. Use this method to force or stop an autoload or change the internal name. More...
 
virtual void AutoStaticDefaults ()
 Automatically sets certain static defaults. Override this if you do not want the properties to be set for you. More...
 
virtual bool CanBurnInLava ()
 Returns whether or not this item burns when it is thrown into lava despite item.rare not being 0. Returns false by default. More...
 
virtual bool CanEquipAccessory (Player player, int slot)
 Allows you to disallow the player from equipping this accessory. Return false to disallow equipping this accessory. Returns true by default. More...
 
virtual ? bool CanHitNPC (Player player, NPC target)
 Allows you to determine whether this melee weapon can hit the given NPC when swung. Return true to allow hitting the target, return false to block this 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 (Player player, Player target)
 Allows you to determine whether this melee weapon can hit the given opponent player when swung. Return false to block this weapon from hitting the target. Returns true by default. More...
 
virtual bool CanPickup (Player player)
 Allows you to determine whether or not the item can be picked up More...
 
virtual bool CanRightClick ()
 Returns whether or not this item does something when it is right-clicked in the inventory. Returns false by default. More...
 
virtual bool CanUseItem (Player player)
 Returns whether or not this item can be used. By default returns true. More...
 
virtual void CaughtFishStack (ref int stack)
 Allows you to determine how many of this item a player obtains when the player fishes this item. More...
 
virtual int ChoosePrefix (UnifiedRandom rand)
 Allows you to manually choose what prefix an item will get. More...
 
virtual ModItem Clone ()
 Returns a clone of this ModItem. Allows you to decide which fields of your ModItem class are copied over when an item stack is split or something similar happens. By default this will return a memberwise clone; you will want to override this if your ModItem contains object references. Only called if CloneNewInstances is set to true. Since several ModItem class fields are also set by the default implementation of this method, you'll most likely want to call base.Clone() as the first statement of your override. More...
 
virtual ModItem Clone (Item item)
 Create a copy of this instanced ModItem. Called when an item is cloned. Defaults to NewInstance(item) More...
 
virtual bool ConsumeAmmo (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 (Player player)
 If this item is consumable and this returns true, then this item will be consumed upon usage. Returns true by default. If false is returned, the OnConsumeItem hook is never called. More...
 
virtual void DrawArmorColor (Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor)
 Allows you to modify the colors in which this armor and surrounding accessories are drawn, in addition to which glow mask and in what color is drawn. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual bool DrawBody ()
 Return false to hide the player's body when this body armor is worn. Returns true by default. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual void DrawHair (ref bool drawHair, ref bool drawAltHair)
 Allows you to determine whether the player's hair or alt (hat) hair draws when this head armor is worn. By default both flags will be false. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual void DrawHands (ref bool drawHands, ref bool drawArms)
 Allows you to determine whether the skin/shirt on the player's arms and hands are drawn when this body armor is worn. By default both flags will be false. Note that if drawHands is false, the arms will not be drawn either. Also note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual bool DrawHead ()
 Return false to hide the player's head when this head armor is worn. Returns true by default. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual bool DrawLegs ()
 Return false to hide the player's legs when this leg armor or shoe accessory is worn. Returns true by default. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual void ExtractinatorUse (ref int resultType, ref int resultStack)
 Allows you to modify what item, and in what quantity, is obtained when this item is fed into the Extractinator. By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator. More...
 
virtual ? Color GetAlpha (Color lightColor)
 Allows you to determine the color and transparency in which this item is drawn. Return null to use the default color (normally light color). Returns null by default. More...
 
virtual void GetHealLife (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 (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 (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 (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 (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 (Player player, ref int grabRange)
 Allows you to modify how close this item must be to the player in order to move towards the player. More...
 
virtual bool GrabStyle (Player player)
 Allows you to modify the way this item moves towards the player. Return true if you override this hook; returning false will allow the vanilla grab style to take place. Returns false by default. More...
 
virtual void HoldItem (Player player)
 Allows you to make things happen when the player is holding this item (for example, torches make light and water candles increase spawn rate). More...
 
virtual bool HoldItemFrame (Player player)
 Allows you to modify the player's animation when the player is holding this item. Return true if you modify the player's animation. Returns false by default. More...
 
virtual ? Vector2 HoldoutOffset ()
 Allows you to determine the offset of this 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 vanilla holdout offset; returns null by default. More...
 
virtual ? Vector2 HoldoutOrigin ()
 Allows you to determine the point on this item's sprite that the player holds onto when using this 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 vanilla holdout origin (zero); returns null by default. More...
 
virtual void HoldStyle (Player player)
 Allows you to modify the location and rotation of this item when the player is holding it. More...
 
virtual void HorizontalWingSpeeds (Player player, ref float speed, ref float acceleration)
 Allows you to modify these wing's horizontal flight speed and acceleration. More...
 
virtual bool IsAnglerQuestAvailable ()
 Whether or not specific conditions have been satisfied for the Angler to be able to request this item. (For example, Hardmode.) Returns true by default. More...
 
virtual bool IsArmorSet (Item head, Item body, Item legs)
 Returns whether or not the head armor, body armor, and leg armor make up a set. If this returns true, then this item's UpdateArmorSet method will be called. Returns false by default. More...
 
virtual bool IsQuestFish ()
 Whether or not the Angler can ever randomly request this type of item for his daily quest. Returns false by default. More...
 
virtual bool 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. By default, this will return the same value as the IsArmorSet hook (passing the equipment textures' associated items as parameters), so you will not have to use this hook unless you want vanity effects to be entirely separate from armor sets. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual bool ItemSpace (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 (TagCompound tag)
 Allows you to load custom data that you have saved for this item. More...
 
virtual void LoadLegacy (BinaryReader reader)
 Allows you to load pre-v0.9 custom data that you have saved for this item. More...
 
virtual void MeleeEffects (Player player, Rectangle hitbox)
 Allows you to give this melee weapon special effects, such as creating light or dust. More...
 
virtual float MeleeSpeedMultiplier (Player player)
 Allows you to change the effective useAnimation of this item. More...
 
virtual void ModifyHitNPC (Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
 Allows you to modify the damage, knockback, etc., that this melee weapon does to an NPC. More...
 
virtual void ModifyHitPvp (Player player, Player target, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that this melee weapon does to a player. More...
 
virtual void ModifyManaCost (Player player, ref float reduce, ref float mult)
 Allows you to temporarily modify the amount of mana this item will consume on use, based on player buffs, accessories, etc. This is only called for items with a mana value. More...
 
virtual void ModifyTooltips (List< TooltipLine > tooltips)
 Allows you to modify all the tooltips that display for this item. See here for information about TooltipLine. More...
 
virtual void ModifyWeaponDamage (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 creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts). More...
 
virtual void ModifyWeaponDamage (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 creating new classes of damage, or for making subclasses of damage (for example, Shroomite armor set boosts). More...
 
virtual void NetRecieve (BinaryReader reader)
 Receives the custom data sent in the NetSend hook. More...
 
virtual void NetSend (BinaryWriter writer)
 Allows you to send custom data for this item between client and server. More...
 
virtual ModItem NewInstance (Item itemClone)
 Create a new instance of this ModItem 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 ()
 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 (Player player)
 Allows you to makes 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 (Player player)
 Allows you to make things happen when this item is consumed. Called before the item stack is reduced. More...
 
virtual void OnConsumeMana (Player player, int manaConsumed)
 Allows you to make stuff happen when a player consumes mana on use of this item. More...
 
virtual void OnCraft (Recipe recipe)
 Allows you to make anything happen when the player crafts this item using the given recipe. More...
 
virtual void OnHitNPC (Player player, NPC target, int damage, float knockBack, bool crit)
 Allows you to create special effects when this melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads). More...
 
virtual void OnHitPvp (Player player, Player target, int damage, bool crit)
 Allows you to create special effects when this melee weapon hits a player. More...
 
virtual void OnMissingMana (Player player, int neededMana)
 Allows you to make stuff happen when a player doesn't have enough mana for the item they are trying to use. If the player has high enough mana after this hook runs, mana consumption will happen normally. Only runs once per item use. More...
 
virtual bool OnPickup (Player player)
 Allows you to make special things happen when the player picks up this item. Return false to stop the item from being added to the player's inventory; returns true by default. More...
 
virtual void OpenBossBag (Player player)
 Allows you to give items to the given player when this item is right-clicked in the inventory if the bossBagNPC field has been set to a positive number. This ignores the CanRightClick and RightClick hooks. More...
 
virtual void PickAmmo (Item weapon, 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. This hook is called on the ammo. More...
 
virtual void PickAmmo (Player player, ref int type, ref float speed, ref int damage, ref float knockback)
 
virtual void PostDrawInInventory (SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
 Allows you to draw things in front of this item in the inventory. This method is called even if PreDrawInInventory returns false. More...
 
virtual void PostDrawInWorld (SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
 Allows you to draw things in front of this item. This method is called even if PreDrawInWorld returns false. More...
 
virtual void PostDrawTooltip (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 (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 ()
 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 ()
 Allows you to make things happen when this item is lying in the world. This will always be called, even when it 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 (SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
 Allows you to draw things behind this 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 (SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
 Allows you to draw things behind this item, or to modify the way this 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 (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 (DrawableTooltipLine line, ref int yOffset)
 Allows you to do things before a tooltip line of this item is drawn. The line contains draw info. More...
 
virtual ? bool PrefixChance (int pre, UnifiedRandom rand)
 To prevent putting the item in the tinkerer slot, return false when pre is -3. To prevent rolling of a prefix on spawn, return false when pre is -1. To force rolling of a prefix on spawn, return true when pre is -1. More...
 
virtual void PreReforge ()
 
virtual void PreUpdateVanitySet (Player player)
 Allows you to create special effects (such as the necro armor's hurt noise) when the player wears this item's vanity set. This hook is called regardless of whether the player is frozen in any way. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual bool ReforgePrice (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 (Player player)
 Allows you to make things happen when this item is right-clicked in the inventory. Useful for goodie bags. More...
 
virtual TagCompound Save ()
 Allows you to save custom data for this item. Returns null by default. More...
 
virtual void SetDefaults ()
 This is where you set all your item's properties, such as width, damage, shootSpeed, defense, etc. For those that are familiar with tAPI, this has the same function as .json files. More...
 
virtual void SetMatch (bool male, ref int equipSlot, ref bool robes)
 Allows you to modify the equipment that the player appears to be wearing. This hook will only be called for body armor and leg armor. Note that equipSlot is 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. If this hook is called on body armor, equipSlot allows you to modify the leg armor the player appears to be wearing. If you modify it, make sure to set robes to true. If this hook is called on leg armor, equipSlot allows you to modify the leg armor the player appears to be wearing, and the robes parameter is useless. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual void SetStaticDefaults ()
 This is where you set all your item's static properties, such as names/translations and the arrays in ItemID.Sets. This is called after SetDefaults on the initial ModItem More...
 
virtual bool Shoot (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 (ref float gravity, ref float maxFallSpeed)
 Allows you to customize this item's movement when lying in the world. Note that this will not be called if this item is currently being grabbed by a player. More...
 
virtual void UpdateAccessory (Player player, bool hideVisual)
 Allows you to give effects to this accessory. 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)
 Allows you to give set bonuses to the armor set that this armor is in. Set player.setBonus to a string for the bonus description. More...
 
virtual void UpdateEquip (Player player)
 Allows you to give effects to this armor or accessory, such as increased damage. More...
 
virtual void UpdateInventory (Player player)
 Allows you to make things happen when this item is in the player's inventory (for example, how the cell phone makes information display). More...
 
virtual void UpdateVanity (Player player, EquipType type)
 Allows you to create special effects (such as dust) when this item's equipment texture of the given equipment type is displayed on the player. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual void UpdateVanitySet (Player player)
 Allows you to create special effects (such as dust) when the player wears this item's vanity set. This hook will only be called if the player is not frozen in any way. Note that this hook is only ever called through this item's associated equipment texture. More...
 
virtual bool UseItem (Player player)
 Allows you to make things happen when this item is used. Return true if using this item actually does stuff. Returns false by default. Runs on all clients and server. Use More...
 
virtual bool UseItemFrame (Player player)
 Allows you to modify the player's animation when this item is being used. Return true if you modify the player's animation. Returns false by default. More...
 
virtual void UseItemHitbox (Player player, ref Rectangle hitbox, ref bool noHitbox)
 Changes the hitbox of this melee weapon when it is used. More...
 
virtual void UseStyle (Player player)
 Allows you to modify the location and rotation of this item in its use animation. More...
 
virtual float UseTimeMultiplier (Player player)
 Allows you to change the effective useTime of this item. More...
 
virtual void VerticalWingSpeeds (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 these wings are equipped. More...
 
virtual bool WingUpdate (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 these wings visually appear on the player. Use to animate wings, create dusts, invoke sounds, and create lights. Note that this hook is only ever called through this item's associated equipment texture. False will keep everything the same. True, you need to handle all animations in your own code. More...
 

Public Attributes

int bossBagNPC
 
bool projOnSwing
 

Properties

virtual int BossBagNPC [get]
 The type of NPC that drops this boss bag. Used to determine how many coins this boss bag contains. Defaults to 0, which means this isn't a boss bag. More...
 
int BossBagNPC_Obsolete [get, set]
 
virtual bool CloneNewInstances [get]
 Whether instances of this ModItem are created through Clone or constructor (by default implementations of NewInstance and Clone(Item, Item)). Defaults to false (using default constructor). More...
 
ModTranslation DisplayName [get, set]
 The translations for the display name of this item. More...
 
virtual bool IgnoreDamageModifiers [get]
 Set this to true to prevent this weapon or ammo item from being adjusted by damage modifiers. More...
 
Item item [get, set]
 The item object that this ModItem controls. More...
 
Mod mod [get, set]
 Gets the mod. More...
 
string Name [get, set]
 The internal name of this ModItem. More...
 
virtual bool OnlyShootOnSwing [get]
 Setting this to true makes it so that this weapon can shoot projectiles only at the beginning of its animation. Set this to true if you want a sword and its projectile creation to be in sync (for example, the Terra Blade). Defaults to false. More...
 
bool ProjOnSwing_Obsolete [get, set]
 
virtual string Texture [get]
 The file name of this item's texture file in the mod loader's file space. More...
 
ModTranslation Tooltip [get, set]
 The translations for the display name of this tooltip. More...
 

Detailed Description

This class serves as a place for you to place all your properties and hooks for each item. Create instances of ModItem (preferably overriding this class) to pass as parameters to Mod.AddItem.

Definition at line 16 of file ModItem.cs.

Constructor & Destructor Documentation

◆ ModItem()

Terraria.ModLoader.ModItem.ModItem ( )

Definition at line 89 of file ModItem.cs.

89 {
90 item = new Item { modItem = this };
91 }
Item item
The item object that this ModItem controls.
Definition: ModItem.cs:26

References Terraria.ModLoader.ModItem.item, and Terraria.ModLoader.Item.

Referenced by Terraria.ModLoader.ModItem.NewInstance().

+ Here is the caller graph for this function:

Member Function Documentation

◆ AddRecipes()

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

This is essentially the same as Mod.AddRecipes. Do note that this will be called for every instance of the overriding ModItem class that is added to the game. This allows you to avoid clutter in your overriding Mod class by adding recipes for which this item is the result.

Definition at line 1051 of file ModItem.cs.

1051 {
1052 }

◆ AllowPrefix()

virtual bool Terraria.ModLoader.ModItem.AllowPrefix ( int  pre)
virtual

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

◆ AltFunctionUse()

virtual bool Terraria.ModLoader.ModItem.AltFunctionUse ( Player  player)
virtual

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

Parameters
playerThe player.
Returns

Definition at line 545 of file ModItem.cs.

545 {
546 return false;
547 }

◆ AnglerQuestChat()

virtual void Terraria.ModLoader.ModItem.AnglerQuestChat ( ref string  description,
ref string  catchLocation 
)
virtual

Allows you to set what the Angler says when he requests for this item. The description parameter is his dialogue, and catchLocation should be set to "\n(Caught at [location])".

Parameters
descriptionThe description.
catchLocationThe catch location.

Definition at line 994 of file ModItem.cs.

994 {
995 }

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

+ Here is the caller graph for this function:

◆ ArmorArmGlowMask()

virtual void Terraria.ModLoader.ModItem.ArmorArmGlowMask ( 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. Also note that this hook is only ever called through this item's associated equipment texture.

Parameters
drawPlayerThe draw player.
shadowThe shadow.
glowMaskThe glow mask.
colorThe color.

Definition at line 761 of file ModItem.cs.

761 {
762 }

Referenced by Terraria.ModLoader.EquipTexture.ArmorArmGlowMask().

+ Here is the caller graph for this function:

◆ ArmorSetShadows()

virtual void Terraria.ModLoader.ModItem.ArmorSetShadows ( Player  player)
virtual

Allows you to determine special visual effects this vanity set has on the player without having to code them yourself. Note that this hook is only ever called through this item's associated equipment texture. Use the player.armorEffectDraw bools to activate the desired effects.

player.armorEffectDrawShadow = true;
Parameters
playerThe player.

Definition at line 637 of file ModItem.cs.

637 {
638 }

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

+ Here is the caller graph for this function:

◆ AutoDefaults()

virtual void Terraria.ModLoader.ModItem.AutoDefaults ( )
virtual

Automatically sets certain defaults. Override this if you do not want the properties to be set for you.

Definition at line 161 of file ModItem.cs.

161 {
162 EquipLoader.SetSlot(item);
163 }

References Terraria.ModLoader.ModItem.item.

◆ AutoLightSelect()

virtual void Terraria.ModLoader.ModItem.AutoLightSelect ( ref bool  dryTorch,
ref bool  wetTorch,
ref bool  glowstick 
)
virtual

Allows you to tell the game whether this item is a torch that cannot be placed in liquid, a torch that can be placed in liquid, or a glowstick. This information is used for when the player is holding down the auto-select hotkey.

Parameters
dryTorchif set to true [dry torch].
wetTorchif set to true [wet torch].
glowstickif set to true [glowstick].

Definition at line 965 of file ModItem.cs.

965 {
966 }

◆ Autoload()

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

Allows you to automatically load an item instead of using Mod.AddItem. Return true to allow autoloading; by default returns the mod's autoload property. Use this method to force or stop an autoload or change the internal name.

Parameters
nameThe name, initialized to the name of this type.

Definition at line 99 of file ModItem.cs.

99 {
100 return mod.Properties.Autoload;
101 }
ModProperties Properties
Definition: Mod.cs:52
Mod mod
Gets the mod.
Definition: ModItem.cs:37
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.ModItem.mod, and Terraria.ModLoader.Mod.Properties.

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

+ Here is the caller graph for this function:

◆ AutoStaticDefaults()

virtual void Terraria.ModLoader.ModItem.AutoStaticDefaults ( )
virtual

Automatically sets certain static defaults. Override this if you do not want the properties to be set for you.

Definition at line 175 of file ModItem.cs.

175 {
176 Main.itemTexture[item.type] = ModContent.GetTexture(Texture);
177
178 var flameTexture = Texture + "_Flame";
179 if (ModContent.TextureExists(flameTexture)) {
180 Main.itemFlameTexture[item.type] = ModContent.GetTexture(flameTexture);
181 Main.itemFlameLoaded[item.type] = true;
182 }
183
185 DisplayName.SetDefault(Regex.Replace(Name, "([A-Z])", " $1").Trim());
186 }
string Name
The internal name of this ModItem.
Definition: ModItem.cs:45
virtual string Texture
The file name of this item's texture file in the mod loader's file space.
Definition: ModItem.cs:69
ModTranslation DisplayName
The translations for the display name of this item.
Definition: ModItem.cs:53

References Terraria.ModLoader.ModItem.DisplayName, Terraria.ModLoader.ModContent.GetTexture(), Terraria.ModLoader.ModTranslation.IsDefault(), Terraria.ModLoader.ModItem.item, Terraria.ModLoader.ModItem.Name, Terraria.ModLoader.ModTranslation.SetDefault(), Terraria.ModLoader.ModItem.Texture, and Terraria.ModLoader.ModContent.TextureExists().

+ Here is the call graph for this function:

◆ CanBurnInLava()

virtual bool Terraria.ModLoader.ModItem.CanBurnInLava ( )
virtual

Returns whether or not this item burns when it is thrown into lava despite item.rare not being 0. Returns false by default.

Definition at line 807 of file ModItem.cs.

808 {
809 return false;
810 }

◆ CanEquipAccessory()

virtual bool Terraria.ModLoader.ModItem.CanEquipAccessory ( Player  player,
int  slot 
)
virtual

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

Parameters
playerThe player.
slotThe inventory slot that the item is attempting to occupy.

Definition at line 947 of file ModItem.cs.

947 {
948 return true;
949 }

◆ CanHitNPC()

virtual ? bool Terraria.ModLoader.ModItem.CanHitNPC ( Player  player,
NPC  target 
)
virtual

Allows you to determine whether this melee weapon can hit the given NPC when swung. Return true to allow hitting the target, return false to block this weapon from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default.

Parameters
playerThe player.
targetThe target.
Returns

Definition at line 436 of file ModItem.cs.

436 {
437 return null;
438 }

◆ CanHitPvp()

virtual bool Terraria.ModLoader.ModItem.CanHitPvp ( Player  player,
Player  target 
)
virtual

Allows you to determine whether this melee weapon can hit the given opponent player when swung. Return false to block this weapon from hitting the target. Returns true by default.

Parameters
playerThe player.
targetThe target.
Returns
true if this instance [can hit PVP] the specified player; otherwise, false.

Definition at line 470 of file ModItem.cs.

470 {
471 return true;
472 }

◆ CanPickup()

virtual bool Terraria.ModLoader.ModItem.CanPickup ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 839 of file ModItem.cs.

839 {
840 return true;
841 }

◆ CanRightClick()

virtual bool Terraria.ModLoader.ModItem.CanRightClick ( )
virtual

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

Definition at line 654 of file ModItem.cs.

654 {
655 return false;
656 }

◆ CanUseItem()

virtual bool Terraria.ModLoader.ModItem.CanUseItem ( Player  player)
virtual

Returns whether or not this item can be used. By default returns true.

Parameters
playerThe player using the item.

Definition at line 218 of file ModItem.cs.

218 {
219 return true;
220 }

◆ CaughtFishStack()

virtual void Terraria.ModLoader.ModItem.CaughtFishStack ( ref int  stack)
virtual

Allows you to determine how many of this item a player obtains when the player fishes this item.

Parameters
stackThe stack.

Definition at line 972 of file ModItem.cs.

972 {
973 }

◆ ChoosePrefix()

virtual int Terraria.ModLoader.ModItem.ChoosePrefix ( UnifiedRandom  rand)
virtual

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

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

◆ Clone() [1/2]

virtual ModItem Terraria.ModLoader.ModItem.Clone ( )
virtual

Returns a clone of this ModItem. Allows you to decide which fields of your ModItem class are copied over when an item stack is split or something similar happens. By default this will return a memberwise clone; you will want to override this if your ModItem contains object references. Only called if CloneNewInstances is set to true. Since several ModItem class fields are also set by the default implementation of this method, you'll most likely want to call base.Clone() as the first statement of your override.

var clone = (ExampleHookItem)base.Clone();
clone.targets = (int[])this.targets.Clone(); // Or whatever deep copy operations are relevant.
return clone;

Referenced by Terraria.ModLoader.ModItem.NewInstance().

+ Here is the caller graph for this function:

◆ Clone() [2/2]

virtual ModItem Terraria.ModLoader.ModItem.Clone ( Item  item)
virtual

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

Parameters
itemThe item being cloned
itemCloneThe new item

◆ ConsumeAmmo()

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

Parameters
playerThe player.
Returns

Definition at line 386 of file ModItem.cs.

386 {
387 return true;
388 }

◆ ConsumeItem()

virtual bool Terraria.ModLoader.ModItem.ConsumeItem ( Player  player)
virtual

If this item is consumable and this returns true, then this item will be consumed upon usage. Returns true by default. If false is returned, the OnConsumeItem hook is never called.

Parameters
playerThe player.
Returns

Definition at line 510 of file ModItem.cs.

510 {
511 return true;
512 }

◆ DrawArmorColor()

virtual void Terraria.ModLoader.ModItem.DrawArmorColor ( Player  drawPlayer,
float  shadow,
ref Color  color,
ref int  glowMask,
ref Color  glowMaskColor 
)
virtual

Allows you to modify the colors in which this armor and surrounding accessories are drawn, in addition to which glow mask and in what color is drawn. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
drawPlayerThe draw player.
shadowThe shadow.
colorThe color.
glowMaskThe glow mask.
glowMaskColorColor of the glow mask.

Definition at line 751 of file ModItem.cs.

751 {
752 }

Referenced by Terraria.ModLoader.EquipTexture.DrawArmorColor().

+ Here is the caller graph for this function:

◆ DrawBody()

virtual bool Terraria.ModLoader.ModItem.DrawBody ( )
virtual

Return false to hide the player's body when this body armor is worn. Returns true by default. Note that this hook is only ever called through this item's associated equipment texture.

Returns

Definition at line 731 of file ModItem.cs.

731 {
732 return true;
733 }

Referenced by Terraria.ModLoader.EquipTexture.DrawBody().

+ Here is the caller graph for this function:

◆ DrawHair()

virtual void Terraria.ModLoader.ModItem.DrawHair ( ref bool  drawHair,
ref bool  drawAltHair 
)
virtual

Allows you to determine whether the player's hair or alt (hat) hair draws when this head armor is worn. By default both flags will be false. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
drawHairif set to true [draw hair].
drawAltHairif set to true [draw alt hair].

Definition at line 716 of file ModItem.cs.

716 {
717 }

Referenced by Terraria.ModLoader.EquipTexture.DrawHair().

+ Here is the caller graph for this function:

◆ DrawHands()

virtual void Terraria.ModLoader.ModItem.DrawHands ( 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 this body armor is worn. By default both flags will be false. Note that if drawHands is false, the arms will not be drawn either. Also note that this hook is only ever called through this item's associated equipment texture.

Parameters
drawHandsif set to true [draw hands].
drawArmsif set to true [draw arms].

Definition at line 708 of file ModItem.cs.

708 {
709 }

Referenced by Terraria.ModLoader.EquipTexture.DrawHands().

+ Here is the caller graph for this function:

◆ DrawHead()

virtual bool Terraria.ModLoader.ModItem.DrawHead ( )
virtual

Return false to hide the player's head when this head armor is worn. Returns true by default. Note that this hook is only ever called through this item's associated equipment texture.

Returns

Definition at line 723 of file ModItem.cs.

723 {
724 return true;
725 }

Referenced by Terraria.ModLoader.EquipTexture.DrawHead().

+ Here is the caller graph for this function:

◆ DrawLegs()

virtual bool Terraria.ModLoader.ModItem.DrawLegs ( )
virtual

Return false to hide the player's legs when this leg armor or shoe accessory is worn. Returns true by default. Note that this hook is only ever called through this item's associated equipment texture.

Returns

Definition at line 739 of file ModItem.cs.

739 {
740 return true;
741 }

Referenced by Terraria.ModLoader.EquipTexture.DrawLegs().

+ Here is the caller graph for this function:

◆ ExtractinatorUse()

virtual void Terraria.ModLoader.ModItem.ExtractinatorUse ( ref int  resultType,
ref int  resultStack 
)
virtual

Allows you to modify what item, and in what quantity, is obtained when this item is fed into the Extractinator. By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator.

Parameters
resultTypeType of the result.
resultStackThe result stack.

Definition at line 956 of file ModItem.cs.

956 {
957 }

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

+ Here is the caller graph for this function:

◆ GetAlpha()

virtual ? Color Terraria.ModLoader.ModItem.GetAlpha ( Color  lightColor)
virtual

Allows you to determine the color and transparency in which this item is drawn. Return null to use the default color (normally light color). Returns null by default.

Parameters
lightColorColor of the light.
Returns

Definition at line 866 of file ModItem.cs.

866 {
867 return null;
868 }

◆ GetHealLife()

virtual void Terraria.ModLoader.ModItem.GetHealLife ( 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
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 267 of file ModItem.cs.

267 {
268 }

◆ GetHealMana()

virtual void Terraria.ModLoader.ModItem.GetHealMana ( 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
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 276 of file ModItem.cs.

276 {
277 }

◆ GetWeaponCrit()

virtual void Terraria.ModLoader.ModItem.GetWeaponCrit ( 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
playerThe player using this item
critThe critical strike chance, at 0 it will never trigger a crit and at 100 or above it will always trigger a crit

Definition at line 361 of file ModItem.cs.

361 {
362 }

◆ GetWeaponDamage()

virtual void Terraria.ModLoader.ModItem.GetWeaponDamage ( 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
playerThe player using the item
damageThe damage.

Definition at line 316 of file ModItem.cs.

316 {
317 }

◆ GetWeaponKnockback()

virtual void Terraria.ModLoader.ModItem.GetWeaponKnockback ( 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
playerThe player using the item
knockbackThe knockback

Definition at line 348 of file ModItem.cs.

348 {
349 }

◆ GrabRange()

virtual void Terraria.ModLoader.ModItem.GrabRange ( Player  player,
ref int  grabRange 
)
virtual

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

Parameters
playerThe player.
grabRangeThe grab range.

Definition at line 823 of file ModItem.cs.

823 {
824 }

◆ GrabStyle()

virtual bool Terraria.ModLoader.ModItem.GrabStyle ( Player  player)
virtual

Allows you to modify the way this item moves towards the player. Return true if you override this hook; returning false will allow the vanilla grab style to take place. Returns false by default.

Parameters
playerThe player.
Returns

Definition at line 831 of file ModItem.cs.

831 {
832 return false;
833 }

◆ HoldItem()

virtual void Terraria.ModLoader.ModItem.HoldItem ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 240 of file ModItem.cs.

240 {
241 }

◆ HoldItemFrame()

virtual bool Terraria.ModLoader.ModItem.HoldItemFrame ( Player  player)
virtual

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

Parameters
playerThe player.
Returns

Definition at line 536 of file ModItem.cs.

536 {
537 return false;
538 }

◆ HoldoutOffset()

virtual ? Vector2 Terraria.ModLoader.ModItem.HoldoutOffset ( )
virtual

Allows you to determine the offset of this 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 vanilla holdout offset; returns null by default.

Returns

Definition at line 930 of file ModItem.cs.

930 {
931 return null;
932 }

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

+ Here is the caller graph for this function:

◆ HoldoutOrigin()

virtual ? Vector2 Terraria.ModLoader.ModItem.HoldoutOrigin ( )
virtual

Allows you to determine the point on this item's sprite that the player holds onto when using this 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 vanilla holdout origin (zero); returns null by default.

Returns

Definition at line 938 of file ModItem.cs.

938 {
939 return null;
940 }

◆ HoldStyle()

virtual void Terraria.ModLoader.ModItem.HoldStyle ( Player  player)
virtual

Allows you to modify the location and rotation of this item when the player is holding it.

Parameters
playerThe player.

Definition at line 233 of file ModItem.cs.

233 {
234 }

◆ HorizontalWingSpeeds()

virtual void Terraria.ModLoader.ModItem.HorizontalWingSpeeds ( Player  player,
ref float  speed,
ref float  acceleration 
)
virtual

Allows you to modify these wing's horizontal flight speed and acceleration.

Parameters
playerThe player.
speedThe speed.
accelerationThe acceleration.

Definition at line 783 of file ModItem.cs.

783 {
784 }

Referenced by Terraria.ModLoader.EquipTexture.HorizontalWingSpeeds().

+ Here is the caller graph for this function:

◆ IsAnglerQuestAvailable()

virtual bool Terraria.ModLoader.ModItem.IsAnglerQuestAvailable ( )
virtual

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

Definition at line 985 of file ModItem.cs.

985 {
986 return true;
987 }

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

+ Here is the caller graph for this function:

◆ IsArmorSet()

virtual bool Terraria.ModLoader.ModItem.IsArmorSet ( Item  head,
Item  body,
Item  legs 
)
virtual

Returns whether or not the head armor, body armor, and leg armor make up a set. If this returns true, then this item's UpdateArmorSet method will be called. Returns false by default.

Parameters
headThe head.
bodyThe body.
legsThe legs.

Definition at line 585 of file ModItem.cs.

585 {
586 return false;
587 }

Referenced by Terraria.ModLoader.ModItem.IsVanitySet().

+ Here is the caller graph for this function:

◆ IsQuestFish()

virtual bool Terraria.ModLoader.ModItem.IsQuestFish ( )
virtual

Whether or not the Angler can ever randomly request this type of item for his daily quest. Returns false by default.

Definition at line 978 of file ModItem.cs.

978 {
979 return false;
980 }

◆ IsVanitySet()

virtual bool Terraria.ModLoader.ModItem.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. By default, this will return the same value as the IsArmorSet hook (passing the equipment textures' associated items as parameters), so you will not have to use this hook unless you want vanity effects to be entirely separate from armor sets. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
headThe head.
bodyThe body.
legsThe legs.

Definition at line 602 of file ModItem.cs.

602 {
603 Item headItem = new Item();
604 if (head >= 0) {
605 headItem.SetDefaults(Item.headType[head], true);
606 }
607 Item bodyItem = new Item();
608 if (body >= 0) {
609 bodyItem.SetDefaults(Item.bodyType[body], true);
610 }
611 Item legItem = new Item();
612 if (legs >= 0) {
613 legItem.SetDefaults(Item.legType[legs], true);
614 }
615 return IsArmorSet(headItem, bodyItem, legItem);
616 }
virtual bool IsArmorSet(Item head, Item body, Item legs)
Returns whether or not the head armor, body armor, and leg armor make up a set. If this returns true,...
Definition: ModItem.cs:585

References Terraria.ModLoader.ModItem.IsArmorSet(), and Terraria.ModLoader.Item.

Referenced by Terraria.ModLoader.EquipTexture.IsVanitySet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ItemSpace()

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

Parameters
playerThe player.
Returns

Definition at line 857 of file ModItem.cs.

857 {
858 return false;
859 }

◆ Load()

virtual void Terraria.ModLoader.ModItem.Load ( TagCompound  tag)
virtual

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

Parameters
tagThe tag.

Definition at line 1024 of file ModItem.cs.

1024 {
1025 }

◆ LoadLegacy()

virtual void Terraria.ModLoader.ModItem.LoadLegacy ( BinaryReader  reader)
virtual

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

Parameters
readerThe reader.

Definition at line 1031 of file ModItem.cs.

1031 {
1032 }

◆ MeleeEffects()

virtual void Terraria.ModLoader.ModItem.MeleeEffects ( Player  player,
Rectangle  hitbox 
)
virtual

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

Parameters
playerThe player.
hitboxThe hitbox.

Definition at line 427 of file ModItem.cs.

427 {
428 }

◆ MeleeSpeedMultiplier()

virtual float Terraria.ModLoader.ModItem.MeleeSpeedMultiplier ( Player  player)
virtual

Allows you to change the effective useAnimation of this item.

Parameters
player
Returns
The multiplier on the animation speed. 1f by default. Values greater than 1 increase the item speed.

Definition at line 257 of file ModItem.cs.

257 {
258 return 1f;
259 }

◆ ModifyHitNPC()

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

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

Parameters
playerThe player.
targetThe target.
damageThe damage.
knockBackThe knock back.
critif set to true [crit].

Definition at line 448 of file ModItem.cs.

448 {
449 }

◆ ModifyHitPvp()

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

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

Parameters
playerThe player.
targetThe target.
damageThe damage.
critif set to true [crit].

Definition at line 481 of file ModItem.cs.

481 {
482 }

◆ ModifyManaCost()

virtual void Terraria.ModLoader.ModItem.ModifyManaCost ( Player  player,
ref float  reduce,
ref float  mult 
)
virtual

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

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

Definition at line 285 of file ModItem.cs.

285 {
286 }

◆ ModifyTooltips()

virtual void Terraria.ModLoader.ModItem.ModifyTooltips ( List< TooltipLine tooltips)
virtual

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

Parameters
tooltipsThe tooltips.

Definition at line 1100 of file ModItem.cs.

1100 {
1101 }

◆ ModifyWeaponDamage() [1/2]

virtual void Terraria.ModLoader.ModItem.ModifyWeaponDamage ( Player  player,
ref float  add,
ref float  mult 
)
virtual

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

Parameters
playerThe player using the item
addUsed for additively stacking buffs (most common). Only ever use += on this field.
multUse to directly multiply the player's effective damage. Good for debuffs, or things which should stack separately (eg ammo type buffs)

Definition at line 326 of file ModItem.cs.

326 {
327 }

◆ ModifyWeaponDamage() [2/2]

virtual void Terraria.ModLoader.ModItem.ModifyWeaponDamage ( Player  player,
ref float  add,
ref float  mult,
ref float  flat 
)
virtual

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

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

Definition at line 336 of file ModItem.cs.

336 {
337 }

◆ NetRecieve()

virtual void Terraria.ModLoader.ModItem.NetRecieve ( BinaryReader  reader)
virtual

Receives the custom data sent in the NetSend hook.

Parameters
readerThe reader.

Definition at line 1045 of file ModItem.cs.

1045 {
1046 }

◆ NetSend()

virtual void Terraria.ModLoader.ModItem.NetSend ( BinaryWriter  writer)
virtual

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

Parameters
writerThe writer.

Definition at line 1038 of file ModItem.cs.

1038 {
1039 }

◆ NewInstance()

virtual ModItem Terraria.ModLoader.ModItem.NewInstance ( Item  itemClone)
virtual

Create a new instance of this ModItem 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 135 of file ModItem.cs.

135 {
136 if (CloneNewInstances) {
137 var clone = Clone();
138 clone.item = itemClone;
139 return clone;
140 }
141
142 var copy = (ModItem)Activator.CreateInstance(GetType());
143 copy.item = itemClone;
144 copy.mod = mod;
145 copy.Name = Name;
146 copy.ProjOnSwing_Obsolete = ProjOnSwing_Obsolete;
147 copy.BossBagNPC_Obsolete = BossBagNPC_Obsolete;
148 return copy;
149 }
virtual bool CloneNewInstances
Whether instances of this ModItem are created through Clone or constructor (by default implementation...
Definition: ModItem.cs:107
virtual ModItem Clone()
Returns a clone of this ModItem. Allows you to decide which fields of your ModItem class are copied o...

References Terraria.ModLoader.ModItem.ModItem(), Terraria.ModLoader.ModItem.BossBagNPC_Obsolete, Terraria.ModLoader.ModItem.Clone(), Terraria.ModLoader.ModItem.CloneNewInstances, Terraria.ModLoader.ModItem.mod, Terraria.ModLoader.ModItem.Name, and Terraria.ModLoader.ModItem.ProjOnSwing_Obsolete.

+ Here is the call graph for this function:

◆ NewPreReforge()

virtual bool Terraria.ModLoader.ModItem.NewPreReforge ( )
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 686 of file ModItem.cs.

686 {
687 return true;
688 }

◆ OnConsumeAmmo()

virtual void Terraria.ModLoader.ModItem.OnConsumeAmmo ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 395 of file ModItem.cs.

395 {
396 }

◆ OnConsumeItem()

virtual void Terraria.ModLoader.ModItem.OnConsumeItem ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 519 of file ModItem.cs.

519 {
520 }

◆ OnConsumeMana()

virtual void Terraria.ModLoader.ModItem.OnConsumeMana ( Player  player,
int  manaConsumed 
)
virtual

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

Parameters
playerThe player using the item.
manaConsumedThe mana consumed from the player.

Definition at line 303 of file ModItem.cs.

303 {
304 }

◆ OnCraft()

virtual void Terraria.ModLoader.ModItem.OnCraft ( Recipe  recipe)
virtual

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

Parameters
recipeThe recipe that was used to craft this item.

Definition at line 1058 of file ModItem.cs.

1058 {
1059 }

◆ OnHitNPC()

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

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

Parameters
playerThe player.
targetThe target.
damageThe damage.
knockBackThe knock back.
critif set to true [crit].

Definition at line 459 of file ModItem.cs.

459 {
460 }

◆ OnHitPvp()

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

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

Parameters
playerThe player.
targetThe target.
damageThe damage.
critif set to true [crit].

Definition at line 491 of file ModItem.cs.

491 {
492 }

◆ OnMissingMana()

virtual void Terraria.ModLoader.ModItem.OnMissingMana ( Player  player,
int  neededMana 
)
virtual

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

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

Definition at line 295 of file ModItem.cs.

295 {
296 }

◆ OnPickup()

virtual bool Terraria.ModLoader.ModItem.OnPickup ( Player  player)
virtual

Allows you to make special things happen when the player picks up this item. Return false to stop the item from being added to the player's inventory; returns true by default.

Parameters
playerThe player.
Returns

Definition at line 848 of file ModItem.cs.

848 {
849 return true;
850 }

◆ OpenBossBag()

virtual void Terraria.ModLoader.ModItem.OpenBossBag ( Player  player)
virtual

Allows you to give items to the given player when this item is right-clicked in the inventory if the bossBagNPC field has been set to a positive number. This ignores the CanRightClick and RightClick hooks.

Parameters
playerThe player.

Definition at line 669 of file ModItem.cs.

669 {
670 }

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

+ Here is the caller graph for this function:

◆ PickAmmo() [1/2]

virtual void Terraria.ModLoader.ModItem.PickAmmo ( Item  weapon,
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. This hook is called on the ammo.

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

Definition at line 373 of file ModItem.cs.

373 {
374 }

◆ PickAmmo() [2/2]

virtual void Terraria.ModLoader.ModItem.PickAmmo ( Player  player,
ref int  type,
ref float  speed,
ref int  damage,
ref float  knockback 
)
virtual

Definition at line 377 of file ModItem.cs.

377 {
378 }

◆ PostDrawInInventory()

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

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

Parameters
spriteBatchThe sprite batch.
positionThe position.
frameThe frame.
drawColorColor of the draw.
itemColorColor of the item.
originThe origin.
scaleThe scale.

Definition at line 922 of file ModItem.cs.

923 {
924 }

◆ PostDrawInWorld()

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

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

Parameters
spriteBatchThe sprite batch.
lightColorColor of the light.
alphaColorColor of the alpha.
rotationThe rotation.
scaleThe scale.
whoAmIThe who am i.

Definition at line 893 of file ModItem.cs.

893 {
894 }

◆ PostDrawTooltip()

virtual void Terraria.ModLoader.ModItem.PostDrawTooltip ( 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
linesThe tooltip lines for this item

Definition at line 1076 of file ModItem.cs.

1076 {
1077 }

◆ PostDrawTooltipLine()

virtual void Terraria.ModLoader.ModItem.PostDrawTooltipLine ( DrawableTooltipLine  line)
virtual

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

Parameters
lineThe line that was drawn

Definition at line 1093 of file ModItem.cs.

1093 {
1094 }

◆ PostReforge()

virtual void Terraria.ModLoader.ModItem.PostReforge ( )
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 700 of file ModItem.cs.

700 {
701 }

◆ PostUpdate()

virtual void Terraria.ModLoader.ModItem.PostUpdate ( )
virtual

Allows you to make things happen when this item is lying in the world. This will always be called, even when it 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 815 of file ModItem.cs.

815 {
816 }

◆ PreDrawInInventory()

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

Allows you to draw things behind this 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.

Parameters
spriteBatchThe sprite batch.
positionThe position.
frameThe frame.
drawColorColor of the draw.
itemColorColor of the item.
originThe origin.
scaleThe scale.
Returns

Definition at line 907 of file ModItem.cs.

908 {
909 return true;
910 }

◆ PreDrawInWorld()

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

Allows you to draw things behind this item, or to modify the way this 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.

Parameters
spriteBatchThe sprite batch.
lightColorColor of the light.
alphaColorColor of the alpha.
rotationThe rotation.
scaleThe scale.
whoAmIThe who am i.
Returns

Definition at line 880 of file ModItem.cs.

880 {
881 return true;
882 }

◆ PreDrawTooltip()

virtual bool Terraria.ModLoader.ModItem.PreDrawTooltip ( ReadOnlyCollection< TooltipLine lines,
ref int  x,
ref int  y 
)
virtual

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

Parameters
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 1068 of file ModItem.cs.

1068 {
1069 return true;
1070 }

◆ PreDrawTooltipLine()

virtual bool Terraria.ModLoader.ModItem.PreDrawTooltipLine ( 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
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 1085 of file ModItem.cs.

1085 {
1086 return true;
1087 }

◆ PrefixChance()

virtual ? bool Terraria.ModLoader.ModItem.PrefixChance ( int  pre,
UnifiedRandom  rand 
)
virtual

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

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

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

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

◆ PreReforge()

virtual void Terraria.ModLoader.ModItem.PreReforge ( )
virtual

Definition at line 692 of file ModItem.cs.

692 {
693 item.modItem?.NewPreReforge();
694 }

References Terraria.ModLoader.ModItem.item.

◆ PreUpdateVanitySet()

virtual void Terraria.ModLoader.ModItem.PreUpdateVanitySet ( Player  player)
virtual

Allows you to create special effects (such as the necro armor's hurt noise) when the player wears this item's vanity set. This hook is called regardless of whether the player is frozen in any way. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
playerThe player.

Definition at line 622 of file ModItem.cs.

622 {
623 }

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

+ Here is the caller graph for this function:

◆ ReforgePrice()

virtual bool Terraria.ModLoader.ModItem.ReforgePrice ( 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 677 of file ModItem.cs.

677 {
678 return true;
679 }

◆ RightClick()

virtual void Terraria.ModLoader.ModItem.RightClick ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 662 of file ModItem.cs.

662 {
663 }

◆ Save()

virtual TagCompound Terraria.ModLoader.ModItem.Save ( )
virtual

Allows you to save custom data for this item. Returns null by default.

Returns

Definition at line 1016 of file ModItem.cs.

1016 {
1017 return null;
1018 }

◆ SetDefaults()

virtual void Terraria.ModLoader.ModItem.SetDefaults ( )
virtual

This is where you set all your item's properties, such as width, damage, shootSpeed, defense, etc. For those that are familiar with tAPI, this has the same function as .json files.

Definition at line 155 of file ModItem.cs.

155 {
156 }

◆ SetMatch()

virtual void Terraria.ModLoader.ModItem.SetMatch ( bool  male,
ref int  equipSlot,
ref bool  robes 
)
virtual

Allows you to modify the equipment that the player appears to be wearing. This hook will only be called for body armor and leg armor. Note that equipSlot is 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. If this hook is called on body armor, equipSlot allows you to modify the leg armor the player appears to be wearing. If you modify it, make sure to set robes to true. If this hook is called on leg armor, equipSlot allows you to modify the leg armor the player appears to be wearing, and the robes parameter is useless. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
maleif set to true [male].
equipSlotThe equip slot.
robesif set to true [robes].

Definition at line 648 of file ModItem.cs.

648 {
649 }

Referenced by Terraria.ModLoader.EquipTexture.SetMatch().

+ Here is the caller graph for this function:

◆ SetStaticDefaults()

virtual void Terraria.ModLoader.ModItem.SetStaticDefaults ( )
virtual

This is where you set all your item's static properties, such as names/translations and the arrays in ItemID.Sets. This is called after SetDefaults on the initial ModItem

Definition at line 169 of file ModItem.cs.

169 {
170 }

◆ Shoot()

virtual bool Terraria.ModLoader.ModItem.Shoot ( 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
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 choosen by ammo and weapon.
damageThe projectile damage.
knockBackThe projectile knock back.
Returns

Definition at line 409 of file ModItem.cs.

409 {
410 return true;
411 }

◆ Update()

virtual void Terraria.ModLoader.ModItem.Update ( ref float  gravity,
ref float  maxFallSpeed 
)
virtual

Allows you to customize this item's movement when lying in the world. Note that this will not be called if this item is currently being grabbed by a player.

Parameters
gravityThe gravity.
maxFallSpeedThe maximum fall speed.

Definition at line 801 of file ModItem.cs.

801 {
802 }

◆ UpdateAccessory()

virtual void Terraria.ModLoader.ModItem.UpdateAccessory ( Player  player,
bool  hideVisual 
)
virtual

Allows you to give effects to this accessory. The hideVisual parameter is whether the player has marked the accessory slot to be hidden from being drawn on the player.

Parameters
playerThe player.
hideVisualif set to true the accessory is hidden.

Definition at line 568 of file ModItem.cs.

568 {
569 }

◆ UpdateArmorSet()

virtual void Terraria.ModLoader.ModItem.UpdateArmorSet ( Player  player)
virtual

Allows you to give set bonuses to the armor set that this armor is in. Set player.setBonus to a string for the bonus description.

Parameters
playerThe player.

Definition at line 593 of file ModItem.cs.

593 {
594 }

◆ UpdateEquip()

virtual void Terraria.ModLoader.ModItem.UpdateEquip ( Player  player)
virtual

Allows you to give effects to this armor or accessory, such as increased damage.

Parameters
playerThe player.

Definition at line 560 of file ModItem.cs.

560 {
561 }

◆ UpdateInventory()

virtual void Terraria.ModLoader.ModItem.UpdateInventory ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 553 of file ModItem.cs.

553 {
554 }

◆ UpdateVanity()

virtual void Terraria.ModLoader.ModItem.UpdateVanity ( Player  player,
EquipType  type 
)
virtual

Allows you to create special effects (such as dust) when this item's equipment texture of the given equipment type is displayed on the player. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
playerThe player.
typeThe type.

Definition at line 576 of file ModItem.cs.

576 {
577 }

Referenced by Terraria.ModLoader.EquipTexture.UpdateVanity().

+ Here is the caller graph for this function:

◆ UpdateVanitySet()

virtual void Terraria.ModLoader.ModItem.UpdateVanitySet ( Player  player)
virtual

Allows you to create special effects (such as dust) when the player wears this item's vanity set. This hook will only be called if the player is not frozen in any way. Note that this hook is only ever called through this item's associated equipment texture.

Parameters
playerThe player.

Definition at line 629 of file ModItem.cs.

629 {
630 }

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

+ Here is the caller graph for this function:

◆ UseItem()

virtual bool Terraria.ModLoader.ModItem.UseItem ( Player  player)
virtual

Allows you to make things happen when this item is used. Return true if using this item actually does stuff. Returns false by default. Runs on all clients and server. Use

if (player.whoAmI == Main.myPlayer) and if (Main.netMode == NetmodeID.??) if appropriate.

Parameters
playerThe player.
Returns

Definition at line 500 of file ModItem.cs.

500 {
501 return false;
502 }

◆ UseItemFrame()

virtual bool Terraria.ModLoader.ModItem.UseItemFrame ( Player  player)
virtual

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

Parameters
playerThe player.
Returns

Definition at line 527 of file ModItem.cs.

527 {
528 return false;
529 }

◆ UseItemHitbox()

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

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

Parameters
playerThe player.
hitboxThe hitbox.
noHitboxif set to true [no hitbox].

Definition at line 419 of file ModItem.cs.

419 {
420 }

◆ UseStyle()

virtual void Terraria.ModLoader.ModItem.UseStyle ( Player  player)
virtual

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

Parameters
playerThe player.

Definition at line 226 of file ModItem.cs.

226 {
227 }

◆ UseTimeMultiplier()

virtual float Terraria.ModLoader.ModItem.UseTimeMultiplier ( Player  player)
virtual

Allows you to change the effective useTime of this item.

Parameters
player
Returns
The multiplier on the usage speed. 1f by default. Values greater than 1 increase the item speed.

Definition at line 248 of file ModItem.cs.

248 {
249 return 1f;
250 }

◆ VerticalWingSpeeds()

virtual void Terraria.ModLoader.ModItem.VerticalWingSpeeds ( 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 these wings are equipped.

Parameters
playerThe player.
ascentWhenFallingThe ascent when falling.
ascentWhenRisingThe ascent when rising.
maxCanAscendMultiplierThe maximum can ascend multiplier.
maxAscentMultiplierThe maximum ascent multiplier.
constantAscendThe constant ascend.

Definition at line 773 of file ModItem.cs.

774 {
775 }

Referenced by Terraria.ModLoader.EquipTexture.VerticalWingSpeeds().

+ Here is the caller graph for this function:

◆ WingUpdate()

virtual bool Terraria.ModLoader.ModItem.WingUpdate ( 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 these wings visually appear on the player. Use to animate wings, create dusts, invoke sounds, and create lights. Note that this hook is only ever called through this item's associated equipment texture. False will keep everything the same. True, you need to handle all animations in your own code.

Parameters
playerThe player.
inUseif set to true [in use].
Returns

Definition at line 792 of file ModItem.cs.

792 {
793 return false;
794 }

Referenced by Terraria.ModLoader.EquipTexture.WingUpdate().

+ Here is the caller graph for this function:

Member Data Documentation

◆ bossBagNPC

int Terraria.ModLoader.ModItem.bossBagNPC

Definition at line 75 of file ModItem.cs.

◆ projOnSwing

bool Terraria.ModLoader.ModItem.projOnSwing

Definition at line 72 of file ModItem.cs.

Property Documentation

◆ BossBagNPC

virtual int Terraria.ModLoader.ModItem.BossBagNPC
get

The type of NPC that drops this boss bag. Used to determine how many coins this boss bag contains. Defaults to 0, which means this isn't a boss bag.

Definition at line 1005 of file ModItem.cs.

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

◆ BossBagNPC_Obsolete

int Terraria.ModLoader.ModItem.BossBagNPC_Obsolete
getsetprivate

Definition at line 84 of file ModItem.cs.

84 {
85 get => bossBagNPC;
86 set => bossBagNPC = value;
87 }

Referenced by Terraria.ModLoader.ModItem.NewInstance().

◆ CloneNewInstances

virtual bool Terraria.ModLoader.ModItem.CloneNewInstances
get

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

Definition at line 107 of file ModItem.cs.

Referenced by Terraria.ModLoader.ModItem.NewInstance().

◆ DisplayName

ModTranslation Terraria.ModLoader.ModItem.DisplayName
getset

The translations for the display name of this item.

Definition at line 53 of file ModItem.cs.

53 {
54 get;
55 internal set;
56 }

Referenced by Terraria.ModLoader.ModItem.AutoStaticDefaults(), and Terraria.ModLoader.ModContent.RefreshModLanguage().

◆ IgnoreDamageModifiers

virtual bool Terraria.ModLoader.ModItem.IgnoreDamageModifiers
get

Set this to true to prevent this weapon or ammo item from being adjusted by damage modifiers.

Definition at line 1010 of file ModItem.cs.

◆ item

◆ mod

Mod Terraria.ModLoader.ModItem.mod
getset

Gets the mod.

The mod that added this ModItem.

Definition at line 37 of file ModItem.cs.

37 {
38 get;
39 internal set;
40 }

Referenced by Terraria.ModLoader.ModItem.Autoload(), and Terraria.ModLoader.ModItem.NewInstance().

◆ Name

string Terraria.ModLoader.ModItem.Name
getset

The internal name of this ModItem.

Definition at line 45 of file ModItem.cs.

45 {
46 get;
47 internal set;
48 }

Referenced by Terraria.ModLoader.Mod.AutoloadItem(), Terraria.ModLoader.ModItem.AutoStaticDefaults(), and Terraria.ModLoader.ModItem.NewInstance().

◆ OnlyShootOnSwing

virtual bool Terraria.ModLoader.ModItem.OnlyShootOnSwing
get

Setting this to true makes it so that this weapon can shoot projectiles only at the beginning of its animation. Set this to true if you want a sword and its projectile creation to be in sync (for example, the Terra Blade). Defaults to false.

Definition at line 1000 of file ModItem.cs.

◆ ProjOnSwing_Obsolete

bool Terraria.ModLoader.ModItem.ProjOnSwing_Obsolete
getsetprivate

Definition at line 78 of file ModItem.cs.

78 {
79 get => projOnSwing;
80 set => projOnSwing = value;
81 }

Referenced by Terraria.ModLoader.ModItem.NewInstance().

◆ Texture

virtual string Terraria.ModLoader.ModItem.Texture
get

The file name of this item's texture file in the mod loader's file space.

Definition at line 69 of file ModItem.cs.

Referenced by Terraria.ModLoader.Mod.AutoloadItem(), and Terraria.ModLoader.ModItem.AutoStaticDefaults().

◆ Tooltip

ModTranslation Terraria.ModLoader.ModItem.Tooltip
getset

The translations for the display name of this tooltip.

Definition at line 61 of file ModItem.cs.

61 {
62 get;
63 internal set;
64 }

Referenced by Terraria.ModLoader.ModContent.RefreshModLanguage().