Class ItemArray<C extends Container<jl>>

java.lang.Object
  extended by ItemArray<C>
Direct Known Subclasses:
BaseContainerBlock, DoubleChest, PlayerInventory, StorageMinecart

public abstract class ItemArray<C extends Container<jl>>
extends java.lang.Object

ItemArray.java - Interface to jh[] so I don't have to copy+paste this a bunch of times


Field Summary
Modifier and Type Field and Description
protected  C container
           
 
Constructor Summary
Constructor and Description
ItemArray(C c)
           
 
Method Summary
Modifier and Type Method and Description
 void addItem(Item item)
          Adds the specified item.
 void clearContents()
           
 Item[] getContents()
          Returns the contents of this chest
 int getContentsSize()
           
 int getEmptySlot()
          Gets the nearest empty slot.
 Item getItemFromId(int id)
          Retrieves from the slot
 Item getItemFromId(int id, int maxAmount)
          Retrieves from the slot
 Item getItemFromId(Item.Type type)
          Retrieves from the slot
 Item getItemFromId(Item.Type type, int maxAmount)
          Retrieves from the slot
 Item getItemFromSlot(int slot)
          Retrieves from the slot
 boolean hasItem(int itemId)
          Checks to see if this getArray() has one slot that has the given item id
 boolean hasItem(int itemId, int minimum)
          Checks to see if this getArray() has one slot that has the item id and equal or more to the amount.
 boolean hasItem(int itemId, int minimum, int maximum)
          Checks to see if this getArray() has one slot that has the item id and equal or more to the amount.
 boolean hasItem(Item.Type type)
          Checks to see if this getArray() has one slot that has the given item type
 boolean hasItem(Item.Type type, int minimum)
          Checks to see if this getArray() has one slot that has the item id and equal or more to the amount.
 void removeItem(int slot)
          Removes the item from the slot
 void removeItem(int id, int amount)
          Removes the item.
 void removeItem(Item.Type type, int amount)
          Removes the item.
 void removeItem(Item item)
          Removes the item.
 void setContents(Item[] contents)
          Sets the contents
 void setSlot(int itemId, int amount, int slot)
          Replaces the slot with the specified item.
 void setSlot(int itemId, int amount, int damage, int slot)
          Replaces the slot with the specified item.
 void setSlot(Item.Type type, int amount, int slot)
          Replaces the slot with the specified item.
 void setSlot(Item item, int slot)
          Sets the specified slot with item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

protected C extends Container<jl> container
Constructor Detail

ItemArray

public ItemArray(C c)
Method Detail

getContentsSize

public int getContentsSize()

addItem

public void addItem(Item item)
Adds the specified item. If the item doesn't have a slot, it will get the nearest available slot. If amount is equal to 0, it will delete the item if a slot is specified.

Parameters:
item - item to add

getItemFromSlot

public Item getItemFromSlot(int slot)
Retrieves from the slot

Parameters:
slot - slot to get item from
Returns:
item

getItemFromId

public Item getItemFromId(Item.Type type)
Retrieves from the slot

Parameters:
type -
Returns:
item

getItemFromId

public Item getItemFromId(int id)
Retrieves from the slot

Parameters:
id -
Returns:
item

getItemFromId

public Item getItemFromId(Item.Type type,
                          int maxAmount)
Retrieves from the slot

Parameters:
type -
maxAmount -
Returns:
item

getItemFromId

public Item getItemFromId(int id,
                          int maxAmount)
Retrieves from the slot

Parameters:
id -
maxAmount -
Returns:
item

getEmptySlot

public int getEmptySlot()
Gets the nearest empty slot. -1 if there's no empty slots

Returns:
nearest empty slot

removeItem

public void removeItem(int slot)
Removes the item from the slot

Parameters:
slot - slot to remove item from

setSlot

public void setSlot(Item item,
                    int slot)
Sets the specified slot with item

Parameters:
item - item to set
slot - slot to use

setSlot

public void setSlot(Item.Type type,
                    int amount,
                    int slot)
Replaces the slot with the specified item.

Parameters:
type - type of the item to put into the slot.
amount - amount of the item to put into the slot.
slot - the id of the slot.

setSlot

public void setSlot(int itemId,
                    int amount,
                    int slot)
Replaces the slot with the specified item.

Parameters:
itemId - item id of the item to put into the slot.
amount - amount of the item to put into the slot.
slot - the id of the slot.

setSlot

public void setSlot(int itemId,
                    int amount,
                    int damage,
                    int slot)
Replaces the slot with the specified item.

Parameters:
itemId - item id of the item to put into the slot.
amount - amount of the item to put into the slot.
damage - remaining damage of the item to put into the slot.
slot - the id of the slot.

removeItem

public void removeItem(Item item)
Removes the item. No slot needed, it will go through the inventory until the amount specified is removed.

Parameters:
item - item id and amount to remove

removeItem

public void removeItem(Item.Type type,
                       int amount)
Removes the item. No slot needed, it will go through the inventory until the amount specified is removed.

Parameters:
type - item to remove
amount - amount to remove

removeItem

public void removeItem(int id,
                       int amount)
Removes the item. No slot needed, it will go through the inventory until the amount specified is removed.

Parameters:
id - item to remove
amount - amount to remove

hasItem

public boolean hasItem(Item.Type type)
Checks to see if this getArray() has one slot that has the given item type

Parameters:
type -
Returns:

hasItem

public boolean hasItem(int itemId)
Checks to see if this getArray() has one slot that has the given item id

Parameters:
itemId -
Returns:

hasItem

public boolean hasItem(Item.Type type,
                       int minimum)
Checks to see if this getArray() has one slot that has the item id and equal or more to the amount.

Parameters:
type - item to look for
minimum - amount of items that must be in the stack
Returns:

hasItem

public boolean hasItem(int itemId,
                       int minimum)
Checks to see if this getArray() has one slot that has the item id and equal or more to the amount.

Parameters:
itemId - item to look for
minimum - amount of items that must be in the stack
Returns:

hasItem

public boolean hasItem(int itemId,
                       int minimum,
                       int maximum)
Checks to see if this getArray() has one slot that has the item id and equal or more to the amount.

Parameters:
itemId -
minimum -
maximum -
Returns:

getContents

public Item[] getContents()
Returns the contents of this chest

Returns:
contents

setContents

public void setContents(Item[] contents)
Sets the contents

Parameters:
contents - contents to set

clearContents

public void clearContents()