Class ContainerLayout

java.lang.Object
net.ixdarklord.coolcatcore.api.container.ContainerLayout

public final class ContainerLayout extends Object
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();
 
  • Field Details

    • MAX_ITEM_SLOTS

      public static final int MAX_ITEM_SLOTS
      The most slots an item stack can keep in its NBT (an Items list numbers its slots with a byte).
      See Also:
  • Method Details

    • builder

      public static ContainerLayout.Builder builder(int size)
    • of

      public static ContainerLayout of(int size)
      size storage slots that take anything.
    • create

      public SlotContainer create()
    • size

      public int size()
    • maxStackSize

      public int maxStackSize()
    • role

      public SlotRole role(int slot)
    • 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 for null. 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 vanilla Items list, which the block's loot table must copy from the block entity into the item, like a shulker box's: a copy_nbt function from block_entity with the operation "source": "Items", "target": "BlockEntityTag.Items", "op": "replace".
    • codec

      public com.mojang.serialization.Codec<SlotContainer> codec()
      Saves a container's contents (slot and item per filled slot).
    • streamCodec

      public StreamCodec<net.minecraft.network.FriendlyByteBuf,SlotContainer> streamCodec()
      Syncs a container's contents (every slot).