Package net.minecraft.world
Class SimpleContainer
java.lang.Object
net.minecraft.world.SimpleContainer
- All Implemented Interfaces:
Clearable,Container,StackedContentsCompatible
- Direct Known Subclasses:
ComposterBlock.EmptyContainer,ComposterBlock.InputContainer,ComposterBlock.OutputContainer,PlayerEnderChestContainer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NonNullList<ItemStack> private List<ContainerListener> private final intFields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ContainerListener listener) Add a listener that will be notified when any item in this inventory is modified.booleancanAddItem(ItemStack stack) voidcreateTag(HolderLookup.Provider levelRegistry) voidfillStackedContents(StackedContents helper) voidfromTag(ListTag tag, HolderLookup.Provider levelRegistry) intgetItem(int index) Returns the stack in the given slot.getItems()booleanisEmpty()private voidmoveItemsBetweenStacks(ItemStack stack, ItemStack other) private voidmoveItemToEmptySlots(ItemStack stack) private voidremoveItem(int index, int count) Removes up to a specified number of items from an inventory slot and returns them in a new stack.removeItemNoUpdate(int index) Removes a stack from the given slot and returns it.removeItemType(Item item, int amount) voidremoveListener(ContainerListener listener) Removes the specifiedContainerListenerfrom receiving further change notices.voidvoidSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).booleanstillValid(Player player) Don't rename this method to canInteractWith due to conflicts with ContainertoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.Container
canPlaceItem, canTakeItem, countItem, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, startOpen, stopOpen
-
Field Details
-
size
private final int size -
items
-
listeners
-
-
Constructor Details
-
SimpleContainer
public SimpleContainer(int size) -
SimpleContainer
-
-
Method Details
-
addListener
Add a listener that will be notified when any item in this inventory is modified. -
removeListener
Removes the specifiedContainerListenerfrom receiving further change notices. -
getItem
Returns the stack in the given slot. -
removeAllItems
-
removeItem
Removes up to a specified number of items from an inventory slot and returns them in a new stack.- Specified by:
removeItemin interfaceContainer
-
removeItemType
-
addItem
-
canAddItem
-
removeItemNoUpdate
Removes a stack from the given slot and returns it.- Specified by:
removeItemNoUpdatein interfaceContainer
-
setItem
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). -
getContainerSize
public int getContainerSize()- Specified by:
getContainerSizein interfaceContainer
-
isEmpty
public boolean isEmpty() -
setChanged
public void setChanged()- Specified by:
setChangedin interfaceContainer
-
stillValid
Don't rename this method to canInteractWith due to conflicts with Container- Specified by:
stillValidin interfaceContainer
-
clearContent
public void clearContent()- Specified by:
clearContentin interfaceClearable
-
fillStackedContents
- Specified by:
fillStackedContentsin interfaceStackedContentsCompatible
-
toString
-
moveItemToEmptySlots
-
moveItemToOccupiedSlotsWithSameType
-
moveItemsBetweenStacks
-
fromTag
-
createTag
-
getItems
-