Class InventoryUtil
java.lang.Object
my.celium.org.util.InventoryUtil
Small cohesive inventory helpers over vanilla
Container.
Slot counts are small; all scans are linear and allocation-free in spirit.-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(net.minecraft.world.Container container, net.minecraft.world.item.Item item, int amount) static intcount(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> filter) static intcount(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> filter) static intcountItem(net.minecraft.world.Container container, net.minecraft.world.item.Item item) static intfindSlot(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> filter) First slot matching the filter, or-1.static booleanholdOne(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> filter) Deprecated, for removal: This API element is subject to removal in a future version.despite its name this never moved anything into the hand; it only reports whether a match exists.static net.minecraft.world.item.ItemStackinsert(net.minecraft.world.Container container, net.minecraft.world.item.ItemStack stack) Insertsstack, merging with existing stacks first.static intremove(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> filter, int amount) Removes up toamountmatching items.static intremoveItem(net.minecraft.world.Container container, net.minecraft.world.item.Item item, int amount)
-
Method Details
-
count
public static int count(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> filter) -
count
public static int count(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> filter) -
countItem
public static int countItem(net.minecraft.world.Container container, net.minecraft.world.item.Item item) -
contains
public static boolean contains(net.minecraft.world.Container container, net.minecraft.world.item.Item item, int amount) -
remove
public static int remove(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> filter, int amount) Removes up toamountmatching items. Returns how many were actually removed. -
removeItem
public static int removeItem(net.minecraft.world.Container container, net.minecraft.world.item.Item item, int amount) -
insert
public static net.minecraft.world.item.ItemStack insert(net.minecraft.world.Container container, net.minecraft.world.item.ItemStack stack) Insertsstack, merging with existing stacks first. Returns the leftover (possibly empty). The passed stack is consumed. -
findSlot
public static int findSlot(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> filter) First slot matching the filter, or-1. -
holdOne
@Deprecated(since="1.4.0", forRemoval=true) public static boolean holdOne(net.minecraft.world.entity.player.Player player, Predicate<net.minecraft.world.item.ItemStack> filter) Deprecated, for removal: This API element is subject to removal in a future version.despite its name this never moved anything into the hand; it only reports whether a match exists. UsefindSlot(Container, Predicate)instead. Removed in Mycel 2.0.Whether the player's inventory holds an item matchingfilter.
-