tModLoader v2024.04
A mod to make and play Terraria mods
Item Class Reference

Inherits Entity, TagSerializable, and IEntityWithGlobals< GlobalItem >.

Classes

struct  DisableCloneMethod
 
struct  DisableNewItemMethod
 

Public Member Functions

 Item (int setDefaultsToType, int stack=1, int prefix=0)
 
string AffixName ()
 Gets the localized name of this Item including its prefix. More...
 
bool CanApplyPrefix (int prefix)
 Determines if this Item can receive the given prefix. More...
 
bool CanCombineStackInWorld ()
 
bool CanFillEmptyAmmoSlot ()
 
bool CanHavePrefixes ()
 Determines if this Item can receive prefixes. More...
 
bool CanRollPrefix (int prefix)
 Determines if this Item can roll the given prefix. More...
 
bool CanShimmer ()
 
void ChangeItemType (int to)
 
void ClearNameOverride ()
 Clears the overridden value of Name.
 
Item Clone ()
 
void CloneDefaults (int TypeToClone)
 
void CopyNetStateTo (Item target)
 Use this instead of Clone for much faster state snapshotting and change sync detection.
Note!! SetDefaults(int) will NOT be called. The target item will remain as it was (most likely air), except for type, stack, prefix and netStateVersion
 
bool CountsAsClass (DamageClass damageClass)
 This is used to check if this item benefits from the specified DamageClass. More...
 
bool CountsAsClass< T > ()
 
void DefaultToAccessory (int newwidth=24, int newheight=24)
 
void DefaultToBow (int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to bow weapons.
Specifically: More...
 
void DefaultToCapturedCritter (int npcIdToSpawnOnUse)
 
void DefaultToFood (int newwidth, int newheight, int foodbuff, int foodbuffduration, bool useGulpSound=false, int animationTime=17)
 This method sets a variety of Item values common to food items.
Specifically: More...
 
void DefaultToGolfBall (int projid)
 This method sets a variety of Item values common to golf ball items.
Specifically: More...
 
void DefaultToGolfClub (int newwidth, int newheight)
 
void DefaultToGuitar (int newwidth=24, int newheight=24)
 
void DefaultToHeadgear (int newwidth, int newheight, int helmetArtID)
 Modders should not use this.
 
void DefaultToHealingPotion (int newwidth, int newheight, int healingAmount, int animationTime=17)
 
void DefaultTokite (int projId)
 
void DefaultToLawnMower (int newwidth, int newheight)
 
void DefaultToMagicWeapon (int projType, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to magic weapons.
Specifically: More...
 
void DefaultToMount (int mount)
 
void DefaultToMusicBox (int tileIDToPlace, int style=0)
 This method sets a variety of Item values common to items that place music boxes.
Specifically: More...
 
void DefaultToPlaceableTile (int tileIDToPlace, int tileStyleToPlace=0)
 
void DefaultToPlaceableTile (ushort tileIDToPlace, int tileStyleToPlace=0)
 This method sets a variety of Item values common to items that place tiles.
Specifically: More...
 
void DefaultToPlaceableWall (int wallToPlace)
 This method sets a variety of Item values common to placeable walls.
Specifically: More...
 
void DefaultToQuestFish ()
 This method sets a variety of Item values common to quest fish items.
Specifically: More...
 
void DefaultToRangedWeapon (int baseProjType, int ammoID, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to ranged weapons.
Specifically: More...
 
void DefaultToSeaShell ()
 
void DefaultToSolution (int projectileId)
 This method sets a variety of Item values common to Clentaminator ammo solution items.
Specifically: More...
 
void DefaultToSpear (int projType, float pushForwardSpeed, int animationTime)
 This method sets a variety of Item values common to spear weapons.
Specifically: More...
 
void DefaultToStaff (int projType, float pushForwardSpeed, int singleShotTime, int manaPerShot)
 This method sets a variety of Item values common to staff magic weapons.
Specifically: More...
 
void DefaultToThrownWeapon (int baseProjType, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to thrown weapons.
Specifically: More...
 
void DefaultToTorch (int tileIDToPlace, int tileStyleToPlace, bool allowWaterPlacement=false)
 This method sets a variety of Item values common to items that place music boxes.
Specifically: More...
 
void DefaultToVanitypet (int projId, int buffID)
 
void DefaultToWhip (int projectileId, int dmg, float kb, float shootspeed, int animationTotalTime=30)
 This method sets a variety of Item values common to whip weapons.
Specifically: More...
 
void DeserializeFrom (BinaryReader reader, ItemSerializationContext context)
 
void FindOwner (int whoAmI)
 
bool FitsAmmoSlot ()
 
void FixAgainstExploit ()
 
Color GetAlpha (Color newColor)
 
Color GetColor (Color newColor)
 
FlexibleTileWand GetFlexibleTileWand ()
 
GetGlobalItem< T > ()
 Gets the instance of the specified GlobalItem type. This will throw exceptions on failure. More...
 
GetGlobalItem< T > (T baseInstance)
 Gets the local instance of the type of the specified GlobalItem instance. This will throw exceptions on failure. More...
 
PrefixCategory? GetPrefixCategory ()
 Determines the PrefixCategory of this Item. More...
 
Rectangle getRect ()
 Gets this Item's hitbox in the world. Equivalent to Entity.Hitbox. More...
 
int GetStoreValue ()
 
bool IsAPrefixableAccessory ()
 Determines if this Item is an accessory that can receive prefixes. More...
 
bool IsNetStateDifferent (Item compareItem)
 Returns true if these items are different and there is a need to re-sync them
 
bool IsNotSameTypePrefixAndStack (Item compareItem)
 returns false if and only if type, stack and prefix match

See also
IsNetStateDifferent(Item)

 
void MakeUsableWithChlorophyteExtractinator ()
 
void netDefaults (int type)
 
void NetStateChanged ()
 Call this to trigger a re-sync of this item in a player's inventory or equipment in multiplayer.
The item will be sent to the server and other players at the end of the frame (not immediately).
br/> Has no effect on server-side items or items in remote player's inventories

 
void OnCreated (ItemCreationContext context)
 
void OnPurchase (Item item)
 
bool Prefix (int prefixWeWant)
 Attempts to apply a prefix to this Item. More...
 
void RebuildTooltip ()
 
void Refresh (bool onlyIfVariantChanged=true)
 
void ResetPrefix ()
 
void ResetStats (int Type)
 
void Serialize (BinaryWriter writer, ItemSerializationContext context)
 
TagCompound SerializeData ()
 
void SetDefaults (int Type, bool noMatCheck=false, ItemVariant variant=null)
 
void SetDefaults (int Type=0)
 
void SetDefaults1 (int type)
 
void SetDefaults2 (int type)
 
void SetDefaults3 (int type)
 
void SetDefaults4 (int type)
 
void SetDefaults5 (int type)
 
void SetNameOverride (string name)
 Overrides the value of Name. More...
 
void SetShopValues (ItemRarityColor rarity, int coinValue)
 A helper method that sets item rarity (Item.rare) and item value (Item.value). More...
 
void SetWeaponValues (int dmg, float knockback, int bonusCritChance=0)
 This method conveniently sets Item.damage, Item.knockBack, and Item.crit. More...
 
override string ToString ()
 
void TryCombiningIntoNearbyItems (int i)
 
bool TryGetGlobalItem< T > (out T result)
 Gets the instance of the specified GlobalItem type. More...
 
bool TryGetGlobalItem< T > (T baseInstance, out T result)
 Safely attempts to get the local instance of the type of the specified GlobalItem instance. More...
 
void TurnToAir (bool fullReset=false)
 
void UpdateItem (int i)
 
- Public Member Functions inherited from Entity
float AngleFrom (Vector2 Source)
 
float AngleTo (Vector2 Destination)
 
Vector2 DirectionFrom (Vector2 Source)
 
Vector2 DirectionTo (Vector2 Destination)
 
float Distance (Vector2 Other)
 
float DistanceSQ (Vector2 Other)
 
IEntitySource GetSource_CatchEntity (Entity caughtEntity, string? context=null)
 
IEntitySource GetSource_Death (string? context=null)
 
IEntitySource GetSource_DropAsItem (string? context=null)
 
IEntitySource GetSource_FromAI (string? context=null)
 
IEntitySource GetSource_FromThis (string? context=null)
 
IEntitySource GetSource_GiftOrReward (string? context=null)
 
IEntitySource GetSource_Loot (string? context=null)
 
IEntitySource GetSource_Misc (string context)
 
IEntitySource GetSource_OnHit (Entity victim, string? context=null)
 
IEntitySource GetSource_OnHurt (Entity? attacker, string? context=null)
 
IEntitySource GetSource_ReleaseEntity (string? context=null)
 
IEntitySource GetSource_TileInteraction (int tileCoordsX, int tileCoordsY, string? context=null)
 
bool WithinRange (Vector2 Target, float MaxRange)
 
TagCompound SerializeData ()
 

Static Public Member Functions

static int BannerToItem (int banner)
 Converts a banner ID into the equivalent item type (Item.type). More...
 
static int BannerToNPC (int i)
 Converts a banner ID into the equivalent NPC type (NPC.type). More...
 
static int buyPrice (int platinum=0, int gold=0, int silver=0, int copper=0)
 Converts the provided buy price into copper coins.
If assigned to Item.value, that item will be bought for the provided value. More...
 
static void DropCache (IEntitySource reason, Vector2 pos, Vector2 spread, int t, bool stopCaching=true)
 Drops a cache previously created using StartCachingType(int).
If no cache of t exists, nothing happens. More...
 
static Rectangle GetDrawHitbox (int type, Player user)
 
static int[] GetVanillaPrefixes (PrefixCategory category)
 Gets the vanilla prefixes for the given PrefixCategory. More...
 
static bool IsAGolfingItem (Item item)
 
static bool MechSpawn (float x, float y, int type)
 Use to check if a mechanism is allowed to spawn an Item of the provided type at the provided world coordinates. Checks nearby area to see if the Spawn Limitshave been reached.
 
static int NewItem (IEntitySource source, int X, int Y, int Width, int Height, int Type, int Stack=1, bool noBroadcast=false, int pfix=0, bool noGrabDelay=false, bool reverseLookup=false)
 Spawns an item into the game world with the given type and stack size. The X, Y, Width, and Height parameters dictate a rectangle, the item will be spawned centered within that rectangle. Other overloads support passing in a position directly, or just use 0 for Width and Height if the center is passed in a X and Y.
This method should not be called on multiplayer clients. If you need to spawn items from client code, use Player.QuickSpawnItem(IEntitySource, int, int) instead, it handles the multiplayer syncing code needed.
See the noBroadcast documentation if you need to customize attached ModItem or GlobalItem data prior to syncing.
The source represents the entity causing this item to spawn. The return value is the index of the spawned Item within the Main.item array. More...
 
static int NewItem (IEntitySource source, int X, int Y, int Width, int Height, Item item, bool noBroadcast=false, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses an Item instead of just the item type. All modded data will be preserved. More...
 
static int NewItem (IEntitySource source, Rectangle rectangle, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses a Rectangle instead of X, Y, Width, and Height to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Rectangle rectangle, Item item, bool noBroadcast=false, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Rectangle instead of X, Y, Width, and Height to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Vector2 pos, int Width, int Height, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Vector2 pos, int Width, int Height, Item item, bool noBroadcast=false, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Vector2 pos, Vector2 randomBox, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses two Vector2 to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Vector2 pos, Vector2 randomBox, Item item, bool noBroadcast=false, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Vector2 position, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses a Vector2 instead of X, Y, Width, and Height to determine the actual spawn position. More...
 
static int NewItem (IEntitySource source, Vector2 position, Item item, bool noBroadcast=false, bool noGrabDelay=false, bool reverseLookup=false)
 

This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Vector2 instead of X, Y, Width, and Height to determine the actual spawn position. More...
 
static int NPCtoBanner (int i)
 Converts an NPC type (NPC.type) into the equivalent banner ID. More...
 
static int sellPrice (int platinum=0, int gold=0, int silver=0, int copper=0)
 Converts the provided sell value into copper coins. This value is five times larger than buyPrice.
If assigned to Item.value, that item will be sold for the provided value. More...
 
static void ShimmerEffect (Vector2 shimmerPositon)
 
static void StartCachingType (int t)
 Begins caching items spawns for a given item type (Item.type).
Cached item types will not be spawned into the world when created with Item.NewItem().
Cache sizes can be checked by indexing cachedItemSpawnsByType and dropped using DropCache(IEntitySource, Vector2, Vector2, int, bool). More...
 
- Static Public Member Functions inherited from Entity
static IEntitySource GetSource_NaturalSpawn ()
 
static ? IEntitySource GetSource_None ()
 
static IEntitySource GetSource_TownSpawn ()
 
static ? IEntitySource InheritSource (Entity entity)
 

Public Attributes

bool accessory
 Whether the item is an accessory.
Defaults to false.
 
int alpha
 Set to a value from 0 to 255 to control how transparent the item will appear when drawn. Gel uses 175, gemstone items use 50. 0 is opaque, and 255 is transparent. Note that this is the opposite of how alpha is typically expressed in computer graphics. Use ModItem.GetAlpha(Color) for more control over the resulting color.
Defaults to 0.
 
int ammo = AmmoID.None
 The Ammo ID this item belongs to. Weapons with useAmmo set to the same AmmoID will consume this item as ammo. See the Ammo Guidefor more information.
Defaults to AmmoID.None.
 
bool autoReuse
 Whether the item is in continuous use while the mouse button is held down.
Defaults to false.
 
int axe
 The Axe power of this item. The Axe power percentage shown to the user is five times this value, so adjust accordingly. For example, Item.axe = 9; will appear as 45% Axe Power in the tooltip.
The Axes wiki pageis a good resource for finding a suitable value.
Defaults to 0.
 
int backSlot = -1
 
int bait
 The numerical value this item adds to a player's fishing skill when used as bait.
If greater than 0, categorizes this item as bait.
Bait can be put into ammo slots and is consumed when fishing.
The higher the value of bait, the lower the chance the bait is consumed.
Defaults to 0.

 
int balloonSlot = -1
 
int beardSlot = -1
 
bool beingGrabbed
 If true, then this item is currently being grabbed by a player.
Items being grabbed by the player cannot combine with nearby items, be picked up by enemies, burn in lava, or despawn.

 
string BestiaryNotes
 
int bodySlot = -1
 
int buffTime
 The duration in ticks of the buff given by this item on use. There are 60 ticks per second, multiply the number of seconds by 60. For example, a buff lasting 8 minutes would use a value of either 28800 or 8*60*60.
Make sure to set buffType as well.
Defaults to 0.
 
int buffType
 The Buff ID of the buff given by this item on use. To have a potion give multiple buffs, assign one buff here and in ModItem.UseItem(Player), call Player.AddBuff(int, int, bool, bool) for the remaining buffs you wish to give.
Make sure to set buffTime as well or the buff will instantly disappear.
Defaults to 0.
 
bool buy
 
bool buyOnce
 Indicates that an item in a shop can only be bought once, meaning it is an item that has been sold to the NPC shop by the player.
 
bool cartTrack
 
bool channel
 Used for items that have special behavior when the attack button is held.
Defaults to false.
 
bool chlorophyteExtractinatorConsumable
 
Color color
 Draws the item sprite with a colored tint. Gel and Sharkfin use this to spawn different colored items from the same ItemID. NetMessage.SendData(88, ...) needs to be used to sync this if not done in SetDefaults.
Defaults to Color.Transparent
 
bool consumable
 Whether the item is consumed after use. If consumed, the item stack will decrease by 1. Modders can use the ModItem.ConsumeItem(Player) hook to dynamically decide if the item should be consumed. Modders can use ModItem.OnConsumeItem(Player) to act on an item being consumed.
Defaults to false.
 
int createTile = -1
 The ID of the tile this item places on use. Either a TileID entry or ModContent.TileType<T>, for example TileID.WorkBenches or ModContent.ItemType<ExampleWorkbench>()
Defaults to -1.
 
int createWall = -1
 The ID of the wall this item places on use. Either a WallID entry or ModContent.WallType<T>, for example WallID.TopazGemspark or ModContent.ItemType<ExampleWall>()
Defaults to -1.
 
int crit
 The base critical chance for this item. Remember that the player has a base crit chance of 4.
Use ModItem.ModifyWeaponCrit(Player, ref float) for dynamic crit values.
Defaults to 0
 
int damage
 The base damage inflicted by this item. The List of weapons wiki pagecan be a useful guide for deciding on a value.
Use ModItem.ModifyWeaponDamage(Player, ref StatModifier) for dynamic damage values.
Defaults to -1.
 
bool DD2Summon
 If true, the given item is categorized as a Dungeon Defenders 2 summon item.
DD2 summon items get a counter for how much Etherian Mana is in the player's inventory.
This field being set does not make the item consume Etherian Mana. Etherian Mana consumption is handled manually per-type.
Defaults to false.

 
int defense
 The amount of defense this item provides when equipped, either as an accessory or armor.
Defaults to 0.
 
int dye
 The numerical ID of the armor shader in GameShaders.Armor this item activates when worn in a dye slot.
If greater than 0, then this item can be equipped into dye slots.
Defaults to 0.

 
bool expert
 If true, then the given item is automatically given the Expert rarity, causing its name to be drawn in rainbow text.
It also adds the "Expert" tooltip. To use the Expert rarity without adding this tooltip, see ItemRarityID.Expert.

 
bool expertOnly
 If true, then the given item's effects only function in Expert Mode or higher (Main.expertMode).
Specifically, any equipped, Expert-only accessory will not update, any Expert-only minecart will not be used when riding minecart tracks, and an 'X' will be drawn over the item when equipped.
Unused in vanilla.

 
int faceSlot = -1
 
bool favorited
 If true, then the given item is favorited.
Favorited items cannot be dropped, automatically moved into chests, placed in any kind of item rack, sold, trashed, or sorted.
Favorited items can still be dropped if the player has no inventory space and will still drop on death on Mediumcore or higher difficulties.
An item becomes unfavorited if removed from the player's inventory, including if the item is move to any equipment slot.
Defaults to false.

 
int fishingPole = 1
 The numerical value this item adds to a player's fishing skill when held.
If greater than 0, categorizes this item as a fishing pole.
Fishing poles can be placed into weapon racks, have a counter for the bait the player is carrying, and are held out when a bobber is active.
Defaults to 0.

 
bool flame
 If true, will cause the corresponding flame texture to be drawn while this item is held. Used for torches, candles, .
Modded items should make a texture file postfixed by "_Flame" to autoload the flame texture. For example, ExampleTorch in ExampleMod has both ExampleTorch.png and ExampleTorch_Flame.png.
Defaults to false.
 
int frontSlot = -1
 
short glowMask
 The index in TextureAssets.GlowMask of this item's glow mask, or -1 if this item doesn't have a glow mask.
Currently does not support modded content.
Defaults to -1.
 
int hairDye = -1
 The numerical ID of the hair shader in GameShaders.Hair this item will apply to the player when used.
If greater than -1, then this item is a hair dye.
Defaults to -1.

 
int hammer
 The Hammer power of this item. For example, Item.hammer = 70; will appear as 70% Hammer Power in the tooltip.
The Hammers wiki pageis a good resource for finding a suitable value.
Defaults to 0.
 
int handOffSlot = -1
 
int handOnSlot = -1
 
bool hasVanityEffects
 If true, this item has vanity effects even though it doesn't use equipment slots.
Unused in vanilla, as the system it was used for was removed in 1.4.4.
 
int headSlot = -1
 
int healLife
 The amount of health this item restores on use.
Use ModItem.GetHealLife(Player, bool, ref int) for dynamic health restoring values.
Defaults to 0.
 
int healMana
 The amount of mana this item restores on use.
Use ModItem.GetHealMana(Player, bool, ref int) for dynamic mana restoring values.
Defaults to 0.
 
int holdStyle
 Assign to an ItemHoldStyleID value to give this item a specific animation while the player is not using the item, but the item is currently selected. Leave as 0 and use ModLoader.ModItem.HoldStyle(Player, Rectangle) hook to implement a custom animation.
Defaults to ItemHoldStyleID.None.
 
bool instanced
 If true, then the given item is instanced per-client.
Instanced items only appear on the client they were spawned on and are less likely to be replaced if a new item is spawned.
Instanced items do not exist on servers.
Vanilla uses this field for treasure bags and Defender Medals. tModLoader automatically handles this for modded treasure bags.
If you would like to make an instanced item, see any one of the following for examples:
More...
 
bool isAShopItem
 If true, then the given item is being sold in a shop.
Shop items display their price. See value.

 
int keepTime
 
float knockBack
 The force of the knock back. Max value is 20. The Knockback wiki pagehas info on existing values. The List of weapons wiki pagecan also be a useful guide for deciding on a value.
Use ModItem.ModifyWeaponKnockback(Player, ref StatModifier) for dynamic knockback values.
Defaults to 0f.
 
int legSlot = -1
 
int lifeRegen
 The value to add to Player.lifeRegen of the equipping player.
Defaults to 0.
 
int makeNPC
 The numerical ID of the NPC that this item creates when used.
Mainly used for caught critters as items so that they can be released into the world.
 
int mana
 The amount of mana this item consumes on use.
Use ModItem.ModifyManaCost(Player, ref float, ref float) for dynamic mana costs.
Defaults to 0.
 
int manaIncrease
 
bool master
 If true, then the given item is automatically given the Master rarity, causing its name to be drawn in red-orange text.
It also adds the "Master" tooltip. To use the Master rarity without adding this tooltip, see ItemRarityID.Master.

 
bool masterOnly
 If true, then the given item's effects only function in Master Mode or higher (Main.masterMode).
Specifically, any equipped, Master-only accessory will not update, any Master-only minecart will not be used when riding minecart tracks, and an 'X' will be drawn over the item when equipped.
Unused in vanilla.

 
bool material
 Indicates that an item should show the material tooltip. Typically this means that the item is used in at least 1 recipe. Automatically assigned.
 
int maxStack
 The maximum number of items that can be contained within a single stack. stack indicates the current stack size.
Defaults to 1.
 
bool mech
 If true, then the given item will show all placed wires and actuators when held.
This item will also be grouped with other items with mech set to true when the inventory is sorted.
Defaults to false.

 
int mountType = -1
 Specifies which mount to equip when the item is used. Assign to ModContent.MountType<ModdedMountHere>(). See ExampleMountItem.csfor an example.
Defaults to -1.
 
int neckSlot = -1
 
int netID
 
bool newAndShiny
 
int noGrabDelay
 The delay, in ticks, before players can pick up this item.
Usually set to 100 (approximately 1.666... seconds) whenever an item is dropped.
Set to 0 whenever an item drops from a projectile.

 
bool noMelee
 If true, the item's using animation will not deal damage. Set to true on most weapons that aren't swords.
Defaults to false.
 
bool notAmmo
 If true and the item is ammo (sets ammo to something), the item will not count as ammo for certain ammo-specific behavior, such as the tooltip mentioning the item is ammo, or ammo items going into ammo slots first when picked up. Used for the Coin items, Ale, and Sand Blocks.
Defaults to false.
 
bool noUseGraphic
 If true, the item's sprite will not be visible while the item is in use.
Defaults to false.
 
bool noWet
 If true, the item won't be drawn while the holding player is wet. The player will also not be in the animation frame corresponding to the item's holdStyle
Defaults to false.
 
int ownIgnore = -1
 
int ownTime
 
byte paint
 The numerical ID of the paint applied by this item when used with a paint brush or paint roller.
For conversion into a shader index, see Main.ConvertPaintIdToTileShaderIndex.
For more details regarding paint, see Tile.TileColor and Tile.WallColor.
Defaults to 0.

 
byte paintCoating
 
int pick
 The Pickaxe power of this item. For example, Item.pick = 50; will appear as 50% Pickaxe Power in the tooltip.
The Pickaxes wiki pageis a good resource for finding a suitable value.
Defaults to 0.
 
int placeStyle
 The style of the tile being placed. Used for tiles that have a different look depending on the item used to place them.
The Basic Tile guideexplains more about this concept.
Defaults to 0.
 
int playerIndexTheItemIsReservedFor = 255
 
bool potion
 If true, this item will inflict potion sickness on use. Also determines whether the item cannot be used when the player has potion sickness, and if the item can be used with the Quick Heal key.
Defaults to false.
 
int prefix
 The current prefix applied to this item. Either a PrefixID entry or ModContent.PrefixType<T>. Prefixes are assigned by calling the Item.Prefix(int) method.
Defaults to 0.
 
bool questItem
 If true, categorizes the given item as a quest fish.
Quest fish get a special tooltip, their own category in the Research Menu, and cannot be auto-moved to the Void Vault when picked up.
If you'd like to make a quest fish, see DefaultToQuestFish.
If you'd just like to emulate the one-per-inventory behavior of quest fish, see uniqueStack.
Defaults to false.

 
int rare
 Indicates the rarity of an item. Assign to a ItemRarityID value. Vanilla values range from -1 to 13.
Items with ItemRarityID.White rarity will burn in lava unless ItemID.Sets.IsLavaImmuneRegardlessOfRarity is used.
Modded rarities can be assigned by: Item.rare = ModContent.RarityType<ExampleModRarity>();
The Rarity wiki pagehas guidelines for deciding on a suitable rarity.
Defaults to ItemRarityID.White
 
int reuseDelay
 A delay in frames added at the end of the using animation for the item, during which the player wont be able to use any items.
Defaults to 0.
 
float scale = 1f
 The size multiplier of the item's sprite while the item is being used. Also increases range for melee weapons.
Use ModItem.ModifyItemScale(Player, ref float) for dynamic scale values.
Defaults to 1f.
 
bool sentry
 
int shieldSlot = -1
 
bool shimmered
 
float shimmerTime
 
int shoeSlot = -1
 
int shoot
 The ID of the projectile that is fired by this item on use. Either a ProjectileID entry or ModContent.ProjectileType<T>, for example ProjectileID.FireArrow or ModContent.ProjectileType<MyModProjectile>()
If this weapon uses useAmmo, then this value is ignored as the projectile will be decided by the ammo item, but shoot should still be 10 by convention.
Defaults to 0.
 
bool shootsEveryUse
 
float shootSpeed
 The velocity in pixels the projectile fired by this item will have. Actual velocity depends on the projectile being fired. If your weapon is shooting projectiles and they are stationary, change this to something like 10f. Throwing Knife uses 10f. Held projectiles like Vortex Beater use shootSpeed to determine how far away from the player to hold the projectile.
Defaults to 0f.
 
int? shopCustomPrice
 If not null, the custom value of the given item when being bought from a shop.
Used for assigning a non-default price to an item in shops.
Can be used with shopSpecialCurrency to assign a price in terms of a custom currency instead of coins.
To get the raw price of an item, use GetStoreValue.
To get the price of an item after discounts, use Player.GetItemExpectedPrice. Be careful of setting a custom price far below the normal Item.value, it could result in an infinite money exploit. Defaults to null.
 
int shopSpecialCurrency = -1
 The numerical ID of the special currency this item is bought using.
To make an item bought using Defender Medals, set this to CustomCurrencyID.DefenderMedals.
See ExampleCustomCurrencyIdfor an example of creating and using a custom currency.
Must be used with shopCustomPrice assigning the price in terms of this custom currency.
Defaults to -1, which means an item is bought using coins.

 
bool social
 
int stack
 The current stack of the item. maxStack indicates the max possible stack.
 
int stringColor
 
int tileBoost
 Additional tile range provided by this tool or tile. Copper Pickaxe has a value of -1, reducing the range. Chain uses 3 to allow the tile to be placed from farther away than normal tiles.
Defaults to 0.
 
int tileWand = -1
 The numerical ID of the item this item consumes when used.
If greater than 0, this item cannot be used unless the player has the item type tileWand is set to. The item also gains a counter for said item type.
Defaults to -1.

 
int timeLeftInWhichTheItemCannotBeTakenByEnemies
 
int timeSinceItemSpawned
 A value that increases every tick an item is in the world.
Defaults to the value in ItemID.Sets.OverflowProtectionTimeOffset when an item is created, and increases by ItemID.Sets.ItemSpawnDecaySpeed every tick.
When creating new items, items with a high timeSinceItemSpawned value will be replaced if no empty item slots are available.

 
int timeSinceTheItemHasBeenReservedForSomeone
 
ItemTooltip ToolTip
 
int tooltipContext = -1
 The context in which this item's tooltip is being drawn.
See ItemSlot.Context for more details.
Defaults to -1.

 
int type
 The Item ID of this item. The Item ID is a unique number assigned to each Item loaded into the game. This will be equal to either an ItemID entry or ModContent.ItemType<T>, for example ItemID.IronskinPotion or ModContent.ItemType<MyModItem>(). To check if an Item instance is a specific Item, check Item.type == ItemID.VanillaItemHere or Item.type == ModContent.ItemType<ModdedItemHere>() in an if statement.
 
bool uniqueStack
 Players cannot pick up a uniqueStack item if they have an item with the same type in their inventory.
This does not apply to equipped items, nor does it apply to items held with the mouse (Main.mouseItem).
This field only prevents picking items up: Multiple uniqueStack items may still be transferred into the player's inventory from chests.
Defaults to false.

 
int useAmmo = AmmoID.None
 The Ammo ID this weapon will consume. Ammo items with ammo set to this same AmmoID will be consumed as ammo for this weapon to be used. See the Ammo Guidefor more information.
Defaults to AmmoID.None.
 
int useAnimation
 The time span of the using animation for the item in ticks. This is independent of the time it takes for the item to actually be used and potentially autoReused again. For weapons it is recommended to be the same as useTime as this is only the animation.
Blocks use 15. Default value is 100. Terraria runs at 60 frames per second, so 15 is 1/4th of a second.
 
SoundStyleUseSound
 The sound this item makes when used. Set this to an existing SoundID entry or assign to a new SoundStyle for a custom sound.
The Basic Sounds Guideteaches how to find existing sounds to use, how to use custom sounds, and how to customize the playback properties of the sounds.
For example Item.UseSound = SoundID.Item1; can be used for the sword swing sound.
Defaults to null.
 
int useStyle
 Assign to an ItemUseStyleID value to give this item a specific animation while in use. Leave as 0 and use ModLoader.ModItem.UseStyle hook to implement a custom animation.
Defaults to ItemUseStyleID.None.
 
int useTime
 The time span of using the item in ticks. This is independent of the time it takes for the item animation to finish.
Blocks use 10. Default value is 100.
Weapons usually have equal useAnimation and useTime, unequal values for these two results in multiple attacks per click. See ExampleGun.cs's Clockwork Assault Rifle examplefor an example of that.
 
bool useTurn
 Whether the player can turn around while the using animation of this item is happening.
Defaults to false.
 
int value
 The number of copper coins this item is worth (aka, cost to buy from a merchant). Setting it to 10462 would mean the item cost 1 gold, 4 silver, and 62 copper. The sell price of an item is one fifth of its value. Value also influences reforge costs with the goblin tinkerer.
For convenience, you can also use the Item.buyPrice(int, int, int, int) method for setting values: Item.value = Item.buyPrice(0, 1, 4, 62); You can also use the Item.sellPrice(int, int, int, int) method if you would rather think about an item's value the other way. Both Item.buyPrice(0, 0, 10, 55) and Item.sellPrice(0, 0, 2, 11) would set the value to 1055.
 
bool vanity
 If true, this item is a vanity item.
Vanity items can't receive prefixes and have a special vanity tooltip.
 
int waistSlot = -1
 
int wingSlot = -1
 
bool wornArmor
 If true, then this item is in the local player's armor slots.
This causes the item to gain the set bonus tooltip if Player.setBonus isn't an empty string.
Defaults to false.

 
- Public Attributes inherited from Entity
bool active
 If true, the Entity actually exists within the game world. Within the specific entity array, if active is false, the entity is junk data. Always check active if iterating over the entity array.
 
int direction = 1
 The direction this entity is facing. A value of 1 means the entity is facing to the right. -1 means facing to the left.
 
int height
 The height of this Entity's hitbox, in pixels.
 
bool honeyWet
 
bool lavaWet
 
int oldDirection
 
Vector2 oldPosition
 
Vector2 oldVelocity
 
Vector2 position
 The position of this Entity in world coordinates. Note that this corresponds to the top left corner of the entity. Use Center instead for logic that needs the position at the center of the entity.
 
bool shimmerWet
 
Vector2 velocity
 The velocity of this Entity in world coordinates per tick.
 
bool wet
 The Entity is currently in water.
Projectile: Affects movement speed and some projectiles die when wet. Projectile.ignoreWater prevents this.
 
byte wetCount
 
int whoAmI
 The index of this Entity within its specific array. These arrays track the entities in the world.
Item: unused
Projectile: Main.projectile
NPC: Main.npc
Player: Main.player Note that Projectile.whoAmI is not consistent between clients in multiplayer for the same projectile.
 
int width
 The width of this Entity's hitbox, in pixels.
 

Static Public Attributes

static int[] bodyType = new int[ArmorIDs.Body.Count]
 An array for converting an bodySlot value into a type value.
Indexed by bodySlot. Defaults to 0.

 
static int[] cachedItemSpawnsByType = ItemID.Sets.Factory.CreateIntSet(-1)
 The number of cached item spawns by type.
A value of -1 means that an item type is not being cached.
See StartCachingType and DropCache for more info.
Indexed by type.Defaults to -1.

 
static bool[] claw = new bool[ItemID.Count]
 If true, categorizes the given item type as a claw.
Claws are held differently when their useStyle is ItemUseStyleID.Swing, but are otherwise no different than any other item.
Used exclusively by the Bladed Glove in vanilla.
Indexed by type. Defaults to false.

 
static int coinGrabRange = 350
 The additional distance, in pixels, that coins may be grabbed from if the player has the Gold Ring or its upgrades (Player.goldRing).
Applies to ItemID.CopperCoin, ItemID.SilverCoin, ItemID.GoldCoin, and ItemID.PlatinumCoin.

 
static int CommonMaxStack = 9999
 The default stack size for stackable items: 9999
 
const int copper = 1
 
static readonly Func< TagCompound, ItemDESERIALIZER = ItemIO.Load
 
const int flaskTime = 72000
 
const int gold = 10000
 
const int goldCritterRarityColor = 3
 
static int[] headType = new int[ArmorIDs.Head.Count]
 An array for converting an headSlot value into a type value.
Indexed by headSlot. Defaults to 0.

 
static int[] legType = new int[ArmorIDs.Legs.Count]
 An array for converting an legSlot value into a type value.
Indexed by legSlot. Defaults to 0.

 
static int lifeGrabRange = 250
 The additional distance, in pixels, that mana stars may be grabbed from if the player has consumed a Heartreach Potion (Player.lifeMagnet).
Applies to ItemID.Heart, ItemID.CandyApple, and ItemID.CandyCane.

 
const int luckPotionDuration1 = 18000
 
const int luckPotionDuration2 = 36000
 
const int luckPotionDuration3 = 54000
 
static int manaGrabRange = 300
 The additional distance, in pixels, that mana stars may be grabbed from if the player has the Celestial Magnet or its upgrades (Player.manaMagnet).
Applies to ItemID.Star, ItemID.SoulCake, and ItemID.SugarPlum.

 
static int mushroomDelay = 1800
 The default cooldown, in ticks, of Mushrooms.
This value is never changed. For creating a Philosopher's Stone-like item, see Player.pStone or Player.mushroomDelayTime.

 
static int numberOfNewItems = 0
 
const int platinum = 1000000
 
static int potionDelay = 3600
 The default cooldown, in ticks, of most healing items.
This value is never changed. For creating a Philosopher's Stone-like item, see Player.pStone or Player.potionDelayTime.

 
static int restorationDelay = 2700
 The default cooldown, in ticks, of Restoration Potions.
This value is never changed. For creating a Philosopher's Stone-like item, see Player.pStone or Player.restorationDelayTime.

 
const int silver = 100
 
static bool[] staff = new bool[ItemID.Count]
 If true, categorizes the given item type as a staff.
Staffs are held differently when their useStyle is ItemUseStyleID.Shoot, but are otherwise no different than any other item.
Indexed by type. Defaults to false.

 
static int treasureGrabRange = 150
 The additional distance, in pixels, that items may be grabbed from if the player has equipped a Treasure Magnet (Player.treasureMagnet).

 
const int WALL_PLACEMENT_USETIME = 7
 

Properties

bool AllowReforgeForStackableItem [get, set]
 Set to true in SetDefaults to allow this item to receive a prefix on reforge even if maxStack is not 1.
This prevents it from receiving a prefix on craft.
 
int ArmorPenetration [get, set]
 The number of defense points that this item can ignore on its own. Cannot be set to negative values. Defaults to 0.
 
bool attackSpeedOnlyAffectsWeaponAnimation [get, set]
 Dictates whether or not attack speed modifiers on this weapon will actually affect its use time.
Defaults to false, which allows attack speed modifiers to affect use time. Set this to true to prevent this from happening.
Used in vanilla by all melee weapons which shoot a projectile and have noMelee set to false.Tools should typically set this to true to prevent the tool from mining quicker when the player has attack speed modifiers. By convention tool speed should not be affected by attack speed. They will still attack quicker, but their use time (mine/hammer/axe speed) should not be affected.
 
bool CanBeQuickUsed [get]
 
bool ChangePlayerDirectionOnShoot = true [get, set]
 When true, shooting any projectile from this item will make the owner face the projectile. Defaults to true.
The only 2 vanilla items that change this from true to false are the Grand Design and Beam Sword
This is different to Item.useTurn. Item.useTurn will prevent the player from changing their direction while the animation is playing if it is set to true.

 
bool consumeAmmoOnFirstShotOnly [get, set]
 Dictates whether or not this item should only consume ammo on its first shot of each use.
Defaults to false.
Used in vanilla by the following:
More...
 
bool consumeAmmoOnLastShotOnly [get, set]
 Dictates whether or not this item should only consume ammo on its last shot of each use.
Defaults to false.
Used in vanilla by the following:
More...
 
DamageClass DamageType [get, set]
 The damage type of this Item. Assign to DamageClass.Melee/Ranged/Magic/Summon/Throwing for vanilla classes, or ModContent.GetInstance for custom damage types.
 
RefReadOnlyArray< GlobalItemEntityGlobals [get]
 
bool FitsAccessoryVanitySlot [get]
 
EntityGlobalsEnumerator< GlobalItemGlobals [get]
 
string HoverName [get]
 The name of this item including stack size and prefix.
 
bool InterruptChannelOnHurt [get, set]
 When enabled and the player is hurt, Player.channel will be set to false
 
bool IsACoin [get]
 
bool IsAir [get]
 
bool IsCurrency [get]
 
ModItem ModItem [get, set]
 
string Name [get]
 The localized name of this item without stack size or prefixes.
Can be overridden using SetNameOverride(string).
 
int NetStateVersion [get]
 An additional identifier
 
int OriginalDamage [get]
 
int OriginalDefense [get]
 
int OriginalRarity [get]
 
bool PaintOrCoating [get]
 true if paint > 0 || paintCoating > 0 and false otherwise.
 
int ResearchUnlockCount [get, set]
 A utility property for easily getting or setting the amount of items required for this item's current type to be researched.
By default, all modded items will have this set to 1. Set to 0 for un-researchable items, such as items that disappear on pickup. The Journey Mode Research wiki pagelists values for various types of items, use it as a guide for consistency.
NOTE: The accessed values are stored per item type, not per item instance. You're recommended to only use the setter in load-time hooks, like ModType.SetStaticDefaults.
 
List< ModStatsModifiedBy = new() [get]
 
bool StopAnimationOnHurt [get, set]
 When enabled and the player is hurt, Player.channel will be set to false, and the item animation will stop immediately
 
int? useLimitPerAnimation [get, set]
 Dictates the amount of times a weapon can be used (shot, etc) each time it animates (is swung, clicked, etc).
Defaults to null.
Used in vanilla by the following:
More...
 
bool useTurnOnAnimationStart [get, set]
 Similar to useTurn, but only allows turning when an animation starts (eg between swings). Many early-game vanilla swords use this as it makes them clunky and hard to kite with.
Defaults to false.
 
ItemVariant Variant [get]
 
- Properties inherited from Entity
Vector2 Bottom [get, set]
 
Vector2 BottomLeft [get, set]
 
Vector2 BottomRight [get, set]
 
Vector2 Center [get, set]
 The center position of this entity in world coordinates. Calculated from position, width, and height.
 
Rectangle Hitbox [get, set]
 
Vector2 Left [get, set]
 
Vector2 Right [get, set]
 
Vector2 Size [get, set]
 
Vector2 Top [get, set]
 
Vector2 TopLeft [get, set]
 
Vector2 TopRight [get, set]
 
virtual Vector2 VisualPosition [get]
 
- Properties inherited from IEntityWithGlobals< GlobalItem >
RefReadOnlyArray< TGlobal > EntityGlobals [get]
 
int Type [get]
 

Member Function Documentation

◆ AffixName()

string Item.AffixName ( )

Gets the localized name of this Item including its prefix.

Returns
The localized name of this Item including its prefix, or simply Name if the prefix doesn't exist or is an empty string.

◆ BannerToItem()

static int Item.BannerToItem ( int  banner)
static

Converts a banner ID into the equivalent item type (Item.type).

Parameters
bannerThe banner ID to convert.
Returns
The item type associated with the given banner ID.
This method will return the wrong item type if banner is not a valid banner ID.

You can get the banner ID of an NPC using NPCtoBanner(int).

◆ BannerToNPC()

static int Item.BannerToNPC ( int  i)
static

Converts a banner ID into the equivalent NPC type (NPC.type).

Parameters
iThe banner ID to convert.
Returns
The NPC type associated with the given banner ID, or NPCID.None for an invalid banner ID.

◆ buyPrice()

static int Item.buyPrice ( int  platinum = 0,
int  gold = 0,
int  silver = 0,
int  copper = 0 
)
static

Converts the provided buy price into copper coins.
If assigned to Item.value, that item will be bought for the provided value.

Returns
The converted value.

◆ CanApplyPrefix()

bool Item.CanApplyPrefix ( int  prefix)

Determines if this Item can receive the given prefix.

Parameters
prefixThe PrefixID to check.
Returns
true if this Item can roll the given prefix (CanRollPrefix(int)) and if the applied prefix does not fail to modify any stat values.

◆ CanHavePrefixes()

bool Item.CanHavePrefixes ( )

Determines if this Item can receive prefixes.

Returns
true if this Item is allowed to receive prefixes, false otherwise.

◆ CanRollPrefix()

bool Item.CanRollPrefix ( int  prefix)

Determines if this Item can roll the given prefix.

Parameters
prefixThe PrefixID to check.
Returns
true if this Item can receive prefixes (CanHavePrefixes) and if PrefixLoader.CanRoll(Item, int) returns true, false otherwise.

Just because a prefix can be rolled does not mean it can be applied – use CanApplyPrefix(int) to check for that.

◆ CountsAsClass()

bool Item.CountsAsClass ( DamageClass  damageClass)

This is used to check if this item benefits from the specified DamageClass.

Parameters
damageClassThe DamageClass to check for in this item.
Returns
true if this item's DamageClass matches damageClass , false otherwise

◆ CountsAsClass< T >()

bool Item.CountsAsClass< T > ( )

Type Constraints
T :DamageClass 
T :CountsAsClass 
T :ModContent.GetInstance<T>() 

◆ DefaultToBow()

void Item.DefaultToBow ( int  singleShotTime,
float  shotVelocity,
bool  hasAutoReuse = false 
)

This method sets a variety of Item values common to bow weapons.
Specifically:

width = 14;
height = 30;
UseSound = SoundID.Item5;

Additionally:

Parameters
singleShotTime
shotVelocity
hasAutoReuse

◆ DefaultToFood()

void Item.DefaultToFood ( int  newwidth,
int  newheight,
int  foodbuff,
int  foodbuffduration,
bool  useGulpSound = false,
int  animationTime = 17 
)

This method sets a variety of Item values common to food items.
Specifically:

UseSound = useGulpSound ? Item3 : Item2; useStyle = useGulpSound ? ItemUseStyleID.DrinkLiquid : ItemUseStyleID.EatFood; useTurn = true; useAnimation = useTime = animationTime; maxStack = CommonMaxStack; consumable = true; buffType = foodbuff ; buffTime = foodbuffduration ; rare = ItemRarityID.Blue; value = 20 silver;

Parameters
newwidth
newheight
foodbuff
foodbuffduration
useGulpSoundIf true, the gulp sound is set, otherwise the crunch sound is set
animationTime

◆ DefaultToGolfBall()

void Item.DefaultToGolfBall ( int  projid)

This method sets a variety of Item values common to golf ball items.
Specifically:

shoot = projid ; useStyle = ItemUseStyleID.Swing; shootSpeed = 12f; width = 18; height = 20; maxStack = 1; UseSound = SoundID.Item1; useAnimation = 15; useTime = 15; noUseGraphic = true; noMelee = true; accessory = true; SetShopValues(ItemRarityColor.Green2, buyPrice(0, 1)); hasVanityEffects = true;

Parameters
projid

◆ DefaultToMagicWeapon()

void Item.DefaultToMagicWeapon ( int  projType,
int  singleShotTime,
float  shotVelocity,
bool  hasAutoReuse = false 
)

This method sets a variety of Item values common to magic weapons.
Specifically:

autoReuse = hasAutoReuse; useStyle = ItemUseStyleID.Shoot; useAnimation = singleShotTime; useTime = singleShotTime; shoot = projType; shootSpeed = shotVelocity; noMelee = true; DamageType = DamageClass.Magic;

Parameters
projType
singleShotTime
shotVelocity
hasAutoReuse

◆ DefaultToMusicBox()

void Item.DefaultToMusicBox ( int  tileIDToPlace,
int  style = 0 
)

This method sets a variety of Item values common to items that place music boxes.
Specifically:

useStyle = ItemUseStyleID.Swing; useTurn = true; useAnimation = 15; useTime = 10; autoReuse = true; consumable = true; createTile = tileIDToPlace; placeStyle = style; width = 24; height = 24; rare = ItemRarityID.LightRed; value = 100000; accessory = true; hasVanityEffects = true;

Parameters
tileIDToPlace
style

◆ DefaultToPlaceableTile()

void Item.DefaultToPlaceableTile ( ushort  tileIDToPlace,
int  tileStyleToPlace = 0 
)

This method sets a variety of Item values common to items that place tiles.
Specifically:

createTile = tileIDToPlace; placeStyle = tileStyleToPlace; width = 14; height = 14; useStyle = ItemUseStyleID.Swing; useAnimation = 15; useTime = 10; maxStack = CommonMaxStack; useTurn = true; autoReuse = true; consumable = true;

Parameters
tileIDToPlace
tileStyleToPlace

◆ DefaultToPlaceableWall()

void Item.DefaultToPlaceableWall ( int  wallToPlace)

This method sets a variety of Item values common to placeable walls.
Specifically:

useStyle = ItemUseStyleID.Swing; useTurn = true; useAnimation = 15; useTime = 7; autoReuse = true; maxStack = CommonMaxStack; consumable = true; createWall = wallToPlace; width = 12; height = 12;

Parameters
wallToPlace

◆ DefaultToQuestFish()

void Item.DefaultToQuestFish ( )

This method sets a variety of Item values common to quest fish items.
Specifically:

questItem = true; maxStack = 1; width = 26; height = 26; uniqueStack = true; rare = ItemRarityID.Quest;

◆ DefaultToRangedWeapon()

void Item.DefaultToRangedWeapon ( int  baseProjType,
int  ammoID,
int  singleShotTime,
float  shotVelocity,
bool  hasAutoReuse = false 
)

This method sets a variety of Item values common to ranged weapons.
Specifically:

autoReuse = hasAutoReuse; useStyle = ItemUseStyleID.Shoot; useAnimation = singleShotTime; useTime = singleShotTime; shoot = baseProjType; useAmmo = ammoID; shootSpeed = shotVelocity; noMelee = true; DamageType = DamageClass.Ranged;

Parameters
baseProjType
ammoIDThe Ammo ID this weapon will consume. See the Ammo Guidefor more information
singleShotTime
shotVelocity
hasAutoReuse

◆ DefaultToSolution()

void Item.DefaultToSolution ( int  projectileId)

This method sets a variety of Item values common to Clentaminator ammo solution items.
Specifically:

shoot = projectileId - 145; ammo = AmmoID.Solution; width = 10; height = 12; value = buyPrice(0, 0, 15); rare = 3; maxStack = CommonMaxStack; consumable = true;

Parameters
projectileId

◆ DefaultToSpear()

void Item.DefaultToSpear ( int  projType,
float  pushForwardSpeed,
int  animationTime 
)

This method sets a variety of Item values common to spear weapons.
Specifically:

useStyle = ItemUseStyleID.Shoot; useAnimation = animationTime; useTime = animationTime; shootSpeed = pushForwardSpeed; width = 32; height = 32; UseSound = SoundID.Item1; shoot = projType; noMelee = true; noUseGraphic = true; DamageType = DamageClass.Melee;

Parameters
projType
pushForwardSpeed
animationTime

◆ DefaultToStaff()

void Item.DefaultToStaff ( int  projType,
float  pushForwardSpeed,
int  singleShotTime,
int  manaPerShot 
)

This method sets a variety of Item values common to staff magic weapons.
Specifically:

DefaultToMagicWeapon(projType, singleShotTime, pushForwardSpeed, hasAutoReuse: true); mana = manaPerShot; width = 40; height = 40; UseSound = SoundID.Item43; Additionally:

Parameters
projType
pushForwardSpeedPassed into DefaultToMagicWeapon as the shotVelocity parameter
singleShotTime
manaPerShot

◆ DefaultToThrownWeapon()

void Item.DefaultToThrownWeapon ( int  baseProjType,
int  singleShotTime,
float  shotVelocity,
bool  hasAutoReuse = false 
)

This method sets a variety of Item values common to thrown weapons.
Specifically:

autoReuse = hasAutoReuse; useStyle = ItemUseStyleID.Swing; useAnimation = singleShotTime; useTime = singleShotTime; shoot = baseProjType; shootSpeed = shotVelocity; noMelee = true; DamageType = DamageClass.Ranged; consumable = true; maxStack = CommonMaxStack;

Parameters
baseProjType
singleShotTime
shotVelocity
hasAutoReuse

◆ DefaultToTorch()

void Item.DefaultToTorch ( int  tileIDToPlace,
int  tileStyleToPlace,
bool  allowWaterPlacement = false 
)

This method sets a variety of Item values common to items that place music boxes.
Specifically:

flame = true; noWet = !allowWaterPlacement; holdStyle = ItemHoldStyleID.HoldFront; autoReuse = true; maxStack = CommonMaxStack; consumable = true; createTile = tileIDToPlace; placeStyle = tileStyleToPlace; width = 10; height = 12; value = 60; useStyle = ItemUseStyleID.Swing; useTurn = true; useAnimation = 15; useTime = 10;

Parameters
tileIDToPlace
tileStyleToPlace
allowWaterPlacement

◆ DefaultToWhip()

void Item.DefaultToWhip ( int  projectileId,
int  dmg,
float  kb,
float  shootspeed,
int  animationTotalTime = 30 
)

This method sets a variety of Item values common to whip weapons.
Specifically:

autoReuse = false; useStyle = ItemUseStyleID.Swing; useAnimation = animationTotalTime; useTime = animationTotalTime; width = 18; height = 18; shoot = projectileId; UseSound = SoundID.Item152; noMelee = true; DamageType = DamageClass.SummonMeleeSpeed; noUseGraphic = true; damage = dmg; knockBack = kb; shootSpeed = shootspeed ;

Parameters
projectileId
dmg
kb
shootspeed
animationTotalTime

◆ DropCache()

static void Item.DropCache ( IEntitySource  reason,
Vector2  pos,
Vector2  spread,
int  t,
bool  stopCaching = true 
)
static

Drops a cache previously created using StartCachingType(int).
If no cache of t exists, nothing happens.

Parameters
reasonThe source of the dropped cache.
posThe position to drop the cache in world coordinates.
spreadThe random spread of the dropped items in world coordinates.
tThe item type (Item.type) to drop.
stopCachingIf true, then t will no longer be cached, allowing future drops to spawn as normal.

◆ GetGlobalItem< T >() [1/2]

T Item.GetGlobalItem< T > ( )

Gets the instance of the specified GlobalItem type. This will throw exceptions on failure.

Exceptions
KeyNotFoundException
Exceptions
IndexOutOfRangeException
Type Constraints
T :GlobalItem 
T :GlobalItem.GetGlobal<T> 
T :type 
T :EntityGlobals 

◆ GetGlobalItem< T >() [2/2]

T Item.GetGlobalItem< T > ( baseInstance)

Gets the local instance of the type of the specified GlobalItem instance. This will throw exceptions on failure.

Exceptions
KeyNotFoundException
Exceptions
NullReferenceException
Type Constraints
T :GlobalItem 
T :GlobalItem.GetGlobal<T> 
T :type 
T :EntityGlobals 
T :baseInstance 

◆ GetPrefixCategory()

PrefixCategory? Item.GetPrefixCategory ( )

Determines the PrefixCategory of this Item.

Returns
The PrefixCategory of this Item or null if this Item doesn't have a category.

◆ getRect()

Rectangle Item.getRect ( )

Gets this Item's hitbox in the world. Equivalent to Entity.Hitbox.

Returns
This Item's hitbox in the world.

◆ GetVanillaPrefixes()

static int[] Item.GetVanillaPrefixes ( PrefixCategory  category)
static

Gets the vanilla prefixes for the given PrefixCategory.

Parameters
categoryThe PrefixCategory to check.
Returns
An array of vanilla PrefixIDs for the given category, or an empty array for PrefixCategory.Custom.

◆ IsAPrefixableAccessory()

bool Item.IsAPrefixableAccessory ( )

Determines if this Item is an accessory that can receive prefixes.

Returns
true if this Item is an accessory, is not a vanity item, and is not blacklisted from receiving prefixes (ItemID.Sets.CanGetPrefixes).

◆ NewItem() [1/10]

static int Item.NewItem ( IEntitySource  source,
int  X,
int  Y,
int  Width,
int  Height,
int  Type,
int  Stack = 1,
bool  noBroadcast = false,
int  pfix = 0,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static

Spawns an item into the game world with the given type and stack size. The X, Y, Width, and Height parameters dictate a rectangle, the item will be spawned centered within that rectangle. Other overloads support passing in a position directly, or just use 0 for Width and Height if the center is passed in a X and Y.
This method should not be called on multiplayer clients. If you need to spawn items from client code, use Player.QuickSpawnItem(IEntitySource, int, int) instead, it handles the multiplayer syncing code needed.
See the noBroadcast documentation if you need to customize attached ModItem or GlobalItem data prior to syncing.
The source represents the entity causing this item to spawn. The return value is the index of the spawned Item within the Main.item array.

Parameters
source
X
Y
Width
Height
TypeEither an ItemID entry or ModContent.ItemType<T>, for example ItemID.IronskinPotion or ModContent.ItemType<MyModItem>()
StackItem stack
noBroadcastControls whether an item spawned on a server is synced using NetMessage.SendData and MessageID.SyncItem. If false, the item will be synced. If true, the calling code can modify the item instance and then sync the item with MessageID.SyncItem. Has no effect except on server. NewItem running on multiplayer clients always needs to manually sync, see Player.QuickSpawnItem(IEntitySource, int, int) source code for an example.
pfix
noGrabDelay
reverseLookup
Returns
The index of the item within Main.item

◆ NewItem() [2/10]

static int Item.NewItem ( IEntitySource  source,
int  X,
int  Y,
int  Width,
int  Height,
Item  item,
bool  noBroadcast = false,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses an Item instead of just the item type. All modded data will be preserved.

Returns

◆ NewItem() [3/10]

static int Item.NewItem ( IEntitySource  source,
Rectangle  rectangle,
int  Type,
int  Stack = 1,
bool  noBroadcast = false,
int  prefixGiven = 0,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses a Rectangle instead of X, Y, Width, and Height to determine the actual spawn position.

Returns

◆ NewItem() [4/10]

static int Item.NewItem ( IEntitySource  source,
Rectangle  rectangle,
Item  item,
bool  noBroadcast = false,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Rectangle instead of X, Y, Width, and Height to determine the actual spawn position.

Returns

◆ NewItem() [5/10]

static int Item.NewItem ( IEntitySource  source,
Vector2  pos,
int  Width,
int  Height,
int  Type,
int  Stack = 1,
bool  noBroadcast = false,
int  prefixGiven = 0,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position.

Returns

◆ NewItem() [6/10]

static int Item.NewItem ( IEntitySource  source,
Vector2  pos,
int  Width,
int  Height,
Item  item,
bool  noBroadcast = false,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position.

Returns

◆ NewItem() [7/10]

static int Item.NewItem ( IEntitySource  source,
Vector2  pos,
Vector2  randomBox,
int  Type,
int  Stack = 1,
bool  noBroadcast = false,
int  prefixGiven = 0,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses two Vector2 to determine the actual spawn position.

Returns

◆ NewItem() [8/10]

static int Item.NewItem ( IEntitySource  source,
Vector2  pos,
Vector2  randomBox,
Item  item,
bool  noBroadcast = false,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position.

Returns

◆ NewItem() [9/10]

static int Item.NewItem ( IEntitySource  source,
Vector2  position,
int  Type,
int  Stack = 1,
bool  noBroadcast = false,
int  prefixGiven = 0,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses a Vector2 instead of X, Y, Width, and Height to determine the actual spawn position.

Returns

◆ NewItem() [10/10]

static int Item.NewItem ( IEntitySource  source,
Vector2  position,
Item  item,
bool  noBroadcast = false,
bool  noGrabDelay = false,
bool  reverseLookup = false 
)
static



This particular overload uses an Item instead of just the item type. All modded data will be preserved.

This particular overload uses a Vector2 instead of X, Y, Width, and Height to determine the actual spawn position.

Returns

◆ NPCtoBanner()

static int Item.NPCtoBanner ( int  i)
static

Converts an NPC type (NPC.type) into the equivalent banner ID.

Parameters
iThe NPC type to convert.
Returns
The banner ID associated with the given NPC type, or 0 if the NPC type has no associated banner.

◆ Prefix()

bool Item.Prefix ( int  prefixWeWant)

Attempts to apply a prefix to this Item.

Parameters
prefixWeWant
If prefixWeWant == 0, do nothing.
If prefixWeWant == -1, then a random prefix is rolled, with a 25% chance to not roll a prefix and an additional 66% chance to void any prefixes in the PrefixID.Sets.ReducedNaturalChance set. This is used for chest loot, starting equipment, etc.
If prefixWeWant == -2, then a random prefix is rolled, with no chance to not roll a prefix. This is used for the Goblin Tinkerer.
If prefixWeWant == -3, then this method simple checks if this item can receive prefixes.
Otherwise, attempt to apply the given PrefixID to this item.
Returns
false if: Otherwise, return true.

◆ sellPrice()

static int Item.sellPrice ( int  platinum = 0,
int  gold = 0,
int  silver = 0,
int  copper = 0 
)
static

Converts the provided sell value into copper coins. This value is five times larger than buyPrice.
If assigned to Item.value, that item will be sold for the provided value.

Returns
The converted value.

◆ SerializeData()

TagCompound Item.SerializeData ( )

Implements TagSerializable.

◆ SetNameOverride()

void Item.SetNameOverride ( string  name)

Overrides the value of Name.

Parameters
nameThe new name of this Item.

◆ SetShopValues()

void Item.SetShopValues ( ItemRarityColor  rarity,
int  coinValue 
)

A helper method that sets item rarity (Item.rare) and item value (Item.value).

Parameters
rarity
coinValue

◆ SetWeaponValues()

void Item.SetWeaponValues ( int  dmg,
float  knockback,
int  bonusCritChance = 0 
)

This method conveniently sets Item.damage, Item.knockBack, and Item.crit.

Parameters
dmg
knockback
bonusCritChance

◆ StartCachingType()

static void Item.StartCachingType ( int  t)
static

Begins caching items spawns for a given item type (Item.type).
Cached item types will not be spawned into the world when created with Item.NewItem().
Cache sizes can be checked by indexing cachedItemSpawnsByType and dropped using DropCache(IEntitySource, Vector2, Vector2, int, bool).

Parameters
tThe item type to start caching.

◆ TryGetGlobalItem< T >() [1/2]

bool Item.TryGetGlobalItem< T > ( out T  result)

Gets the instance of the specified GlobalItem type.

Type Constraints
T :GlobalItem 
T :GlobalItem.TryGetGlobal 
T :type 
T :EntityGlobals 
T :out 
T :result 

◆ TryGetGlobalItem< T >() [2/2]

bool Item.TryGetGlobalItem< T > ( baseInstance,
out T  result 
)

Safely attempts to get the local instance of the type of the specified GlobalItem instance.

Returns
Whether or not the requested instance has been found.
Type Constraints
T :GlobalItem 
T :GlobalItem.TryGetGlobal 
T :type 
T :EntityGlobals 
T :baseInstance 
T :out 
T :result 

Member Data Documentation

◆ instanced

bool Item.instanced

If true, then the given item is instanced per-client.
Instanced items only appear on the client they were spawned on and are less likely to be replaced if a new item is spawned.
Instanced items do not exist on servers.
Vanilla uses this field for treasure bags and Defender Medals. tModLoader automatically handles this for modded treasure bags.
If you would like to make an instanced item, see any one of the following for examples:

  • NPC.DropItemInstanced
  • GameContent.ItemDropRules.CommonCode.DropItemLocalPerClientAndSetNPCMoneyTo0
  • MessageID.InstancedItem
    Defaults to false.

Property Documentation

◆ consumeAmmoOnFirstShotOnly

bool Item.consumeAmmoOnFirstShotOnly
getset

Dictates whether or not this item should only consume ammo on its first shot of each use.
Defaults to false.
Used in vanilla by the following:

  • Flamethrower
  • Elf Melter

◆ consumeAmmoOnLastShotOnly

bool Item.consumeAmmoOnLastShotOnly
getset

Dictates whether or not this item should only consume ammo on its last shot of each use.
Defaults to false.
Used in vanilla by the following:

  • ClockworkAssaultRifle
  • Clentaminator
  • FairyQueenRangedItem

◆ useLimitPerAnimation

int? Item.useLimitPerAnimation
getset

Dictates the amount of times a weapon can be used (shot, etc) each time it animates (is swung, clicked, etc).
Defaults to null.
Used in vanilla by the following:

  • BookStaff
  • FairyQueenMagicItem
  • FairyQueenRangedItem