Package alexiil.mc.lib.attributes.misc
Class PlayerInvUtil
java.lang.Object
alexiil.mc.lib.attributes.misc.PlayerInvUtil
public final class PlayerInvUtil
extends java.lang.Object
-
Method Summary
Modifier and Type Method Description static java.util.function.Consumer<net.minecraft.item.ItemStack>createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)Returns aConsumerthat will callinsertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity, net.minecraft.item.ItemStack)for everyItemStackpassed to it.static voidinsertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack stack)Either inserts the given item into the player's inventory or drops it in front of them.static Reference<net.minecraft.item.ItemStack>referenceGuiCursor(net.minecraft.server.network.ServerPlayerEntity player)Creates aReferenceto the given player'scursor stack, that updates the client whenever it is changed.static Reference<net.minecraft.item.ItemStack>referenceHand(net.minecraft.entity.player.PlayerEntity player, net.minecraft.util.Hand hand)Creates aReferenceto the what the player is currently holding in the givenHand.static Reference<net.minecraft.item.ItemStack>referenceSlot(net.minecraft.screen.slot.Slot slot)Creates aReferenceto the givenSlot.
-
Method Details
-
insertItemIntoPlayerInventory
public static void insertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack stack)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!) -
referenceGuiCursor
public static Reference<net.minecraft.item.ItemStack> referenceGuiCursor(net.minecraft.server.network.ServerPlayerEntity player)Creates aReferenceto the given player'scursor stack, that updates the client whenever it is changed. -
referenceHand
public static Reference<net.minecraft.item.ItemStack> referenceHand(net.minecraft.entity.player.PlayerEntity player, net.minecraft.util.Hand hand)Creates aReferenceto the what the player is currently holding in the givenHand. -
referenceSlot
public static Reference<net.minecraft.item.ItemStack> referenceSlot(net.minecraft.screen.slot.Slot slot)Creates aReferenceto the givenSlot. If the slot is an instance ofStackReference, or isConvertible.getAs(Object, Class)to one, then that is returned. -
createPlayerInsertable
public static java.util.function.Consumer<net.minecraft.item.ItemStack> createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)Returns aConsumerthat will callinsertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity, net.minecraft.item.ItemStack)for everyItemStackpassed to it.
-