@ParametersAreNullableByDefault public interface Container
| Modifier and Type | Method and Description |
|---|---|
boolean |
addItem(ItemStack item)
Add an item to the first empty slot or merge with other items.
|
boolean |
addItemToFirstEmptySlot(ItemStack item)
Adds an item to the first empty slot
|
void |
clearSlot(int slot)
Clear specific slot in the
Container. |
void |
clearSlots()
Clear all slots in the
Container. |
void |
decreaseSlot(int slot,
int amount) |
void |
dropContents(Level level,
com.flowpowered.math.vector.Vector3f position,
boolean randomize)
Drop the contents of the
Container to the world as DroppedItems. |
ItemStack[] |
getContents()
Retrieve a copy of the entire
Container's contents. |
Optional<String> |
getCustomName()
Get container name if it exists.
|
int |
getEmptySlotsCount()
The amount of empty slots.
|
OptionalInt |
getFirstEmptySlot()
Get the first empty slot
|
int |
getSize()
Get the size of the container
|
ItemStack |
getSlot(int slot)
Get item in given slot if it exists
|
boolean |
hasCustomName()
Whether the container has a custom name.
|
boolean |
hasRoomForItem(ItemStack item)
Check to see if there is enough room for the given item, whether that be empty slots or an item that
ItemStack.isMergeable(ItemStack). |
void |
setCustomName(String name)
Give the container a custom name or set as null for default.
|
void |
setSlot(int slot,
ItemStack item)
Set an item at a given slot.
|
Optional<String> getCustomName()
void setCustomName(String name)
name - custom nameboolean hasCustomName()
ItemStack getSlot(int slot)
slot - the slot to getboolean addItem(ItemStack item)
item - item to addboolean addItemToFirstEmptySlot(ItemStack item)
item - item to addvoid setSlot(int slot,
ItemStack item)
slot - slot to setitem - item to setvoid clearSlot(int slot)
Container.slot - slot to clearSlotvoid clearSlots()
Container.void decreaseSlot(int slot,
int amount)
@Nonnull ItemStack[] getContents()
Container's contents.
Changes to this array will not affect the ContainerContainerint getEmptySlotsCount()
OptionalInt getFirstEmptySlot()
boolean hasRoomForItem(ItemStack item)
ItemStack.isMergeable(ItemStack).item - item to test againstvoid dropContents(@Nonnull Level level, @Nonnull com.flowpowered.math.vector.Vector3f position, boolean randomize)
Container to the world as DroppedItems.level - level to drop the contents inposition - blockPosition at which to drop the contentsrandomize - random offset and motion to the itemsint getSize()
Copyright © 2017–2019 NukkitX. All rights reserved.