public class ItemStackHandler extends java.lang.Object implements IItemHandler, IItemHandlerModifiable, INBTSerializable<NBTTagCompound>
Constructor and Description |
---|
ItemStackHandler() |
ItemStackHandler(int size) |
ItemStackHandler(ItemStack[] stacks) |
Modifier and Type | Method and Description |
---|---|
void |
deserializeNBT(NBTTagCompound nbt) |
ItemStack |
extractItem(int slot,
int amount,
boolean simulate)
Extracts an ItemStack from the given slot.
|
int |
getSlots()
Returns the number of slots available
|
ItemStack |
getStackInSlot(int slot)
Returns the ItemStack in a given slot.
|
protected int |
getStackLimit(int slot,
ItemStack stack) |
ItemStack |
insertItem(int slot,
ItemStack stack,
boolean simulate)
Inserts an ItemStack into the given slot and return the remainder.
|
protected void |
onContentsChanged(int slot) |
protected void |
onLoad() |
NBTTagCompound |
serializeNBT() |
void |
setSize(int size) |
void |
setStackInSlot(int slot,
ItemStack stack)
Overrides the stack in the given slot.
|
protected void |
validateSlotIndex(int slot) |
protected ItemStack[] stacks
public ItemStackHandler()
public ItemStackHandler(int size)
public ItemStackHandler(ItemStack[] stacks)
public void setSize(int size)
public void setStackInSlot(int slot, ItemStack stack)
IItemHandlerModifiable
setStackInSlot
in interface IItemHandlerModifiable
slot
- Slot to modifystack
- ItemStack to set slot to (may be null)public int getSlots()
IItemHandler
getSlots
in interface IItemHandler
public ItemStack getStackInSlot(int slot)
IItemHandler
getStackInSlot
in interface IItemHandler
slot
- Slot to querypublic ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
IItemHandler
insertItem
in interface IItemHandler
slot
- Slot to insert into.stack
- ItemStack to insert.simulate
- If true, the insertion is only simulatedpublic ItemStack extractItem(int slot, int amount, boolean simulate)
IItemHandler
extractItem
in interface IItemHandler
slot
- Slot to extract from.amount
- Amount to extract (may be greater than the current stacks max limit)simulate
- If true, the extraction is only simulatedprotected int getStackLimit(int slot, ItemStack stack)
public NBTTagCompound serializeNBT()
serializeNBT
in interface INBTSerializable<NBTTagCompound>
public void deserializeNBT(NBTTagCompound nbt)
deserializeNBT
in interface INBTSerializable<NBTTagCompound>
protected void validateSlotIndex(int slot)
protected void onLoad()
protected void onContentsChanged(int slot)