Class ItemContainers

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

public final class ItemContainers extends Object
Inventories kept in an item stack's minecraft:container component (as shulker boxes keep theirs).
SlotContainer pouch = ItemContainers.of(stack, POUCH_LAYOUT);
pouch.insert(new ItemStack(Items.DIAMOND), false);   // written back to the stack right away
player.openMenu(new SimpleMenuProvider((id, inventory, p) -> new PouchMenu(id, inventory, pouch), title));
  • Method Details

    • of

      public static SlotContainer of(net.minecraft.world.item.ItemStack stack, ContainerLayout layout)
      The stack's inventory: reads the stack now and writes every change back to it. Keep it only as long as the stack is the one in use (a menu should check the player still holds it).
    • of

      @Nullable public static @Nullable SlotContainer of(net.minecraft.world.item.ItemStack stack)
      The inventory of a ContainerItem's stack, or null for other items.