Class ContainerLayout
java.lang.Object
net.ixdarklord.coolcatcore.api.container.ContainerLayout
The shape of an inventory: how many slots, what each accepts and holds, who reaches it and from which faces.
One layout makes any number of
SlotContainers.
public static final ContainerLayout FURNACE_LIKE = ContainerLayout.builder(3)
.role(0, SlotRole.INPUT)
.filter(1, stack -> stack.is(ItemTags.COALS)).role(1, SlotRole.INPUT)
.role(2, SlotRole.OUTPUT)
.face(Direction.UP, 0).face(Direction.DOWN, 2) // faces left out reach every slot
.build();
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe most slots an item stack can keep in its NBT (anItemslist numbers its slots with a byte). -
Method Summary
Modifier and TypeMethodDescriptionstatic ContainerLayout.Builderbuilder(int size) com.mojang.serialization.Codec<SlotContainer>codec()Saves a container's contents (slot and item per filled slot).create()booleanexposes(int slot, @Nullable net.minecraft.core.Direction side) booleanisItemValid(int slot, net.minecraft.world.item.ItemStack stack) Whether the slot's filter takes the item.booleanWhether a block keeps the contents in its dropped item (like a shulker box) instead of spilling them.intstatic ContainerLayoutof(int size) sizestorage slots that take anything.role(int slot) intsize()intslotLimit(int slot) The most items the slot holds, before the item's own stack size.int[]slotsForFace(@Nullable net.minecraft.core.Direction side) The slots automation reaches through a face, or through any face fornull.StreamCodec<net.minecraft.network.FriendlyByteBuf,SlotContainer> Syncs a container's contents (every slot).
-
Field Details
-
MAX_ITEM_SLOTS
public static final int MAX_ITEM_SLOTSThe most slots an item stack can keep in its NBT (anItemslist numbers its slots with a byte).- See Also:
-
-
Method Details
-
builder
-
of
sizestorage slots that take anything. -
create
-
size
public int size() -
maxStackSize
public int maxStackSize() -
role
-
isItemValid
public boolean isItemValid(int slot, net.minecraft.world.item.ItemStack stack) Whether the slot's filter takes the item. -
slotLimit
public int slotLimit(int slot) The most items the slot holds, before the item's own stack size. -
slotsForFace
public int[] slotsForFace(@Nullable @Nullable net.minecraft.core.Direction side) The slots automation reaches through a face, or through any face fornull. Don't modify it. -
exposes
public boolean exposes(int slot, @Nullable @Nullable net.minecraft.core.Direction side) -
keepContentsOnBreak
public boolean keepContentsOnBreak()Whether a block keeps the contents in its dropped item (like a shulker box) instead of spilling them. The block entity then also saves them as a vanillaItemslist, which the block's loot table must copy from the block entity into the item, like a shulker box's: acopy_nbtfunction fromblock_entitywith the operation"source": "Items", "target": "BlockEntityTag.Items", "op": "replace". -
codec
Saves a container's contents (slot and item per filled slot). -
streamCodec
Syncs a container's contents (every slot).
-