tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.Item Class Reference

Inherits Terraria.Entity, Terraria.ModLoader.IO.TagSerializable, and Terraria.ModLoader.IEntityWithGlobals< GlobalItem >.

Public Member Functions

 Item (int setDefaultsToType, int stack=1, int prefix=0)
 
string AffixName ()
 
bool CanCombineStackInWorld ()
 
bool CanFillEmptyAmmoSlot ()
 
bool checkMat ()
 
void ClearNameOverride ()
 
Item Clone ()
 
void CloneDefaults (int TypeToClone)
 
Item CloneWithModdedDataFrom (Item dataSource)
 
bool CountsAsClass (DamageClass damageClass)
 
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 common Item values common to bow weapons.
Specifically: width = 14; height = 30; UseSound = SoundID.Item5;
Addtionally: More...
 
void DefaultToCapturedCritter (short npcIdToSpawnOnUse)
 
void DefaultToFood (int newwidth, int newheight, int foodbuff, int foodbuffduration, bool useGulpSound=false, int animationTime=17)
 This method sets a variety of common Item values common to food items.
Specifically: UseSound = useGulpSound ? Item3 : Item2; useStyle = useGulpSound ? DrinkLiquid : EatFood;
useTurn = true; useAnimation = useTime = animationTime; maxStack = 30; consumable = true;
buffType = foodbuff; buffTime = foodbuffduration; rare = Blue; value = 20 silver; More...
 
void DefaultToGolfBall (int projid)
 
void DefaultToGolfClub (int newwidth, int newheight)
 
void DefaultToGuitar (int newwidth=24, int newheight=24)
 
void DefaultToHeadgear (int newwidth, int newheight, int helmetArtID)
 
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)
 
void DefaultToMount (int mount)
 
void DefaultToMusicBox (int style)
 
void DefaultToPlacableWall (ushort wallToPlace)
 This method sets a variety of common Item values common to placeable walls.
Specifically: useStyle = 1; useTurn = true; useAnimation = 15; useTime = 7; autoReuse = true; maxStack = 999; consumable = true; createWall = wallToPlace; width = 12; height = 12;
More...
 
void DefaultToPlaceableTile (int tileIDToPlace, int tileStyleToPlace=0)
 
void DefaultToPlaceableTile (ushort tileIDToPlace, int tileStyleToPlace=0)
 
void DefaultToQuestFish ()
 
void DefaultToRangedWeapon (int baseProjType, int ammoID, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 This method sets a variety of common Item values common to ranged weapons.
Specifically: autoReuse = hasAutoReuse; useStyle = 5; useAnimation = singleShotTime; useTime = singleShotTime; shoot = baseProjType; useAmmo = ammoID; shootSpeed = shotVelocity; noMelee = true; ranged = true;
More...
 
void DefaultToSeaShelll ()
 
void DefaultToSpear (int projType, float pushForwardSpeed, int animationTime)
 
void DefaultToStaff (int projType, float pushForwardSpeed, int singleShotTime, int manaPerShot)
 
void DefaultToThrownWeapon (int baseProjType, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 
void DefaultToTorch (int tileStyleToPlace, bool allowWaterPlacement=false)
 
void DefaultToVanitypet (int projId, int buffID)
 
void DefaultToWhip (int projectileId, int dmg, float kb, float shootspeed, int animationTotalTime=30)
 
void DeserializeFrom (BinaryReader reader, ItemSerializationContext context)
 
void FindOwner (int whoAmI)
 
bool FitsAmmoSlot ()
 
Color GetAlpha (Color newColor)
 
Color GetColor (Color newColor)
 
GetGlobalItem< T > (bool exactType=true)
 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...
 
Rectangle getRect ()
 
int GetStoreValue ()
 
bool IsNotSameTypePrefixAndStack (Item compareItem)
 returns false if and only if netID (deprecated, equivalent to type), stack and prefix match More...
 
void netDefaults (int type)
 
void OnPurchase (Item item)
 
bool Prefix (int pre)
 
void RebuildTooltip ()
 
void Refresh ()
 
void ResetStats (int Type)
 
void Serialize (BinaryWriter writer, ItemSerializationContext context)
 
TagCompound SerializeData ()
 
void SetDefaults (int Type, bool noMatCheck=false)
 
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)
 
void SetShopValues (ItemRarityColor rarity, int coinValue)
 
void SetWeaponValues (int dmg, float knockback, int bonusCritChance=0)
 
override string ToString ()
 
void TryCombiningIntoNearbyItems (int i)
 
bool TryGetGlobalItem< T > (out T result, bool exactType=true)
 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 ()
 
void UpdateItem (int i)
 
- Public Member Functions inherited from Terraria.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_Accessory (Item item, string? context=null)
 
IEntitySource GetSource_CatchEntity (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_ItemUse (Item item, string? context=null)
 
IEntitySource GetSource_ItemUse_WithPotentialAmmo (Item item, int ammoItemId, 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_OpenItem (int itemType, 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)
 

Static Public Member Functions

static int BannerToItem (int banner)
 
static int BannerToNPC (int i)
 
static int buyPrice (int platinum=0, int gold=0, int silver=0, int copper=0)
 
static void DropCache (IEntitySource reason, Vector2 pos, Vector2 spread, int t, bool stopCaching=true)
 
static Rectangle GetDrawHitbox (int type, Player user)
 
static bool IsAGolfingItem (Item item)
 
static bool MechSpawn (float x, float y, int type)
 
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)
 
static int NewItem (IEntitySource source, Rectangle rectangle, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 
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)
 
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)
 
static int NewItem (IEntitySource source, Vector2 position, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 
static int NPCtoBanner (int i)
 
static int sellPrice (int platinum=0, int gold=0, int silver=0, int copper=0)
 
static void StartCachingType (int t)
 
- Static Public Member Functions inherited from Terraria.Entity
static IEntitySource GetSource_NaturalSpawn ()
 
static ? IEntitySource GetSource_None ()
 
static IEntitySource GetSource_TownSpawn ()
 
static ? IEntitySource InheritSource (Entity entity)
 

Public Attributes

bool accessory
 
int alpha
 
int ammo = AmmoID.None
 
bool autoReuse
 
int axe
 
sbyte backSlot = -1
 
int bait
 
sbyte balloonSlot = -1
 
sbyte beardSlot = -1
 
bool beingGrabbed
 
string BestiaryNotes
 
int bodySlot = -1
 
int buffTime
 
int buffType
 
bool buy
 
bool buyOnce
 
bool canBePlacedInVanityRegardlessOfConditions
 
bool cartTrack
 
bool channel
 
Color color
 
bool consumable
 
int createTile = -1
 
int createWall = -1
 
int crit
 
int damage
 
bool DD2Summon
 
int defense
 
int dye
 
bool expert
 
bool expertOnly
 
sbyte faceSlot = -1
 
bool favorited
 
int fishingPole = 1
 
bool flame
 
sbyte frontSlot = -1
 
short glowMask
 
int hairDye = -1
 
int hammer
 
sbyte handOffSlot = -1
 
sbyte handOnSlot = -1
 
int headSlot = -1
 
int healLife
 
int healMana
 
int holdStyle
 
bool instanced
 
bool isAShopItem
 
int keepTime
 
float knockBack
 
int legSlot = -1
 
int lifeRegen
 
short makeNPC
 
int mana
 
int manaIncrease
 
bool master
 
bool masterOnly
 
bool material
 
int maxStack
 
bool mech
 
int mountType = -1
 
sbyte neckSlot = -1
 
int netID
 
bool newAndShiny
 
int noGrabDelay
 
bool noMelee
 
bool notAmmo
 
bool noUseGraphic
 
bool noWet
 
int ownIgnore = -1
 
int ownTime
 
byte paint
 
int pick
 
int placeStyle
 
int playerIndexTheItemIsReservedFor = 255
 
bool potion
 
int prefix
 
bool questItem
 
int rare
 
int reuseDelay
 
float scale = 1f
 
bool sentry
 
sbyte shieldSlot = -1
 
sbyte shoeSlot = -1
 
int shoot
 
float shootSpeed
 
int? shopCustomPrice
 
int shopSpecialCurrency = -1
 
bool social
 
int stack
 
int stringColor
 
int tileBoost
 
int tileWand = -1
 
int timeLeftInWhichTheItemCannotBeTakenByEnemies
 
int timeSinceItemSpawned
 
int timeSinceTheItemHasBeenReservedForSomeone
 
ItemTooltip ToolTip
 
int tooltipContext = -1
 
int type
 
bool uniqueStack
 
int useAmmo = AmmoID.None
 
int useAnimation
 
LegacySoundStyle UseSound
 
int useStyle
 
int useTime
 
bool useTurn
 
int value
 
bool vanity
 
sbyte waistSlot = -1
 
sbyte wingSlot = -1
 
bool wornArmor
 
- Public Attributes inherited from Terraria.Entity
bool active
 
int direction = 1
 
int height
 
bool honeyWet
 
bool lavaWet
 
int oldDirection
 
Vector2 oldPosition
 
Vector2 oldVelocity
 
Vector2 position
 
Vector2 velocity
 
bool wet
 
byte wetCount
 
int whoAmI
 
int width
 

Static Public Attributes

static int[] bodyType = new int[246]
 
static int[] cachedItemSpawnsByType = ItemID.Sets.Factory.CreateIntSet(-1)
 
static bool[] claw = new bool[5125]
 
static int coinGrabRange = 350
 
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[277]
 
static int[] legType = new int[234]
 
static int lifeGrabRange = 250
 
const int luckPotionDuration1 = 10800
 
const int luckPotionDuration2 = 18000
 
const int luckPotionDuration3 = 36000
 
static int manaGrabRange = 300
 
static int mushroomDelay = 1800
 
static int numberOfNewItems = 0
 
const int platinum = 1000000
 
static int potionDelay = 3600
 
static int restorationDelay = 2700
 
const int silver = 100
 
static bool[] staff = new bool[5125]
 
static int treasureGrabRange = 150
 
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. More...
 
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. More...
 
bool? CanBeQuickUsed [get]
 
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. More...
 
bool FitsAccessoryVanitySlot [get]
 
RefReadOnlyArray< Instanced< GlobalItem > > Globals [get]
 
string HoverName [get]
 
bool IsACoin [get]
 
bool IsAir [get]
 
bool IsCandidateForReforge [get]
 Used to make stackable items reforgeable More...
 
bool IsCurrency [get]
 
ModItem ModItem [get, set]
 
string Name [get]
 
int OriginalDamage [get]
 
int OriginalDefense [get]
 
int OriginalRarity [get]
 
- Properties inherited from Terraria.Entity
Vector2 Bottom [get, set]
 
Vector2 BottomLeft [get, set]
 
Vector2 BottomRight [get, set]
 
Vector2 Center [get, set]
 
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 Terraria.ModLoader.IEntityWithGlobals< GlobalItem >
RefReadOnlyArray< Instanced< T > > Globals [get]
 

Member Function Documentation

◆ DefaultToBow()

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

This method sets a variety of common Item values common to bow weapons.
Specifically: width = 14; height = 30; UseSound = SoundID.Item5;
Addtionally:

Parameters
singleShotTime
shotVelocity
hasAutoReuse

◆ DefaultToFood()

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

This method sets a variety of common Item values common to food items.
Specifically: UseSound = useGulpSound ? Item3 : Item2; useStyle = useGulpSound ? DrinkLiquid : EatFood;
useTurn = true; useAnimation = useTime = animationTime; maxStack = 30; consumable = true;
buffType = foodbuff; buffTime = foodbuffduration; rare = Blue; value = 20 silver;

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

◆ DefaultToPlacableWall()

void Terraria.Item.DefaultToPlacableWall ( ushort  wallToPlace)

This method sets a variety of common Item values common to placeable walls.
Specifically: useStyle = 1; useTurn = true; useAnimation = 15; useTime = 7; autoReuse = true; maxStack = 999; consumable = true; createWall = wallToPlace; width = 12; height = 12;

Parameters
wallToPlace

◆ DefaultToRangedWeapon()

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

This method sets a variety of common Item values common to ranged weapons.
Specifically: autoReuse = hasAutoReuse; useStyle = 5; useAnimation = singleShotTime; useTime = singleShotTime; shoot = baseProjType; useAmmo = ammoID; shootSpeed = shotVelocity; noMelee = true; ranged = true;

Parameters
baseProjType
ammoID
singleShotTime
shotVelocity
hasAutoReuse

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

T Terraria.Item.GetGlobalItem< T > ( bool  exactType = true)

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

Exceptions
KeyNotFoundException
Exceptions
IndexOutOfRangeException
Type Constraints
T :GlobalItem 
T :GlobalType.GetGlobal 
T :Item 
T :GlobalItem 
T :T 
T :globalItems 
T :exactType 

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

T Terraria.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 :GlobalType.GetGlobal 
T :Item 
T :GlobalItem 
T :T 
T :globalItems 
T :baseInstance 

◆ IsNotSameTypePrefixAndStack()

bool Terraria.Item.IsNotSameTypePrefixAndStack ( Item  compareItem)

returns false if and only if netID (deprecated, equivalent to type), stack and prefix match

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

bool Terraria.Item.TryGetGlobalItem< T > ( out T  result,
bool  exactType = true 
)

Gets the instance of the specified GlobalItem type.

Type Constraints
T :GlobalItem 
T :GlobalType.TryGetGlobal 
T :GlobalItem 
T :T 
T :globalItems 
T :exactType 
T :out 
T :result 

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

bool Terraria.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 :GlobalType.TryGetGlobal 
T :GlobalItem 
T :T 
T :globalItems 
T :baseInstance 
T :out 
T :result 

Property Documentation

◆ AllowReforgeForStackableItem

bool Terraria.Item.AllowReforgeForStackableItem
getset

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.

◆ ArmorPenetration

int Terraria.Item.ArmorPenetration
getset

The number of defense points that this item can ignore on its own. Cannot be set to negative values. Defaults to 0.

◆ DamageType

DamageClass?? Terraria.Item.DamageType
getset

The damage type of this Item. Assign to DamageClass.Melee/Ranged/Magic/Summon/Throwing for vanilla classes, or ModContent.GetInstance for custom damage types.

◆ IsCandidateForReforge

bool Terraria.Item.IsCandidateForReforge
get

Used to make stackable items reforgeable