Interface BaseContainer
- All Superinterfaces:
net.minecraft.world.Clearable,net.minecraft.world.Container
public interface BaseContainer
extends net.minecraft.world.Container
-
Field Summary
Fields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_LIMIT, LARGE_MAX_STACK_SIZE -
Method Summary
Modifier and TypeMethodDescriptiondefault voidClears the inventory.default intReturns the inventory size.default net.minecraft.world.item.ItemStackgetItem(int slot) Retrieves the item in the slot.net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>getItems()Retrieves the item list of this inventory.default booleanisEmpty()Checks if the inventory is empty.static BaseContainerof(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> items) Creates an inventory from the item list.static BaseContainerofSize(int size) Creates a new inventory with the specified size.default net.minecraft.world.item.ItemStackremoveItem(int slot, int count) Removes items from an inventory slot.default net.minecraft.world.item.ItemStackremoveItemNoUpdate(int slot) Removes all items from an inventory slot.default voidMarks the state as dirty.default voidsetItem(int slot, net.minecraft.world.item.ItemStack stack) Replaces the current stack in an inventory slot with the provided stack.default booleanstillValid(net.minecraft.world.entity.player.Player player) Methods inherited from interface net.minecraft.world.Container
canPlaceItem, canTakeItem, countItem, getMaxStackSize, hasAnyMatching, hasAnyOf, startOpen, stopOpen
-
Method Details
-
getItems
net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getItems()Retrieves the item list of this inventory. Must return the same instance every time it's called. -
of
Creates an inventory from the item list. -
ofSize
Creates a new inventory with the specified size. -
getContainerSize
default int getContainerSize()Returns the inventory size.- Specified by:
getContainerSizein interfacenet.minecraft.world.Container
-
isEmpty
default boolean isEmpty()Checks if the inventory is empty.- Specified by:
isEmptyin interfacenet.minecraft.world.Container- Returns:
- true if this inventory has only empty stacks, false otherwise.
-
getItem
default net.minecraft.world.item.ItemStack getItem(int slot) Retrieves the item in the slot.- Specified by:
getItemin interfacenet.minecraft.world.Container
-
removeItem
default net.minecraft.world.item.ItemStack removeItem(int slot, int count) Removes items from an inventory slot.- Specified by:
removeItemin interfacenet.minecraft.world.Container- Parameters:
slot- The slot to remove from.count- How many items to remove. If there are less items in the slot than what are requested, takes all items in that slot.
-
removeItemNoUpdate
default net.minecraft.world.item.ItemStack removeItemNoUpdate(int slot) Removes all items from an inventory slot.- Specified by:
removeItemNoUpdatein interfacenet.minecraft.world.Container- Parameters:
slot- The slot to remove from.
-
setItem
default void setItem(int slot, net.minecraft.world.item.ItemStack stack) Replaces the current stack in an inventory slot with the provided stack.- Specified by:
setItemin interfacenet.minecraft.world.Container- Parameters:
slot- The inventory slot of which to replace the itemstack.stack- The replacing itemstack. If the stack is too big for this inventory (Container.getMaxStackSize()()}), it gets resized to this inventory's maximum amount.
-
clearContent
default void clearContent()Clears the inventory.- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-
setChanged
default void setChanged()Marks the state as dirty. Must be called after changes in the inventory, so that the game can properly save the inventory contents and notify neighboring blocks of inventory changes.- Specified by:
setChangedin interfacenet.minecraft.world.Container
-
stillValid
default boolean stillValid(net.minecraft.world.entity.player.Player player) - Specified by:
stillValidin interfacenet.minecraft.world.Container- Returns:
- true if the player can use the inventory, false otherwise.
-