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>armorprivate intchangeCountprivate List<DefaultedList<ItemStack>>combinedInventoryprivate ItemStackcursorStackDefaultedList<ItemStack>mainDefaultedList<ItemStack>offHandPlayerEntityplayerintselectedSlot -
Constructor Summary
Constructors Constructor Description PlayerInventory(PlayerEntity player) -
Method Summary
Modifier and Type Method Description voidaddPickBlock(ItemStack stack)private intaddStack(int slot, ItemStack stack)private intaddStack(ItemStack stack)booleancanPlayerUse(PlayerEntity player)private booleancanStackAddMore(ItemStack existingStack, ItemStack stack)voidclear()voidclone(PlayerInventory other)booleancontains(ItemStack stack)booleancontains(Tag<Item> tag)voiddamageArmor(DamageSource damageSource, float float2)voiddeserialize(ListTag tag)voiddropAll()ItemStackgetArmorStack(int slot)floatgetBlockBreakingSpeed(BlockState block)intgetChangeCount()ItemStackgetCursorStack()intgetEmptySlot()static intgetHotbarSize()ItemStackgetMainHandStack()TextgetName()intgetOccupiedSlotWithRoomForStack(ItemStack stack)intgetSlotWithStack(ItemStack itemStack)ItemStackgetStack(int slot)Fetches the stack currently stored at the given slot.intgetSwappableHotbarSlot()intindexOf(ItemStack stack)booleaninsertStack(int slot, ItemStack stack)booleaninsertStack(ItemStack stack)booleanisEmpty()static booleanisValidHotbarIndex(int slot)voidmarkDirty()voidmethod_32338(ItemStack itemStack, boolean bool)voidofferOrDrop(ItemStack itemStack)voidpopulateRecipeFinder(RecipeFinder finder)intremove(Predicate<ItemStack> shouldRemove, int maxCount, Inventory craftingInventory)voidremoveOne(ItemStack stack)ItemStackremoveStack(int slot)Removes the stack currently stored at the indicated slot.ItemStackremoveStack(int slot, int amount)Removes a specific number of items from the given slot.voidscrollInHotbar(double scrollAmount)ListTagserialize(ListTag tag)voidsetCursorStack(ItemStack stack)voidsetStack(int slot, ItemStack stack)intsize()voidswapSlotWithHotbar(int hotbarSlot)voidupdateItems()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.inventory.Inventory
containsAny, count, getMaxCountPerStack, isValid, onClose, onOpenMethods 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
-
getEmptySlot
public int getEmptySlot() -
addPickBlock
-
swapSlotWithHotbar
public void swapSlotWithHotbar(int hotbarSlot) -
isValidHotbarIndex
public static boolean isValidHotbarIndex(int slot) -
getSlotWithStack
-
indexOf
-
getSwappableHotbarSlot
public int getSwappableHotbarSlot() -
scrollInHotbar
@Environment(CLIENT) public void scrollInHotbar(double scrollAmount) -
remove
-
addStack
-
addStack
-
getOccupiedSlotWithRoomForStack
-
updateItems
public void updateItems() -
insertStack
-
insertStack
-
offerOrDrop
-
method_32338
-
removeStack
Removes a specific number of items from the given slot.- Specified by:
removeStackin interfaceInventory- Returns:
- the removed items as a stack
-
removeOne
-
removeStack
Removes the stack currently stored at the indicated slot.- Specified by:
removeStackin 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:
canPlayerUsein interfaceInventory
-
contains
-
contains
-
clone
-
clear
public void clear() -
populateRecipeFinder
-