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)
 
void DefaultToCapturedCritter (short npcIdToSpawnOnUse)
 
void DefaultToFood (int newwidth, int newheight, int foodbuff, int foodbuffduration, bool useGulpSound=false, int animationTime=17)
 
void DefaultToGolfClub (int newwidth, int newheight)
 
void DefaultToGuitar (int newwidth=24, int newheight=24)
 
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)
 
void DefaultToPlaceableTile (int tileIDToPlace, int tileStyleToPlace=0)
 
void DefaultToPlaceableTile (ushort tileIDToPlace, int tileStyleToPlace=0)
 
void DefaultToRangedWeapon (int baseProjType, int ammoID, int singleShotTime, float shotVelocity, bool hasAutoReuse=false)
 
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 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 IsNotTheSameAs (Item compareItem)
 
bool IsTheSameAs (Item compareItem)
 
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)
 
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 (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 (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 (Rectangle rectangle, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 
static int NewItem (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 (Vector2 pos, Vector2 randomBox, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
 
static int NewItem (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)
 

Public Attributes

bool accessory
 
int alpha
 
int ammo = AmmoID.None
 
bool autoReuse
 
int axe
 
sbyte backSlot = -1
 
int bait
 
sbyte balloonSlot = -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[244]
 
static int[] cachedItemSpawnsByType = ItemID.Sets.Factory.CreateIntSet(-1)
 
static bool[] claw = new bool[5088]
 
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[273]
 
static int[] legType = new int[231]
 
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[5088]
 
static int treasureGrabRange = 150
 
const int WALL_PLACEMENT_USETIME = 7
 

Properties

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<T>() for custom damage types. More...
 
bool FitsAccessoryVanitySlot [get]
 
RefReadOnlyArray< Instanced< GlobalItem > > Globals [get]
 
string HoverName [get]
 
bool IsACoin [get]
 
bool IsAir [get]
 
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

◆ 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 

◆ 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

◆ 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<T>() for custom damage types.