TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
Terraria.Item Class Reference
+ Inheritance diagram for Terraria.Item:
+ Collaboration diagram for Terraria.Item:

Classes

struct  DisableCloneMethod
 
struct  DisableNewItemMethod
 

Public Member Functions

 Item ()
 
 Item (int setDefaultsToType, int stack=1, int prefix=0)
 
override string ToString ()
 
bool CanHavePrefixes ()
 Determines if this T:Terraria.Item can receive prefixes.
 
bool Prefix (int prefixWeWant)
 Attempts to apply a prefix to this T:Terraria.Item.
 
bool CanRollPrefix (int prefix)
 Determines if this T:Terraria.Item can roll the given prefix.
 
bool CanApplyPrefix (int prefix)
 Determines if this T:Terraria.Item can receive the given prefix.
 
PrefixCategoryGetPrefixCategory ()
 Determines the T:Terraria.ModLoader.PrefixCategory of this T:Terraria.Item.
 
bool IsAPrefixableAccessory ()
 Determines if this T:Terraria.Item is an accessory that can receive prefixes.
 
string AffixName ()
 Gets the localized name of this T:Terraria.Item including its prefix.
 
void RebuildTooltip ()
 
Rectangle getRect ()
 Gets this T:Terraria.Item's hitbox in the world. Equivalent to P:Terraria.Entity.Hitbox.
 
void netDefaults (int type)
 
bool FitsAmmoSlot ()
 
bool CanFillEmptyAmmoSlot ()
 
void SetDefaults1 (int type)
 
void SetDefaults2 (int type)
 
void SetDefaults3 (int type)
 
void DefaultToQuestFish ()
 This method sets a variety of Item values common to quest fish items.
Specifically:
 
void SetDefaults4 (int type)
 
void DefaultToGolfBall (int projid)
 This method sets a variety of Item values common to golf ball items.
Specifically:
 
void SetDefaults5 (int type)
 
void DefaultToSolution (int projectileId)
 This method sets a variety of Item values common to Clentaminator ammo solution items.
Specifically:
 
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:
 
void DefaultTokite (int projId)
 
void ChangeItemType (int to)
 
void DefaultToVanitypet (int projId, int buffID)
 
void DefaultToSeaShell ()
 
void DefaultToCapturedCritter (int npcIdToSpawnOnUse)
 
void DefaultToStaff (int projType, float pushForwardSpeed, int singleShotTime, int manaPerShot)
 This method sets a variety of Item values common to staff magic weapons.
Specifically:
 
void DefaultToSpear (int projType, float pushForwardSpeed, int animationTime)
 This method sets a variety of Item values common to spear weapons.
Specifically:
 
void DefaultToMount (int mount)
 
void DefaultToPlaceableWall (int wallToPlace)
 This method sets a variety of Item values common to placeable walls.
Specifically:
 
void SetWeaponValues (int dmg, float knockback, int bonusCritChance=0)
 This method conviniently sets F:Terraria.Item.damage, F:Terraria.Item.knockBack, and F:Terraria.Item.crit.
 
void DefaultToBow (int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to bow weapons.
Specifically:
 
void DefaultToMagicWeapon (int projType, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to magic weapons.
Specifically:
 
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:
 
void DefaultToThrownWeapon (int baseProjType, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of Item values common to thrown weapons.
Specifically:
 
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:
 
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:
 
void MakeUsableWithChlorophyteExtractinator ()
 
void DefaultToGolfClub (int newwidth, int newheight)
 
void DefaultToLawnMower (int newwidth, int newheight)
 
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:
 
void DefaultToHealingPotion (int newwidth, int newheight, int healingAmount, int animationTime=17)
 
void SetShopValues (ItemRarityColor rarity, int coinValue)
 A helper method that sets item rarity (F:Terraria.Item.rare) and item value (F:Terraria.Item.value).
 
void DefaultToHeadgear (int newwidth, int newheight, int helmetArtID)
 Modders should not use this.
 
void DefaultToAccessory (int newwidth=24, int newheight=24)
 
void DefaultToGuitar (int newwidth=24, int newheight=24)
 
void DefaultToMusicBox (int tileIDToPlace, int style=0)
 This method sets a variety of Item values common to items that place music boxes.
Specifically:
 
void SetDefaults (int Type=0)
 
void CloneDefaults (int TypeToClone)
 
void SetDefaults (int Type, bool noMatCheck=false, ItemVariant variant=null)
 
void OnCreated (ItemCreationContext context)
 
void ResetStats (int Type)
 
Color GetAlpha (Color newColor)
 
Color GetColor (Color newColor)
 
bool CanShimmer ()
 
void FixAgainstExploit ()
 
void UpdateItem (int i)
 
void TryCombiningIntoNearbyItems (int i)
 
FlexibleTileWand GetFlexibleTileWand ()
 
bool CanCombineStackInWorld ()
 
void FindOwner (int whoAmI)
 
Item Clone ()
 
void SetNameOverride (string name)
 Overrides the value of P:Terraria.Item.Name.
 
void ClearNameOverride ()
 Clears the overridden value of P:Terraria.Item.Name.
 
void TurnToAir (bool fullReset=false)
 
void OnPurchase (Item item)
 
int GetStoreValue ()
 
void Serialize (BinaryWriter writer, ItemSerializationContext context)
 
void DeserializeFrom (BinaryReader reader, ItemSerializationContext context)
 
void ResetPrefix ()
 
void Refresh (bool onlyIfVariantChanged=true)
 
GetGlobalItem< T > ()
 Gets the instance of the specified GlobalItem type. This will throw exceptions on failure.
 
GetGlobalItem< T > (T baseInstance)
 Gets the local instance of the type of the specified GlobalItem instance. This will throw exceptions on failure.
 
bool TryGetGlobalItem< T > (out T result)
 Gets the instance of the specified GlobalItem type.
 
bool TryGetGlobalItem< T > (T baseInstance, out T result)
 Safely attempts to get the local instance of the type of the specified GlobalItem instance.
 
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).

Has no effect on server-side items or items in remote player's inventories

 
TagCompound SerializeData ()
 
bool CountsAsClass< T > ()
 
bool CountsAsClass (DamageClass damageClass)
 This is used to check if this item benefits from the specified T:Terraria.ModLoader.DamageClass.
 
bool IsNotSameTypePrefixAndStack (Item compareItem)
 returns false if and only if type, stack and prefix match

See also
M:Terraria.Item.IsNetStateDifferent(Terraria.Item)

 
bool IsNetStateDifferent (Item compareItem)
 Returns true if these items are different and there is a need to re-sync them.
 
void CopyNetStateTo (Item target)
 Use this instead of M:Terraria.Item.Clone for much faster state snapshotting and change sync detection.
Note!! M:Terraria.Item.SetDefaults(System.Int32) will NOT be called. The target item will remain as it was (most likely air), except for type, stack, prefix and netStateVersion.
 
float AngleTo (Vector2 Destination)
 
float AngleFrom (Vector2 Source)
 
float Distance (Vector2 Other)
 
float DistanceSQ (Vector2 Other)
 
Vector2 DirectionTo (Vector2 Destination)
 
Vector2 DirectionFrom (Vector2 Source)
 
bool WithinRange (Vector2 Target, float MaxRange)
 
IEntitySource GetSource_FromThis (string? context=null)
 
IEntitySource GetSource_FromAI (string? context=null)
 
IEntitySource GetSource_DropAsItem (string? context=null)
 
IEntitySource GetSource_Loot (string? context=null)
 
IEntitySource GetSource_GiftOrReward (string? context=null)
 
IEntitySource GetSource_OnHit (Entity victim, string? context=null)
 
IEntitySource GetSource_OnHurt (Entity? attacker, string? context=null)
 
IEntitySource GetSource_Death (string? context=null)
 
IEntitySource GetSource_Misc (string context)
 
IEntitySource GetSource_TileInteraction (int tileCoordsX, int tileCoordsY, string? context=null)
 
IEntitySource GetSource_ReleaseEntity (string? context=null)
 
IEntitySource GetSource_CatchEntity (Entity caughtEntity, string? context=null)
 

Static Public Member Functions

static void StartCachingType (int t)
 Begins caching items spawns for a given item type (F:Terraria.Item.type).
Cached item types will not be spawned into the world when created with Item.NewItem().
Cache sizes can be checked by indexing F:Terraria.Item.cachedItemSpawnsByType and dropped using M:Terraria.Item.DropCache(Terraria.DataStructures.IEntitySource,Microsoft.Xna.Framework.Vector2,Microsoft.Xna.Framework.Vector2,System.Int32,System.Boolean).
 
static void DropCache (IEntitySource reason, Vector2 pos, Vector2 spread, int t, bool stopCaching=true)
 Drops a cache previously created using M:Terraria.Item.StartCachingType(System.Int32).
If no cache of t exists, nothing happens.
 
static int[] GetVanillaPrefixes (PrefixCategory category)
 Gets the vanilla prefixes for the given T:Terraria.ModLoader.PrefixCategory.
 
static int BannerToItem (int banner)
 Converts a banner ID into the equivalent item type (F:Terraria.Item.type).
 
static int NPCtoBanner (int i)
 Converts an NPC type (F:Terraria.NPC.type) into the equivalent banner ID.
 
static int BannerToNPC (int i)
 Converts a banner ID into the equivalent NPC type (F:Terraria.NPC.type).
 
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 buyPrice (int platinum=0, int gold=0, int silver=0, int copper=0)
 Converts the provided buy price into copper coins.
If assigned to F:Terraria.Item.value, that item will be bought for the provided value.
 
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 M:Terraria.Item.buyPrice(System.Int32,System.Int32,System.Int32,System.Int32).
If assigned to F:Terraria.Item.value, that item will be sold for the provided value.
 
static void ShimmerEffect (Vector2 shimmerPositon)
 
static Rectangle GetDrawHitbox (int type, Player user)
 
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.
 
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.
 
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 M:Terraria.Player.QuickSpawnItem(Terraria.DataStructures.IEntitySource,System.Int32,System.Int32) 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 F:Terraria.Main.item array.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static ? IEntitySource GetSource_None ()
 
static ? IEntitySource InheritSource (Entity entity)
 
static IEntitySource GetSource_NaturalSpawn ()
 
static IEntitySource GetSource_TownSpawn ()
 

Public Attributes

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 M:Terraria.Item.DefaultToQuestFish.
If you'd just like to emulate the one-per-inventory behavior of quest fish, see F:Terraria.Item.uniqueStack.
Defaults to false.

 
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.
 
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 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 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.

 
int timeSinceItemSpawned
 A value that increases every tick an item is in the world.
Defaults to the value in F:Terraria.ID.ItemID.Sets.OverflowProtectionTimeOffset when an item is created, and increases by F:Terraria.ID.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 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.

 
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 F:Terraria.Player.setBonus isn't an empty string.
Defaults to false.

 
int tooltipContext = -1
 The context in which this item's tooltip is being drawn.
See T:Terraria.UI.ItemSlot.Context for more details.
Defaults to -1.

 
int dye
 The numerical ID of the armor shader in F:Terraria.Graphics.Shaders.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.

 
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.

 
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 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.
 
bool expertOnly
 If true, then the given item's effects only function in Expert Mode or higher (P:Terraria.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.

 
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 F:Terraria.ID.ItemRarityID.Expert.

 
bool masterOnly
 If true, then the given item's effects only function in Master Mode or higher (P:Terraria.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 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 F:Terraria.ID.ItemRarityID.Master.

 
bool isAShopItem
 If true, then the given item is being sold in a shop.
Shop items display their price. See F:Terraria.Item.value.

 
int hairDye = -1
 The numerical ID of the hair shader in F:Terraria.Graphics.Shaders.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.

 
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 M:Terraria.Main.ConvertPaintIdToTileShaderIndex(System.Int32,System.Boolean,System.Boolean).
For more details regarding paint, see P:Terraria.Tile.TileColor and P:Terraria.Tile.WallColor.
Defaults to 0.

 
byte paintCoating
 
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:

 
int ownIgnore = -1
 
int ownTime
 
int keepTime
 
int timeLeftInWhichTheItemCannotBeTakenByEnemies
 
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 T:Terraria.ID.ItemID entry or M:Terraria.ModLoader.ModContent.ItemType``1, for example F:Terraria.ID.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 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 holdStyle
 Assign to an T:Terraria.ID.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 M:Terraria.ModLoader.ModItem.HoldStyle(Terraria.Player,Microsoft.Xna.Framework.Rectangle) hook to implement a custom animation.
Defaults to F:Terraria.ID.ItemHoldStyleID.None.
 
int useStyle
 Assign to an T:Terraria.ID.ItemUseStyleID value to give this item a specific animation while in use. Leave as 0 and use M:Terraria.ModLoader.ModItem.UseStyle(Terraria.Player,Microsoft.Xna.Framework.Rectangle) hook to implement a custom animation.
Defaults to F:Terraria.ID.ItemUseStyleID.None.
 
bool channel
 Used for items that have special behavior when the attack button is held.
Defaults to false.
 
bool accessory
 Whether the item is an accessory.
Defaults to false.
 
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 F:Terraria.Item.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.
 
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 F:Terraria.Item.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.
 
int stack
 The current stack of the item. F:Terraria.Item.maxStack indicates the max possible stack.
 
int maxStack
 The maximum number of items that can be contained within a single stack. F:Terraria.Item.stack indicates the current stack size.
Defaults to 1.
 
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 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 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 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 createTile = -1
 The ID of the tile this item places on use. Either a T:Terraria.ID.TileID entry or M:Terraria.ModLoader.ModContent.TileType``1, for example F:Terraria.ID.TileID.WorkBenches or ModContent.ItemType<ExampleWorkbench>()
Defaults to -1.
 
int createWall = -1
 The ID of the wall this item places on use. Either a T:Terraria.ID.WallID entry or M:Terraria.ModLoader.ModContent.WallType``1, for example F:Terraria.ID.WallID.TopazGemspark or ModContent.ItemType<ExampleWall>()
Defaults to -1.
 
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 damage
 The base damage inflicted by this item. The List of weapons wiki pagecan be a useful guide for deciding on a value.
Use M:Terraria.ModLoader.ModItem.ModifyWeaponDamage(Terraria.Player,Terraria.ModLoader.StatModifier@) for dynamic damage values.
Defaults to -1.
 
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 M:Terraria.ModLoader.ModItem.ModifyWeaponKnockback(Terraria.Player,Terraria.ModLoader.StatModifier@) for dynamic knockback values.
Defaults to 0f.
 
int healLife
 The amount of health this item restores on use.
Use M:Terraria.ModLoader.ModItem.GetHealLife(Terraria.Player,System.Boolean,System.Int32@) for dynamic health restoring values.
Defaults to 0.
 
int healMana
 The amount of mana this item restores on use.
Use M:Terraria.ModLoader.ModItem.GetHealMana(Terraria.Player,System.Boolean,System.Int32@) for dynamic mana restoring values.
Defaults to 0.
 
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.
 
bool consumable
 Whether the item is consumed after use. If consumed, the item stack will decrease by 1. Modders can use the M:Terraria.ModLoader.ModItem.ConsumeItem(Terraria.Player) hook to dynamically decide if the item should be consumed. Modders can use M:Terraria.ModLoader.ModItem.OnConsumeItem(Terraria.Player) to act on an item being consumed.
Defaults to false.
 
bool autoReuse
 Whether the item is in continuous use while the mouse button is held down.
Defaults to false.
 
bool useTurn
 Whether the player can turn around while the using animation of this item is happening.
Defaults to false.
 
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 P:Microsoft.Xna.Framework.Color.Transparent
 
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 M:Terraria.ModLoader.ModItem.GetAlpha(Microsoft.Xna.Framework.Color) for more control over the resulting color.
Defaults to 0.
 
short glowMask
 The index in F:Terraria.GameContent.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.
 
float scale = 1f
 The size multiplier of the item's sprite while the item is being used. Also increases range for melee weapons.
Use M:Terraria.ModLoader.ModItem.ModifyItemScale(Terraria.Player,System.Single@) for dynamic scale values.
Defaults to 1f.
 
SoundStyleUseSound
 The sound this item makes when used. Set this to an existing T:Terraria.ID.SoundID entry or assign to a new T:Terraria.Audio.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 defense
 The amount of defense this item provides when equipped, either as an accessory or armor.
Defaults to 0.
 
int headSlot = -1
 
int bodySlot = -1
 
int legSlot = -1
 
int handOnSlot = -1
 
int handOffSlot = -1
 
int backSlot = -1
 
int frontSlot = -1
 
int shoeSlot = -1
 
int waistSlot = -1
 
int wingSlot = -1
 
int shieldSlot = -1
 
int neckSlot = -1
 
int faceSlot = -1
 
int balloonSlot = -1
 
int beardSlot = -1
 
int stringColor
 
ItemTooltip ToolTip
 
string BestiaryNotes
 
int playerIndexTheItemIsReservedFor = 255
 
int rare
 Indicates the rarity of an item. Assign to a T:Terraria.ID.ItemRarityID value. Vanilla values range from -1 to 13.
Items with F:Terraria.ID.ItemRarityID.White rarity will burn in lava unless F:Terraria.ID.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 F:Terraria.ID.ItemRarityID.White
 
int shoot
 The ID of the projectile that is fired by this item on use. Either a T:Terraria.ID.ProjectileID entry or M:Terraria.ModLoader.ModContent.ProjectileType``1, for example F:Terraria.ID.ProjectileID.FireArrow or ModContent.ProjectileType<MyModProjectile>()
If this weapon uses F:Terraria.Item.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.
 
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 ammo = AmmoID.None
 The Ammo ID this item belongs to. Weapons with F:Terraria.Item.useAmmo set to the same AmmoID will consume this item as ammo. See the Ammo Guidefor more information.
Defaults to F:Terraria.ID.AmmoID.None.
 
bool notAmmo
 If true and the item is ammo (sets F:Terraria.Item.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 Wire.
Defaults to false.
 
int useAmmo = AmmoID.None
 The Ammo ID this weapon will consume. Ammo items with F:Terraria.Item.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 F:Terraria.ID.AmmoID.None.
 
int lifeRegen
 The value to add to F:Terraria.Player.lifeRegen of the equipping player.
Defaults to 0.
 
int manaIncrease
 
bool buyOnce
 
int mana
 The amount of mana this item consumes on use.
Use M:Terraria.ModLoader.ModItem.ModifyManaCost(Terraria.Player,System.Single@,System.Single@) for dynamic mana costs.
Defaults to 0.
 
bool noUseGraphic
 If true, the item's sprite will not be visible while the item is in use.
Defaults to false.
 
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.
 
int timeSinceTheItemHasBeenReservedForSomeone
 
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 M:Terraria.Item.buyPrice(System.Int32,System.Int32,System.Int32,System.Int32) method for setting values: Item.value = Item.buyPrice(0, 1, 4, 62); You can also use the M:Terraria.Item.sellPrice(System.Int32,System.Int32,System.Int32,System.Int32) 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 buy
 
bool social
 
bool vanity
 If true, this item is a vanity item.
Vanity items can't receive prefixes and have a special vanity tooltip.
 
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.
 
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 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 M:Terraria.ModLoader.ModItem.UseItem(Terraria.Player), call M:Terraria.Player.AddBuff(System.Int32,System.Int32,System.Boolean,System.Boolean) for the remaining buffs you wish to give.
Make sure to set F:Terraria.Item.buffTime as well or the buff will instantly disappear.
Defaults to 0.
 
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 F:Terraria.Item.buffType as well.
Defaults to 0.
 
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.
 
bool cartTrack
 
bool uniqueStack
 Players cannot pick up a uniqueStack item if they have an item with the same F:Terraria.Item.type in their inventory.
This does not apply to equipped items, nor does it apply to items held with the mouse (F:Terraria.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 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 F:Terraria.ID.CustomCurrencyID.DefenderMedals.
See ExampleCustomCurrencyIdfor an example of creating and using a custom currency.
Must be used with F:Terraria.Item.shopCustomPrice assigning the price in terms of this custom currency.
Defaults to -1, which means an item is bought using coins.

 
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 F:Terraria.Item.shopSpecialCurrency to assign a price in terms of a custom currency instead of coins.
To get the raw price of an item, use M:Terraria.Item.GetStoreValue.
To get the price of an item after discounts, use M:Terraria.Player.GetItemExpectedPrice(Terraria.Item,System.Int64@,System.Int64@).
Defaults to null.

 
bool shootsEveryUse
 
bool chlorophyteExtractinatorConsumable
 
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 netID
 
int crit
 The base critical chance for this item. Remember that the player has a base crit chance of 4.
Use M:Terraria.ModLoader.ModItem.ModifyWeaponCrit(Terraria.Player,System.Single@) for dynamic crit values.
Defaults to 0.
 
int prefix
 The current prefix applied to this item. Either a T:Terraria.ID.PrefixID entry or M:Terraria.ModLoader.ModContent.PrefixType``1. Prefixes are assigned by calling the M:Terraria.Item.Prefix(System.Int32) method.
Defaults to 0.
 
bool sentry
 
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.
 
bool newAndShiny
 
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.
 
bool shimmered
 
float shimmerTime
 
int whoAmI
 The index of this Entity within its specific array. These arrays track the entities in the world.
Item: unused
Projectile: F:Terraria.Main.projectile
NPC: F:Terraria.Main.npc
Player: F:Terraria.Main.player
 
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.
 
Vector2 position
 The position of this Entity in world coordinates.
 
Vector2 velocity
 The velocity of this Entity in world coordinates per tick.
 
Vector2 oldPosition
 
Vector2 oldVelocity
 
int oldDirection
 
int direction = 1
 
int width
 The width of this Entity's hitbox, in pixels.
 
int height
 The height of this Entity's hitbox, in pixels.
 
bool wet
 The Entity is currently in water.
Projectile: Affects movement speed and some projectiles die when wet. F:Terraria.Projectile.ignoreWater prevents this.
 
bool shimmerWet
 
bool honeyWet
 
byte wetCount
 
bool lavaWet
 

Static Public Attributes

const int luckPotionDuration1 = 18000
 
const int luckPotionDuration2 = 36000
 
const int luckPotionDuration3 = 54000
 
const int flaskTime = 72000
 
const int copper = 1
 
const int silver = 100
 
const int gold = 10000
 
const int platinum = 1000000
 
const int goldCritterRarityColor = 3
 
static int CommonMaxStack = 9999
 The default stack size for stackable items: 9999.
 
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 M:Terraria.Item.StartCachingType(System.Int32) and M:Terraria.Item.DropCache(Terraria.DataStructures.IEntitySource,Microsoft.Xna.Framework.Vector2,Microsoft.Xna.Framework.Vector2,System.Int32,System.Boolean) for more info.
Indexed by F:Terraria.Item.type.Defaults to -1.

 
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 F:Terraria.Player.pStone or F:Terraria.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 F:Terraria.Player.pStone or F:Terraria.Player.restorationDelayTime.

 
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 F:Terraria.Player.pStone or F:Terraria.Player.mushroomDelayTime.

 
static int[] headType = new int[ArmorIDs.Head.Count]
 An array for converting an F:Terraria.Item.headSlot value into a F:Terraria.Item.type value.
Indexed by F:Terraria.Item.headSlot. Defaults to 0.

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

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

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

 
static bool[] claw = new bool[ItemID.Count]
 If true, categorizes the given item type as a claw.
Claws are held differently when their F:Terraria.Item.useStyle is F:Terraria.ID.ItemUseStyleID.Swing, but are otherwise no different than any other item.
Used exclusively by the Bladed Glove in vanilla.
Indexed by F:Terraria.Item.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 (F:Terraria.Player.goldRing).
Applies to F:Terraria.ID.ItemID.CopperCoin, F:Terraria.ID.ItemID.SilverCoin, F:Terraria.ID.ItemID.GoldCoin, and F:Terraria.ID.ItemID.PlatinumCoin.

 
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 (F:Terraria.Player.manaMagnet).
Applies to F:Terraria.ID.ItemID.Star, F:Terraria.ID.ItemID.SoulCake, and F:Terraria.ID.ItemID.SugarPlum.

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

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

 
const int WALL_PLACEMENT_USETIME = 7
 
static int numberOfNewItems = 0
 
static readonly Func< TagCompound, ItemDESERIALIZER = ItemIO.Load
 

Package Functions

IEntitySource GetNPCSource_FromThis ()
 
IEntitySource GetItemSource_Misc (int itemSourceId)
 
int[] GetRollablePrefixes ()
 
void DefaultToTorch (int tileStyleToPlace, bool allowWaterPlacement=false)
 
void DefaultToMusicBox (int style)
 
Item DeepClone ()
 
bool IsTheSameAs (Item compareItem)
 
bool IsNotTheSameAs (Item compareItem)
 

Package Attributes

GlobalItem[] _globals
 
long entityId
 

Properties

bool melee [get, set]
 
bool magic [get, set]
 
bool ranged [get, set]
 
bool summon [get, set]
 
string Name [get]
 The localized name of this item without stack size or prefixes.
Can be overridden using M:Terraria.Item.SetNameOverride(System.String).
 
string HoverName [get]
 The name of this item including stack size and prefix.
 
bool PaintOrCoating [get]
 true if F:Terraria.Item.paint > 0 || F:Terraria.Item.paintCoating > 0 and false otherwise.
 
bool FitsAccessoryVanitySlot [get]
 
int OriginalRarity [get]
 
int OriginalDamage [get]
 
int OriginalDefense [get]
 
ItemVariant Variant [get, private set]
 
bool IsACoin [get]
 
bool IsAir [get]
 
bool IsCurrency [get]
 
bool CanBeQuickUsed [get]
 
ModItem ModItem [get, set]
 
int IEntityWithGlobals< GlobalItem >. Type [get]
 
RefReadOnlyArray< GlobalItemEntityGlobals [get]
 
EntityGlobalsEnumerator< GlobalItemGlobals [get]
 
List< ModStatsModifiedBy = new List<Mod>() [get, private set]
 
int NetStateVersion [get, private set]
 An additional identifier.
 
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 F:Terraria.Item.noMelee set to false.
 
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.
 
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.
 
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:

 
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:

 
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:

 
bool InterruptChannelOnHurt [get, set]
 When enabled and the player is hurt, F:Terraria.Player.channel will be set to false.
 
bool StopAnimationOnHurt [get, set]
 When enabled and the player is hurt, F:Terraria.Player.channel will be set to false, and the item animation will stop immediately.
 
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 F:Terraria.Item.useTurn. Item.useTurn will prevent the player from changing their direction while the animation is playing if it is set to true.

 
DamageClass DamageType [get, set]
 The damage type of this Item. Assign to DamageClass.Melee/Ranged/Magic/Summon/Throwing for vanilla classes, or M:Terraria.ModLoader.ModContent.GetInstance``1 for custom damage types.
 
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.
 
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 M:Terraria.ModLoader.ModType.SetStaticDefaults.
 
virtual Vector2 VisualPosition [get]
 
Vector2 Center [get, set]
 
Vector2 Left [get, set]
 
Vector2 Right [get, set]
 
Vector2 Top [get, set]
 
Vector2 TopLeft [get, set]
 
Vector2 TopRight [get, set]
 
Vector2 Bottom [get, set]
 
Vector2 BottomLeft [get, set]
 
Vector2 BottomRight [get, set]
 
Vector2 Size [get, set]
 
Rectangle Hitbox [get, set]
 

Private Member Functions

bool TryGetPrefixStatMultipliersForItem (int rolledPrefix, out float dmg, out float kb, out float spd, out float size, out float shtspd, out float mcst, out int crt)
 
bool RollAPrefix (UnifiedRandom random, ref int rolledPrefix)
 
void SetFoodDefaults (int type)
 
void Shimmering ()
 
int FindDecraftAmount ()
 
int GetShimmerEquivalentType ()
 
void GetShimmered ()
 
void DespawnIfMeetingConditions (int i)
 
void CheckLavaDeath (int i)
 
void MoveInWorld (float gravity, float maxFallSpeed, ref Vector2 wetVelocity, int i)
 
void GetPickedUpByMonsters_Special (int i)
 
void GetPickedUpByMonsters_Money (int i)
 
void CombineWithNearbyItems (int myItemIndex)
 
void UpdateItem_VisualEffects ()
 
void ApplyItemAnimationCompensationsToVanillaItems ()
 
void UndoItemAnimationCompensations ()
 
void RestoreMeleeSpeedBehaviorOnVanillaItems ()
 

Static Private Member Functions

static int NewItem_Inner (IEntitySource source, int X, int Y, int Width, int Height, Item itemToClone, int Type, int Stack=1, bool noBroadcast=false, int pfix=0, bool noGrabDelay=false, bool reverseLookup=false)
 
static int PickAnItemSlotToSpawnItemOn (bool reverseLookup, int nextItem)
 

Private Attributes

string _nameOverride
 
readonly int shadowOrbPrice = sellPrice(0, 1, 50)
 
readonly int dungeonPrice = sellPrice(0, 1, 75)
 
readonly int queenBeePrice = sellPrice(0, 2)
 
readonly int hellPrice = sellPrice(0, 2, 50)
 
readonly int eclipsePrice = sellPrice(0, 7, 50)
 
readonly int eclipsePostPlanteraPrice = sellPrice(0, 10)
 
readonly int eclipseMothronPrice = sellPrice(0, 12, 50)
 
int currentUseAnimationCompensation
 
DamageClass _damageClass = DamageClass.Default
 
int _armorPenetration
 

Static Private Attributes

const int foodWidth = 22
 
const int foodHeight = 22
 
static string cloningDisabled = null
 
static bool newItemDisabled = false
 

Detailed Description

Definition at line 27 of file Item.cs.


The documentation for this class was generated from the following file: