Package net.minecraft.entity.player
Class PlayerInventory
java.lang.Object
net.minecraft.entity.player.PlayerInventory
public class PlayerInventory extends Object implements Inventory, Nameable
-
Field Summary
Fields Modifier and Type Field Description DefaultedList<ItemStack>
armor
private int
changeCount
private List<DefaultedList<ItemStack>>
combinedInventory
private ItemStack
cursorStack
DefaultedList<ItemStack>
main
DefaultedList<ItemStack>
offHand
PlayerEntity
player
int
selectedSlot
-
Constructor Summary
Constructors Constructor Description PlayerInventory(PlayerEntity player)
-
Method Summary
Modifier and Type Method Description void
addPickBlock(ItemStack stack)
private int
addStack(int slot, ItemStack stack)
private int
addStack(ItemStack stack)
private boolean
areItemsEqual(ItemStack stack1, ItemStack stack2)
boolean
canPlayerUse(PlayerEntity player)
private boolean
canStackAddMore(ItemStack existingStack, ItemStack stack)
void
clear()
void
clone(PlayerInventory other)
boolean
contains(ItemStack stack)
boolean
contains(Tag<Item> tag)
void
damageArmor(DamageSource damageSource, float float2)
void
deserialize(ListTag tag)
void
dropAll()
ItemStack
getArmorStack(int slot)
float
getBlockBreakingSpeed(BlockState block)
int
getChangeCount()
ItemStack
getCursorStack()
int
getEmptySlot()
static int
getHotbarSize()
ItemStack
getMainHandStack()
Text
getName()
int
getOccupiedSlotWithRoomForStack(ItemStack stack)
int
getSlotWithStack(ItemStack stack)
ItemStack
getStack(int slot)
Fetches the stack currently stored at the given slot.int
getSwappableHotbarSlot()
boolean
insertStack(int slot, ItemStack stack)
boolean
insertStack(ItemStack stack)
boolean
isEmpty()
static boolean
isValidHotbarIndex(int slot)
void
markDirty()
int
method_7371(ItemStack itemStack)
void
offerOrDrop(World world, ItemStack stack)
void
populateRecipeFinder(RecipeFinder finder)
int
remove(Predicate<ItemStack> shouldRemove, int maxCount, Inventory craftingInventory)
void
removeOne(ItemStack stack)
ItemStack
removeStack(int slot)
Removes the stack currently stored at the indicated slot.ItemStack
removeStack(int slot, int amount)
Removes a specific number of items from the given slot.void
scrollInHotbar(double scrollAmount)
ListTag
serialize(ListTag tag)
void
setCursorStack(ItemStack stack)
void
setStack(int slot, ItemStack stack)
int
size()
void
swapSlotWithHotbar(int hotbarSlot)
void
updateItems()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.inventory.Inventory
containsAny, count, getMaxCountPerStack, isValid, onClose, onOpen
Methods inherited from interface net.minecraft.util.Nameable
getCustomName, getDisplayName, hasCustomName
-
Field Details
-
main
-
armor
-
offHand
-
combinedInventory
-
selectedSlot
public int selectedSlot -
player
-
cursorStack
-
changeCount
private int changeCount
-
-
Constructor Details
-
PlayerInventory
-
-
Method Details
-
getMainHandStack
-
getHotbarSize
public static int getHotbarSize() -
canStackAddMore
-
areItemsEqual
-
getEmptySlot
public int getEmptySlot() -
addPickBlock
-
swapSlotWithHotbar
public void swapSlotWithHotbar(int hotbarSlot) -
isValidHotbarIndex
public static boolean isValidHotbarIndex(int slot) -
getSlotWithStack
-
method_7371
-
getSwappableHotbarSlot
public int getSwappableHotbarSlot() -
scrollInHotbar
@Environment(CLIENT) public void scrollInHotbar(double scrollAmount) -
remove
-
addStack
-
addStack
-
getOccupiedSlotWithRoomForStack
-
updateItems
public void updateItems() -
insertStack
-
insertStack
-
offerOrDrop
-
removeStack
Removes a specific number of items from the given slot.- Specified by:
removeStack
in interfaceInventory
- Returns:
- the removed items as a stack
-
removeOne
-
removeStack
Removes the stack currently stored at the indicated slot.- Specified by:
removeStack
in interfaceInventory
- Returns:
- the stack previously stored at the indicated slot.
-
setStack
-
getBlockBreakingSpeed
-
serialize
-
deserialize
-
size
public int size() -
isEmpty
public boolean isEmpty() -
getStack
Fetches the stack currently stored at the given slot. If the slot is empty, or is outside the bounds of this inventory, returns seeItemStack.EMPTY
. -
getName
-
getArmorStack
-
damageArmor
-
dropAll
public void dropAll() -
markDirty
public void markDirty() -
getChangeCount
@Environment(CLIENT) public int getChangeCount() -
setCursorStack
-
getCursorStack
-
canPlayerUse
- Specified by:
canPlayerUse
in interfaceInventory
-
contains
-
contains
-
clone
-
clear
public void clear() -
populateRecipeFinder
-