Class PlayerInvUtil

java.lang.Object
alexiil.mc.lib.attributes.misc.PlayerInvUtil

public final class PlayerInvUtil extends Object
Various methods for getting Reference's and Consumer's from a PlayerEntity's various inventories.
  • 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 a Reference to the given player's cursor 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 a Reference to the what the player is currently holding in the given Hand.
    • referenceSlot

      public static Reference<net.minecraft.item.ItemStack> referenceSlot(net.minecraft.screen.slot.Slot slot)
      Creates a Reference to the given Slot. If the slot is an instance of StackReference, or is Convertible.getAs(Object, Class) to one, then that is returned.
    • createPlayerInsertable

      public static Consumer<net.minecraft.item.ItemStack> createPlayerInsertable(net.minecraft.entity.player.PlayerEntity player)