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();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The most slots an item stack can keep in its minecraft:container component.
  • Method Summary

    Modifier and Type
    Method
    Description
    builder(int size)
     
    com.mojang.serialization.Codec<SlotContainer>
    Saves a container's contents (slot and item per filled slot).
     
    boolean
    exposes(int slot, @Nullable net.minecraft.core.Direction side)
     
    boolean
    isItemValid(int slot, net.minecraft.world.item.ItemStack stack)
    Whether the slot's filter takes the item.
    boolean
    Whether a block keeps the contents in its dropped item (like a shulker box) instead of spilling them.
    int
     
    of(int size)
    size storage slots that take anything.
    role(int slot)
     
    int
     
    int
    slotLimit(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 for null.
    net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,SlotContainer>
    Syncs a container's contents (every slot).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_ITEM_SLOTS

      public static final int MAX_ITEM_SLOTS
      The most slots an item stack can keep in its minecraft:container component.
      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's loot table must copy minecraft:container from the block entity.
    • codec

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

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