Package alexiil.mc.lib.attributes.item
Class ItemInvUtil
java.lang.Object
alexiil.mc.lib.attributes.item.ItemInvUtil
Various hooks and methods for dealing with pairs of 
FixedItemInv, FixedItemInvView,
 ItemInsertable, ItemExtractable, and GroupedItemInvView instances.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classA pair of ints, representing both the total number of stacks and the total number of items moved bymoveMultiple(ItemExtractable, ItemInsertable, ItemFilter, int, int).
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcopyAll(FixedItemInvView inv, List<net.minecraft.item.ItemStack> dest)Copies everyItemStackheld in the given inventory to the givenList.static Consumer<net.minecraft.item.ItemStack>createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)Deprecated, for removal: This API element is subject to removal in a future version.static net.minecraft.item.ItemStackextractSingle(FixedItemInv inv, int slot, ItemFilter filter, net.minecraft.item.ItemStack toAddWith, int maxAmount, Simulation simulation)Deprecated, for removal: This API element is subject to removal in a future version.Because this has been moved toFixedItemInv.extractStack(int, ItemFilter, ItemStack, int, Simulation).static voidinsertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack stack)Deprecated, for removal: This API element is subject to removal in a future version.static net.minecraft.item.ItemStackinsertSingle(FixedItemInv inv, int slot, net.minecraft.item.ItemStack toInsert, Simulation simulation)Deprecated, for removal: This API element is subject to removal in a future version.Because this has been moved toFixedItemInv.insertStack(int, ItemStack, Simulation).static intmove(ItemExtractable from, ItemInsertable to, int maximum)Attempts to move up to the given maximum number of items from theItemExtractableto theItemInsertable.static intmove(ItemExtractable from, ItemInsertable to, ItemFilter filter, int maximum)Attempts to move up to the given maximum number of items from theItemExtractableto theItemInsertable, provided they match the givenItemFilter.static intmove(ItemExtractable from, ItemInsertable to, ItemFilter filter, int maximum, Simulation simulation)Attempts to move up to the given maximum number of items from theItemExtractableto theItemInsertable, provided they match the givenItemFilter.static ItemInvUtil.MultiMoveResultmoveMultiple(ItemExtractable from, ItemInsertable to)Attempts to move as much as possible from theItemExtractableto theItemInsertable.static ItemInvUtil.MultiMoveResultmoveMultiple(ItemExtractable from, ItemInsertable to, int maxStacks, int maxTotal)Attempts to move a given number of stacks from theItemExtractableto theItemInsertable.static ItemInvUtil.MultiMoveResultmoveMultiple(ItemExtractable from, ItemInsertable to, ItemFilter filter, int maxStacks, int maxTotal)Attempts to move a given number of stacks from theItemExtractableto theItemInsertable.static Reference<net.minecraft.item.ItemStack>referenceGuiCursor(net.minecraft.server.network.ServerPlayerEntity player)Deprecated, for removal: This API element is subject to removal in a future version.static Reference<net.minecraft.item.ItemStack>referenceHand(net.minecraft.entity.player.PlayerEntity player, net.minecraft.util.Hand hand)Deprecated, for removal: This API element is subject to removal in a future version.UsePlayerInvUtil.referenceHand(PlayerEntity,Hand)instead
- 
Method Details- 
createPlayerInsertable@Deprecated(since="0.6.4", forRemoval=true) public static Consumer<net.minecraft.item.ItemStack> createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)Deprecated, for removal: This API element is subject to removal in a future version.Returns aConsumerthat will callPlayerInvUtil.insertItemIntoPlayerInventory(PlayerEntity, ItemStack)for everyItemStackpassed to it.
- 
referenceHand@Deprecated(since="0.6.4", forRemoval=true) public static Reference<net.minecraft.item.ItemStack> referenceHand(net.minecraft.entity.player.PlayerEntity player, net.minecraft.util.Hand hand)Deprecated, for removal: This API element is subject to removal in a future version.UsePlayerInvUtil.referenceHand(PlayerEntity,Hand)insteadCreates aReferenceto the what the player is currently holding in the givenHand.
- 
referenceGuiCursor@Deprecated(since="0.6.4", forRemoval=true) public static Reference<net.minecraft.item.ItemStack> referenceGuiCursor(net.minecraft.server.network.ServerPlayerEntity player)Deprecated, for removal: This API element is subject to removal in a future version.Creates aReferenceto the given player'scursor stack, that updates the client whenever it is changed.
- 
insertItemIntoPlayerInventory@Deprecated(since="0.6.4", forRemoval=true) public static void insertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack stack)Deprecated, for removal: This API element is subject to removal in a future version.Either inserts the given item into the player's inventory or drops it in front of them. Note that this will always keep a reference to the passed stack (and might modify it!)
- 
moveAttempts to move up to the given maximum number of items from theItemExtractableto theItemInsertable. Note that this only ever moves a single stack, unlikemoveMultiple(ItemExtractable, ItemInsertable, ItemFilter, int, int).- Returns:
- The number of items moved.
- See Also:
- move(ItemExtractable, ItemInsertable, ItemFilter, int)
 
- 
moveAttempts to move up to the given maximum number of items from theItemExtractableto theItemInsertable, provided they match the givenItemFilter. Note that this only ever moves a single stack, unlikemoveMultiple(ItemExtractable, ItemInsertable, ItemFilter, int, int).- Returns:
- The number of items moved.
 
- 
movepublic static int move(ItemExtractable from, ItemInsertable to, ItemFilter filter, int maximum, Simulation simulation)Attempts to move up to the given maximum number of items from theItemExtractableto theItemInsertable, provided they match the givenItemFilter. Note that this only ever moves a single stack, unlikemoveMultiple(ItemExtractable, ItemInsertable, ItemFilter, int, int).- Returns:
- The number of items moved.
 
- 
moveMultipleAttempts to move as much as possible from theItemExtractableto theItemInsertable. Internally this callsmoveMultiple(ItemExtractable, ItemInsertable, int, int)withInteger.MAX_VALUEas the maximum value for both arguments.- Returns:
- The ItemInvUtil.MultiMoveResult
 
- 
moveMultiplepublic static ItemInvUtil.MultiMoveResult moveMultiple(ItemExtractable from, ItemInsertable to, int maxStacks, int maxTotal)Attempts to move a given number of stacks from theItemExtractableto theItemInsertable. Internally this callsmove(ItemExtractable, ItemInsertable, int)in a loop from 1 to maxStacks.- Returns:
- The ItemInvUtil.MultiMoveResult
 
- 
moveMultiplepublic static ItemInvUtil.MultiMoveResult moveMultiple(ItemExtractable from, ItemInsertable to, ItemFilter filter, int maxStacks, int maxTotal)Attempts to move a given number of stacks from theItemExtractableto theItemInsertable. Internally this callsmove(ItemExtractable, ItemInsertable, int)in a loop from 1 to maxStacks.- Returns:
- The ItemInvUtil.MultiMoveResult
 
- 
copyAllCopies everyItemStackheld in the given inventory to the givenList.
- 
insertSingle@Deprecated(since="0.8.0", forRemoval=true) public static net.minecraft.item.ItemStack insertSingle(FixedItemInv inv, int slot, net.minecraft.item.ItemStack toInsert, Simulation simulation)Deprecated, for removal: This API element is subject to removal in a future version.Because this has been moved toFixedItemInv.insertStack(int, ItemStack, Simulation).Inserts a single ItemStack into aFixedItemInv, using onlyFixedItemInv.setInvStack(int, ItemStack, Simulation). As such this is useful for implementations ofItemInsertable(or others) for the base implementation.- Parameters:
- toInsert- The stack to insert. This won't be modified.
- Returns:
- The excess ItemStackthat wasn't inserted.
 
- 
extractSingle@Deprecated(since="0.8.0", forRemoval=true) public static net.minecraft.item.ItemStack extractSingle(FixedItemInv inv, int slot, @Nullable ItemFilter filter, net.minecraft.item.ItemStack toAddWith, int maxAmount, Simulation simulation)Deprecated, for removal: This API element is subject to removal in a future version.Because this has been moved toFixedItemInv.extractStack(int, ItemFilter, ItemStack, int, Simulation).Extracts a single ItemStack from aFixedItemInv, using onlyFixedItemInv.setInvStack(int, ItemStack, Simulation). As such this is useful for implementations ofItemInsertable(or others) for the base implementation.- Parameters:
- filter- The filter to match on. If this is null then it will match any- ItemStack.
- toAddWith- An optional- ItemStackthat the extracted item will be added to.
- maxAmount- The maximum number of items to extract. Note that the returned- ItemStackmay have a higher amount than this if the given- ItemStackisn't empty.
- Returns:
- The extracted ItemStack, plus the parameter "toAddWith".
 
 
- 
PlayerInvUtil.createPlayerInsertable(PlayerEntity)instead