Package net.minecraft.world
Class ContainerHelper
java.lang.Object
net.minecraft.world.ContainerHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
clearOrCountMatchingItems
(Container container, Predicate<ItemStack> itemPredicate, int maxItems, boolean simulate) Clears items from the inventory matching a predicate.static int
clearOrCountMatchingItems
(ItemStack stack, Predicate<ItemStack> itemPredicate, int maxItems, boolean simulate) static void
loadAllItems
(CompoundTag tag, NonNullList<ItemStack> items, HolderLookup.Provider levelRegistry) static ItemStack
removeItem
(List<ItemStack> stacks, int index, int amount) static CompoundTag
saveAllItems
(CompoundTag tag, NonNullList<ItemStack> items, boolean alwaysPutTag, HolderLookup.Provider levelRegistry) static CompoundTag
saveAllItems
(CompoundTag tag, NonNullList<ItemStack> items, HolderLookup.Provider levelRegistry) static ItemStack
-
Field Details
-
TAG_ITEMS
- See Also:
-
-
Constructor Details
-
ContainerHelper
public ContainerHelper()
-
-
Method Details
-
removeItem
-
takeItem
-
saveAllItems
public static CompoundTag saveAllItems(CompoundTag tag, NonNullList<ItemStack> items, HolderLookup.Provider levelRegistry) -
saveAllItems
public static CompoundTag saveAllItems(CompoundTag tag, NonNullList<ItemStack> items, boolean alwaysPutTag, HolderLookup.Provider levelRegistry) -
loadAllItems
public static void loadAllItems(CompoundTag tag, NonNullList<ItemStack> items, HolderLookup.Provider levelRegistry) -
clearOrCountMatchingItems
public static int clearOrCountMatchingItems(Container container, Predicate<ItemStack> itemPredicate, int maxItems, boolean simulate) Clears items from the inventory matching a predicate.- Parameters:
maxItems
- The maximum amount of items to be cleared. A negative value means unlimited and 0 means count how many items are found that could be cleared.- Returns:
- The amount of items cleared
-
clearOrCountMatchingItems
-