Interface Container
- All Known Implementing Classes:
EnderChestInventory, PlayerInventory, SimpleContainer
public interface Container
A fixed number of item slots, indexed from
0.
Empty slots hold ItemStack.EMPTY, never null.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Empties every slot.default ItemStack[]contents()Returns a copy of every slot, in index order.default intReturns the index of the first empty slot, or-1when the container is full.get(int slot) Gets the contents of a slot.booleanisEmpty()Returnstrueif every slot is empty.voidReplaces the contents of a slot.default voidsetContents(@Nullable ItemStack[] contents) Replaces every slot at once.intsize()Returns the number of slots exposed by this container.
-
Method Details
-
size
int size()Returns the number of slots exposed by this container.- Returns:
- the number of slots exposed by this container
- Since:
- 0.1.0
-
get
Gets the contents of a slot.- Parameters:
slot- the slot index, from0tosize() - 1- Returns:
- the stack in the slot,
ItemStack.EMPTYwhen it is empty - Throws:
IndexOutOfBoundsException- if the slot is out of bounds- Since:
- 0.1.0
-
set
Replaces the contents of a slot.- Parameters:
slot- the slot index, from0tosize() - 1stack- the new stack;nullis normalized toItemStack.EMPTY- Throws:
IndexOutOfBoundsException- if the slot is out of bounds- Since:
- 0.1.0
-
clear
void clear()Empties every slot.- Since:
- 0.1.0
-
isEmpty
boolean isEmpty()Returnstrueif every slot is empty.- Returns:
trueif every slot is empty- Since:
- 0.1.0
-
firstEmpty
default int firstEmpty()Returns the index of the first empty slot, or-1when the container is full.- Returns:
- the index of the first empty slot, or
-1when the container is full - Since:
- 0.1.0
-
contents
Returns a copy of every slot, in index order.- Returns:
- a copy of every slot, in index order
- Since:
- 0.1.0
-
setContents
-