Class ItemContainerContents
java.lang.Object
net.minecraft.world.item.component.ItemContainerContents
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ItemContainerContents> static final ItemContainerContentsprivate final intprivate final NonNullList<ItemStack> private static final intprivate static final intstatic final StreamCodec<RegistryFriendlyByteBuf, ItemContainerContents> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateItemContainerContents(int p_331689_) privateItemContainerContents(List<ItemStack> p_331046_) privateItemContainerContents(NonNullList<ItemStack> p_332193_) -
Method Summary
Modifier and TypeMethodDescriptionprivate List<ItemContainerContents.Slot> asSlots()voidcopyInto(NonNullList<ItemStack> p_330513_) copyOne()booleanprivate static intfindLastNonEmptySlot(List<ItemStack> p_340916_) static ItemContainerContentsprivate static ItemContainerContentsfromSlots(List<ItemContainerContents.Slot> p_331424_) intgetSlots()Returns the number of slots in this container.getStackInSlot(int slot) Gets a copy of the stack at a particular slot.inthashCode()stream()private voidvalidateSlotIndex(int slot) ThrowsUnsupportedOperationExceptionif the provided slot index is invalid.
-
Field Details
-
NO_SLOT
private static final int NO_SLOT- See Also:
-
MAX_SIZE
private static final int MAX_SIZE- See Also:
-
EMPTY
-
CODEC
-
STREAM_CODEC
-
items
-
hashCode
private final int hashCode
-
-
Constructor Details
-
ItemContainerContents
-
ItemContainerContents
private ItemContainerContents(int p_331689_) -
ItemContainerContents
-
-
Method Details
-
fromSlots
-
fromItems
-
findLastNonEmptySlot
-
asSlots
-
copyInto
-
copyOne
-
stream
-
nonEmptyStream
-
nonEmptyItems
-
nonEmptyItemsCopy
-
equals
-
hashCode
public int hashCode() -
getSlots
public int getSlots()Returns the number of slots in this container.- Returns:
- the number of slots in this container
-
getStackInSlot
Gets a copy of the stack at a particular slot.- Parameters:
slot- The slot to check. Must be within [0,getSlots()]- Returns:
- A copy of the stack in that slot
- Throws:
UnsupportedOperationException- if the provided slot index is out-of-bounds.
-
validateSlotIndex
private void validateSlotIndex(int slot) ThrowsUnsupportedOperationExceptionif the provided slot index is invalid.
-