1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
5using System.Collections.ObjectModel;
7using System.Text.RegularExpressions;
9using Terraria.Utilities;
69 public virtual string Texture => (GetType().Namespace +
"." +
Name).Replace(
'.',
'/');
71 [Obsolete(
"override ModItem.OnlyShootOnSwing property",
true)]
74 [Obsolete(
"override ModItem.BossBagNPC property",
true)]
99 public virtual bool Autoload(ref
string name) {
138 clone.item = itemClone;
142 var copy = (
ModItem)Activator.CreateInstance(GetType());
143 copy.item = itemClone;
178 var flameTexture =
Texture +
"_Flame";
181 Main.itemFlameLoaded[
item.type] =
true;
207 public virtual bool?
PrefixChance(
int pre, UnifiedRandom rand) =>
null;
267 public virtual void GetHealLife(Player player,
bool quickHeal, ref
int healValue) {
276 public virtual void GetHealMana(Player player,
bool quickHeal, ref
int healValue) {
285 public virtual void ModifyManaCost(Player player, ref
float reduce, ref
float mult) {
315 [Obsolete(
"Use ModifyWeaponDamage",
true)]
325 [Obsolete(
"Use ModifyWeaponDamage overload with the additional flat parameter")]
336 public virtual void ModifyWeaponDamage(Player player, ref
float add, ref
float mult, ref
float flat) {
373 public virtual void PickAmmo(Item weapon, Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback) {
376 [Obsolete(
"PickAmmo now has a weapon parameter that represents the item using the ammo.")]
377 public virtual void PickAmmo(Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback) {
409 public virtual bool Shoot(Player player, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack) {
419 public virtual void UseItemHitbox(Player player, ref Rectangle hitbox, ref
bool noHitbox) {
436 public virtual bool?
CanHitNPC(Player player, NPC target) {
448 public virtual void ModifyHitNPC(Player player, NPC target, ref
int damage, ref
float knockBack, ref
bool crit) {
459 public virtual void OnHitNPC(Player player, NPC target,
int damage,
float knockBack,
bool crit) {
470 public virtual bool CanHitPvp(Player player, Player target) {
481 public virtual void ModifyHitPvp(Player player, Player target, ref
int damage, ref
bool crit) {
491 public virtual void OnHitPvp(Player player, Player target,
int damage,
bool crit) {
585 public virtual bool IsArmorSet(Item head, Item body, Item legs) {
605 headItem.SetDefaults(
Item.headType[head],
true);
609 bodyItem.SetDefaults(
Item.bodyType[body],
true);
613 legItem.SetDefaults(
Item.legType[legs],
true);
615 return IsArmorSet(headItem, bodyItem, legItem);
648 public virtual void SetMatch(
bool male, ref
int equipSlot, ref
bool robes) {
677 public virtual bool ReforgePrice(ref
int reforgePrice, ref
bool canApplyDiscount) {
691 [method: Obsolete(
"PreReforge now returns a bool to control whether the reforge takes place. For now, use NewPreReforge")]
693 item.modItem?.NewPreReforge();
708 public virtual void DrawHands(ref
bool drawHands, ref
bool drawArms) {
716 public virtual void DrawHair(ref
bool drawHair, ref
bool drawAltHair) {
751 public virtual void DrawArmorColor(Player drawPlayer,
float shadow, ref Color color, ref
int glowMask, ref Color glowMaskColor) {
761 public virtual void ArmorArmGlowMask(Player drawPlayer,
float shadow, ref
int glowMask, ref Color color) {
773 public virtual void VerticalWingSpeeds(Player player, ref
float ascentWhenFalling, ref
float ascentWhenRising,
774 ref
float maxCanAscendMultiplier, ref
float maxAscentMultiplier, ref
float constantAscend) {
801 public virtual void Update(ref
float gravity, ref
float maxFallSpeed) {
823 public virtual void GrabRange(Player player, ref
int grabRange) {
880 public virtual bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref
float rotation, ref
float scale,
int whoAmI) {
893 public virtual void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor,
float rotation,
float scale,
int whoAmI) {
907 public virtual bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor,
908 Color itemColor, Vector2 origin,
float scale) {
922 public virtual void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor,
923 Color itemColor, Vector2 origin,
float scale) {
965 public virtual void AutoLightSelect(ref
bool dryTorch, ref
bool wetTorch, ref
bool glowstick) {
994 public virtual void AnglerQuestChat(ref
string description, ref
string catchLocation) {
1068 public virtual bool PreDrawTooltip(ReadOnlyCollection<TooltipLine> lines, ref
int x, ref
int y) {
This serves as a central place to store equipment slots and their corresponding textures....
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
static bool TextureExists(string name)
Returns whether or not a texture with the specified name exists.
static Texture2D GetTexture(string name)
Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNa...
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
This class serves as a place for you to place all your properties and hooks for each item....
virtual bool PreDrawTooltip(ReadOnlyCollection< TooltipLine > lines, ref int x, ref int y)
Allows you to do things before this item's tooltip is drawn.
virtual void UpdateInventory(Player player)
Allows you to make things happen when this item is in the player's inventory (for example,...
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 call...
virtual void MeleeEffects(Player player, Rectangle hitbox)
Allows you to give this melee weapon special effects, such as creating light or dust.
virtual void GetWeaponKnockback(Player player, ref float knockback)
Allows you to temporarily modify this weapon's knockback based on player buffs, etc....
virtual void PostUpdate()
Allows you to make things happen when this item is lying in the world. This will always be called,...
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 drawi...
ModTranslation Tooltip
The translations for the display name of this tooltip.
virtual bool DrawBody()
Return false to hide the player's body when this body armor is worn. Returns true by default....
virtual bool IsQuestFish()
Whether or not the Angler can ever randomly request this type of item for his daily quest....
virtual void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox)
Changes the hitbox of this melee weapon when it is used.
virtual bool CanPickup(Player player)
Allows you to determine whether or not the item can be picked up
virtual void PostDrawTooltipLine(DrawableTooltipLine line)
Allows you to do things after a tooltip line of this item is drawn. The line contains draw info.
virtual void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)
Allows you to modify these wing's horizontal flight speed and acceleration.
virtual bool GrabStyle(Player player)
Allows you to modify the way this item moves towards the player. Return true if you override this hoo...
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.
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....
virtual void UpdateAccessory(Player player, bool hideVisual)
Allows you to give effects to this accessory. The hideVisual parameter is whether the player has mark...
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 bod...
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.
virtual float MeleeSpeedMultiplier(Player player)
Allows you to change the effective useAnimation of this item.
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....
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,...
virtual void AutoDefaults()
Automatically sets certain defaults. Override this if you do not want the properties to be set for yo...
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,...
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 ...
virtual void OnConsumeAmmo(Player player)
Allows you to makes things happen when ammo is consumed. Called both by the gun and by the ammo....
virtual bool UseItemFrame(Player player)
Allows you to modify the player's animation when this item is being used. Return true if you modify t...
virtual ? Vector2 HoldoutOffset()
Allows you to determine the offset of this item's sprite when used by the player. This is only used f...
virtual ? bool CanHitNPC(Player player, NPC target)
Allows you to determine whether this melee weapon can hit the given NPC when swung....
virtual bool DrawHead()
Return false to hide the player's head when this head armor is worn. Returns true by default....
virtual bool CloneNewInstances
Whether instances of this ModItem are created through Clone or constructor (by default implementation...
virtual void LoadLegacy(BinaryReader reader)
Allows you to load pre-v0.9 custom data that you have saved for this item.
virtual bool CanRightClick()
Returns whether or not this item does something when it is right-clicked in the inventory....
virtual void HoldItem(Player player)
Allows you to make things happen when the player is holding this item (for example,...
virtual bool DrawLegs()
Return false to hide the player's legs when this leg armor or shoe accessory is worn....
virtual void NetRecieve(BinaryReader reader)
Receives the custom data sent in the NetSend hook.
virtual bool NewPreReforge()
This hook gets called when the player clicks on the reforge button and can afford the reforge....
virtual void PostDrawTooltip(ReadOnlyCollection< DrawableTooltipLine > lines)
Allows you to do things after this item's tooltip is drawn. The lines contain draw information as thi...
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...
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,...
virtual ModItem NewInstance(Item itemClone)
Create a new instance of this ModItem for an Item instance. Called at the end of Item....
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 t...
virtual void NetSend(BinaryWriter writer)
Allows you to send custom data for this item between client and server.
virtual void OnHitPvp(Player player, Player target, int damage, bool crit)
Allows you to create special effects when this melee weapon hits a player.
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 ...
virtual void UpdateVanitySet(Player player)
Allows you to create special effects (such as dust) when the player wears this item's vanity set....
virtual bool UseItem(Player player)
Allows you to make things happen when this item is used. Return true if using this item actually does...
virtual bool AllowPrefix(int pre)
Force a re-roll of a prefix by returning false.
virtual void SetDefaults()
This is where you set all your item's properties, such as width, damage, shootSpeed,...
virtual bool OnlyShootOnSwing
Setting this to true makes it so that this weapon can shoot projectiles only at the beginning of its ...
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.
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....
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 call...
virtual void OnCraft(Recipe recipe)
Allows you to make anything happen when the player crafts this item using the given recipe.
virtual void RightClick(Player player)
Allows you to make things happen when this item is right-clicked in the inventory....
virtual int ChoosePrefix(UnifiedRandom rand)
Allows you to manually choose what prefix an item will get.
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,...
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 wor...
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 e...
virtual ModItem Clone(Item item)
Create a copy of this instanced ModItem. Called when an item is cloned. Defaults to NewInstance(item)
virtual bool CanEquipAccessory(Player player, int slot)
Allows you to disallow the player from equipping this accessory. Return false to disallow equipping t...
string Name
The internal name of this ModItem.
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....
virtual bool IsAnglerQuestAvailable()
Whether or not specific conditions have been satisfied for the Angler to be able to request this item...
virtual void UpdateEquip(Player player)
Allows you to give effects to this armor or accessory, such as increased damage.
virtual string Texture
The file name of this item's texture file in the mod loader's file space.
virtual bool CanBurnInLava()
Returns whether or not this item burns when it is thrown into lava despite item.rare not being 0....
virtual ? Color GetAlpha(Color lightColor)
Allows you to determine the color and transparency in which this item is drawn. Return null to use th...
virtual ModItem Clone()
Returns a clone of this ModItem. Allows you to decide which fields of your ModItem class are copied o...
virtual void SetStaticDefaults()
This is where you set all your item's static properties, such as names/translations and the arrays in...
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,...
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 curr...
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.
virtual float UseTimeMultiplier(Player player)
Allows you to change the effective useTime of this item.
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 ...
virtual TagCompound Save()
Allows you to save custom data for this item. Returns null by default.
virtual void Load(TagCompound tag)
Allows you to load custom data that you have saved for this item.
virtual void AutoStaticDefaults()
Automatically sets certain static defaults. Override this if you do not want the properties to be set...
virtual void OnConsumeItem(Player player)
Allows you to make things happen when this item is consumed. Called before the item stack is reduced.
virtual void ModifyTooltips(List< TooltipLine > tooltips)
Allows you to modify all the tooltips that display for this item. See here for information about Tool...
virtual ? Vector2 HoldoutOrigin()
Allows you to determine the point on this item's sprite that the player holds onto when using this it...
virtual void HoldStyle(Player player)
Allows you to modify the location and rotation of this item when the player is holding it.
virtual bool Autoload(ref string name)
Allows you to automatically load an item instead of using Mod.AddItem. Return true to allow autoloadi...
virtual void OnConsumeMana(Player player, int manaConsumed)
Allows you to make stuff happen when a player consumes mana on use of this item.
virtual bool ConsumeItem(Player player)
If this item is consumable and this returns true, then this item will be consumed upon usage....
virtual int BossBagNPC
The type of NPC that drops this boss bag. Used to determine how many coins this boss bag contains....
virtual void PostReforge()
This hook gets called immediately after an item gets reforged by the Goblin Tinkerer....
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 ...
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 Extr...
virtual void UseStyle(Player player)
Allows you to modify the location and rotation of this item in its use animation.
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 h...
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 ...
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 ...
virtual bool AltFunctionUse(Player player)
Allows you to make this item usable by right-clicking. Returns false by default. When this item is us...
virtual void GetWeaponCrit(Player player, ref int crit)
Allows you to temporarily modify this weapon's crit chance based on player buffs, etc....
virtual void UpdateArmorSet(Player player)
Allows you to give set bonuses to the armor set that this armor is in. Set player....
bool ProjOnSwing_Obsolete
virtual bool IgnoreDamageModifiers
Set this to true to prevent this weapon or ammo item from being adjusted by damage modifiers.
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,...
virtual void ArmorSetShadows(Player player)
Allows you to determine special visual effects this vanity set has on the player without having to co...
virtual void AddRecipes()
This is essentially the same as Mod.AddRecipes. Do note that this will be called for every instance o...
Item item
The item object that this ModItem controls.
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.
virtual void PickAmmo(Player player, ref int type, ref float speed, ref int damage, ref float knockback)
virtual bool ItemSpace(Player player)
Return true to specify that the item can be picked up despite not having enough room in inventory....
virtual bool HoldItemFrame(Player player)
Allows you to modify the player's animation when the player is holding this item. Return true if you ...
virtual void PreUpdateVanitySet(Player player)
Allows you to create special effects (such as the necro armor's hurt noise) when the player wears thi...
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 alter...
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 PreDr...
virtual void CaughtFishStack(ref int stack)
Allows you to determine how many of this item a player obtains when the player fishes this item.
ModTranslation DisplayName
The translations for the display name of this item.
virtual bool CanUseItem(Player player)
Returns whether or not this item can be used. By default returns true.
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 ...
virtual bool OnPickup(Player player)
Allows you to make special things happen when the player picks up this item. Return false to stop the...
virtual bool CanHitPvp(Player player, Player target)
Allows you to determine whether this melee weapon can hit the given opponent player when swung....
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,...
virtual void PreReforge()
void SetDefault(string value)
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...