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 int
Fields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ContainerListener listener) Add a listener that will be notified when any item in this inventory is modified.boolean
canAddItem
(ItemStack stack) void
createTag
(HolderLookup.Provider levelRegistry) void
fillStackedContents
(StackedContents helper) void
fromTag
(ListTag tag, HolderLookup.Provider levelRegistry) int
getItem
(int index) Returns the stack in the given slot.getItems()
boolean
isEmpty()
private void
moveItemsBetweenStacks
(ItemStack stack, ItemStack other) private void
moveItemToEmptySlots
(ItemStack stack) private void
removeItem
(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) void
removeListener
(ContainerListener listener) Removes the specifiedContainerListener
from receiving further change notices.void
void
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).boolean
stillValid
(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, wait
Methods 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 specifiedContainerListener
from 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:
removeItem
in interfaceContainer
-
removeItemType
-
addItem
-
canAddItem
-
removeItemNoUpdate
Removes a stack from the given slot and returns it.- Specified by:
removeItemNoUpdate
in 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:
getContainerSize
in interfaceContainer
-
isEmpty
public boolean isEmpty() -
setChanged
public void setChanged()- Specified by:
setChanged
in interfaceContainer
-
stillValid
Don't rename this method to canInteractWith due to conflicts with Container- Specified by:
stillValid
in interfaceContainer
-
clearContent
public void clearContent()- Specified by:
clearContent
in interfaceClearable
-
fillStackedContents
- Specified by:
fillStackedContents
in interfaceStackedContentsCompatible
-
toString
-
moveItemToEmptySlots
-
moveItemToOccupiedSlotsWithSameType
-
moveItemsBetweenStacks
-
fromTag
-
createTag
-
getItems
-