The information in this article is for Terraria v1.0.6.1.

The chest class is responsible for handling all the chests in the game. Their contents are stored in an Item[] array, and there are a number of functions to deal with them. Interestingly, vendor inventories are considered chests, so this class also handles transactions as well.

A variety of different default chests

Read More


Name Type Description
item Item[]

An array of Item instances that fuctions as the contents of the chest.

  • Array size is equal to maxItems
x int The x-coordinate of the chest in the world.
y int The y-coordinate of the chest in the world.

Static PropertiesEdit

Name Type Description
maxItems int

The maximum number of items all chests may hold. As this affects every chest in a profound way, changing it may produce unexpected behavior!

  • Default value is 20


Method Name Description
public void AddShop(Item newItem)

Adds newItem to the chest's item array. This is typically invoked when you sell an item to a store.

  • Returns no value
public object Clone()

Returns a copy of the instance. This allows you to make changes to the object's data without affecting the original.

  • Returns a copy of the instance
public void SetupShop(int type)

Pre-populates the chest with buyable items. The items that appear depend on the type provided.

  • Returns no value

  • 0: Nothing / default
  • 1: Merchant
  • 2: Arms Dealer
  • 3: Dryad
  • 4: Demolitionist
  • 5: Old Man

Static MethodsEdit

Method Name Description
public static int CreateChest(int X, int Y)

Creates a chest at the given location, and returns the chest's index value in the Main.chest[] array.

  • -1: Could not create chest
  • Any other number: The index value of the chest
public static bool DestroyChest(int X, int Y)

Removes the chest at the given location.

  • true: The chest is empty and will be destroyed
  • false: The chest has items and cannot be destroyed
public static int FindChest(int X, int Y)

Returns the index of Main.chest[] for the chest at the given location.

  • -1: Could not find chest
  • Any other number: The index value of the chest
public static void Unlock(int X, int Y)

Unlocks the chest at the given location. Does not check the inventory for keys, so if you have any conditional statements, you should check them before calling this method.

  • Returns no value
public static int UsingChest(int i)	

When supplied with an index for Main.chest[], this method returns the whoAmI of the player currently using that chest.

  • -1: Nobody is using the chest
  • Any other number: whoAmI of the player using the chest


None yet

Classes in Terraria

Chest | Cloud | Collision | Dust | Gore | Item | Lighting | Liquid | Main | NPC | Player | Projectile | Recipe | Sign | Star | WorldGen