Package alexiil.mc.lib.attributes.misc
Class PlayerInvUtil
java.lang.Object
alexiil.mc.lib.attributes.misc.PlayerInvUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic Consumer<net.minecraft.item.ItemStack>
createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)
Returns aConsumer
that will callinsertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity, net.minecraft.item.ItemStack)
for everyItemStack
passed to it.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.static Reference<net.minecraft.item.ItemStack>
referenceGuiCursor(net.minecraft.server.network.ServerPlayerEntity player)
Creates aReference
to 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 aReference
to the what the player is currently holding in the givenHand
.static Reference<net.minecraft.item.ItemStack>
referenceSlot(net.minecraft.screen.slot.Slot slot)
Creates aReference
to 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 aReference
to 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 aReference
to 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 aReference
to the givenSlot
. If the slot is an instance ofStackReference
, or isConvertible.getAs(Object, Class)
to one, then that is returned. -
createPlayerInsertable
public static Consumer<net.minecraft.item.ItemStack> createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)Returns aConsumer
that will callinsertItemIntoPlayerInventory(net.minecraft.entity.player.PlayerEntity, net.minecraft.item.ItemStack)
for everyItemStack
passed to it.
-