Class ItemContainers
java.lang.Object
net.ixdarklord.coolcatcore.api.container.ItemContainers
Inventories kept in an item stack's NBT, as vanilla keeps them: an
Items list in the stack's
BlockEntityTag for block items (as shulker boxes keep theirs, so placing the block restores the contents), and
in the stack's own tag for other items (as bundles do).
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));
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable net.minecraft.nbt.CompoundTagcontentsTag(net.minecraft.world.item.ItemStack stack) The tag holding the stack'sItemslist: itsBlockEntityTagfor block items, its own tag otherwise;nullwhen there's none.static @Nullable SlotContainerof(net.minecraft.world.item.ItemStack stack) The inventory of aContainerItem's stack, ornullfor other items.static SlotContainerof(net.minecraft.world.item.ItemStack stack, ContainerLayout layout) The stack's inventory: reads the stack now and writes every change back to it.
-
Field Details
-
ITEMS_TAG
The list holding the contents, inContainerHelper.saveAllItems(net.minecraft.nbt.CompoundTag, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>)format.- See Also:
-
-
Method Details
-
of
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
The inventory of aContainerItem's stack, ornullfor other items. -
contentsTag
@Nullable public static @Nullable net.minecraft.nbt.CompoundTag contentsTag(net.minecraft.world.item.ItemStack stack) The tag holding the stack'sItemslist: itsBlockEntityTagfor block items, its own tag otherwise;nullwhen there's none.
-