Package net.minecraft.world
Class SimpleContainer
java.lang.Object
net.minecraft.world.SimpleContainer
- All Implemented Interfaces:
Iterable<ItemStack>,Clearable,Container,StackedContentsCompatible,ContainerExtension
- Direct Known Subclasses:
ComposterBlock.EmptyContainer,ComposterBlock.InputContainer,ComposterBlock.OutputContainer,PlayerEnderChestContainer
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.world.Container
Container.ContainerIterator -
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 pListener) Add a listener that will be notified when any item in this inventory is modified.booleancanAddItem(ItemStack pStack) voidvoidfillStackedContents(StackedItemContents p_361025_) voidintgetItem(int pIndex) Returns the stack in the given slot.getItems()booleanisEmpty()private voidmoveItemsBetweenStacks(ItemStack pStack, ItemStack pOther) private voidmoveItemToEmptySlots(ItemStack pStack) private voidremoveItem(int pIndex, int pCount) Removes up to a specified number of items from an inventory slot and returns them in a new stack.removeItemNoUpdate(int pIndex) Removes a stack from the given slot and returns it.removeItemType(Item pItem, int pAmount) voidremoveListener(ContainerListener pListener) 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).voidSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).booleanstillValid(Player pPlayer) Don't rename this method to canInteractWith due to conflicts with ContainervoidtoString()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, getEntitiesWithContainerOpen, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, iterator, startOpen, stopOpenMethods inherited from interface net.neoforged.neoforge.common.extensions.ContainerExtension
onTransferMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
size
private final int size -
items
-
listeners
-
-
Constructor Details
-
SimpleContainer
public SimpleContainer(int pSize) -
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). -
setItem
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).- Specified by:
setItemin interfaceContainerExtension- Parameters:
insideTransaction- Whentrue, non-transactional actions should be deferred. Whenfalse, non-transactional actions can be performed immediately.- See Also:
-
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
-
fromItemList
-
storeAsItemList
-
getItems
-