Class PlayerInventory

java.lang.Object
net.minecraft.entity.player.PlayerInventory
All Implemented Interfaces:
Inventory, Clearable, Nameable

public class PlayerInventory
extends Object
implements Inventory, Nameable
  • Field Details

  • Constructor Details

    • PlayerInventory

      public PlayerInventory​(PlayerEntity player)
  • Method Details

    • getMainHandStack

      public ItemStack getMainHandStack()
    • getHotbarSize

      public static int getHotbarSize()
    • canStackAddMore

      private boolean canStackAddMore​(ItemStack existingStack, ItemStack stack)
    • areItemsEqual

      private boolean areItemsEqual​(ItemStack stack1, ItemStack stack2)
    • getEmptySlot

      public int getEmptySlot()
    • addPickBlock

      @Environment(CLIENT) public void addPickBlock​(ItemStack stack)
    • swapSlotWithHotbar

      public void swapSlotWithHotbar​(int hotbarSlot)
    • isValidHotbarIndex

      public static boolean isValidHotbarIndex​(int slot)
    • getSlotWithStack

      @Environment(CLIENT) public int getSlotWithStack​(ItemStack stack)
    • method_7371

      public int method_7371​(ItemStack itemStack)
    • getSwappableHotbarSlot

      public int getSwappableHotbarSlot()
    • scrollInHotbar

      @Environment(CLIENT) public void scrollInHotbar​(double scrollAmount)
    • remove

      public int remove​(Predicate<ItemStack> shouldRemove, int maxCount, Inventory craftingInventory)
    • addStack

      private int addStack​(ItemStack stack)
    • addStack

      private int addStack​(int slot, ItemStack stack)
    • getOccupiedSlotWithRoomForStack

      public int getOccupiedSlotWithRoomForStack​(ItemStack stack)
    • updateItems

      public void updateItems()
    • insertStack

      public boolean insertStack​(ItemStack stack)
    • insertStack

      public boolean insertStack​(int slot, ItemStack stack)
    • offerOrDrop

      public void offerOrDrop​(World world, ItemStack stack)
    • removeStack

      public ItemStack removeStack​(int slot, int amount)
      Removes a specific number of items from the given slot.
      Specified by:
      removeStack in interface Inventory
      Returns:
      the removed items as a stack
    • removeOne

      public void removeOne​(ItemStack stack)
    • removeStack

      public ItemStack removeStack​(int slot)
      Removes the stack currently stored at the indicated slot.
      Specified by:
      removeStack in interface Inventory
      Returns:
      the stack previously stored at the indicated slot.
    • setStack

      public void setStack​(int slot, ItemStack stack)
      Specified by:
      setStack in interface Inventory
    • getBlockBreakingSpeed

      public float getBlockBreakingSpeed​(BlockState block)
    • serialize

      public ListTag serialize​(ListTag tag)
    • deserialize

      public void deserialize​(ListTag tag)
    • size

      public int size()
      Specified by:
      size in interface Inventory
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Inventory
    • getStack

      public ItemStack getStack​(int slot)
      Fetches the stack currently stored at the given slot. If the slot is empty, or is outside the bounds of this inventory, returns see ItemStack.EMPTY.
      Specified by:
      getStack in interface Inventory
    • getName

      public Text getName()
      Specified by:
      getName in interface Nameable
    • getArmorStack

      @Environment(CLIENT) public ItemStack getArmorStack​(int slot)
    • damageArmor

      public void damageArmor​(DamageSource damageSource, float float2)
    • dropAll

      public void dropAll()
    • markDirty

      public void markDirty()
      Specified by:
      markDirty in interface Inventory
    • getChangeCount

      @Environment(CLIENT) public int getChangeCount()
    • setCursorStack

      public void setCursorStack​(ItemStack stack)
    • getCursorStack

      public ItemStack getCursorStack()
    • canPlayerUse

      public boolean canPlayerUse​(PlayerEntity player)
      Specified by:
      canPlayerUse in interface Inventory
    • contains

      public boolean contains​(ItemStack stack)
    • contains

      @Environment(CLIENT) public boolean contains​(Tag<Item> tag)
    • clone

      public void clone​(PlayerInventory other)
    • clear

      public void clear()
      Specified by:
      clear in interface Clearable
    • populateRecipeFinder

      public void populateRecipeFinder​(RecipeFinder finder)