Class Inventory
java.lang.Object
net.minecraft.world.entity.player.Inventory
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.world.Container
Container.ContainerIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EntityEquipmentstatic final it.unimi.dsi.fastutil.ints.Int2ObjectMap<EquipmentSlot> static final intprivate final NonNullList<ItemStack> static final intfinal Playerstatic final intprivate intstatic final intstatic final intstatic final intstatic final intprivate intFields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the stack to the specified slot in the player's inventory.booleanAdds the stack to the first empty slot in the player's inventory.voidaddAndPickItem(ItemStack pStack) private intaddResource(int pSlot, ItemStack pStack) private intaddResource(ItemStack pStack) This function stores as many items of an ItemStack as possible in a matching slot and returns the quantity of left over items.voidintclearOrCountMatchingItems(Predicate<ItemStack> pStackPredicate, int pMaxCount, Container pInventory) booleanbooleanbooleanReturnstrueif the specifiedItemStackexists in the inventory.createInventoryUpdatePacket(int pSlot) voiddropAll()voidfillStackedContents(StackedItemContents pContents) intfindSlotMatchingCraftingIngredient(Holder<Item> pItem, ItemStack pStack) intfindSlotMatchingItem(ItemStack pStack) Finds the stack or an equivalent one in the main inventoryintintgetItem(int pIndex) Returns the stack in the given slot.getName()intstatic intintgetSlotWithRemainingSpace(ItemStack pStack) Stores a stack in the player's inventory.intintprivate booleanhasRemainingSpaceForItem(ItemStack pDestination, ItemStack pOrigin) booleanisEmpty()static booleanisHotbarSlot(int pIndex) static booleanisUsableForCrafting(ItemStack pStack) voidvoidpickSlot(int pIndex) voidplaceItemBackInInventory(ItemStack pStack) voidplaceItemBackInInventory(ItemStack pStack, boolean pSendPacket) removeFromSelected(boolean pRemoveStack) removeItem(int pIndex, int pCount) Removes up to a specified number of items from an inventory slot and returns them in a new stack.voidremoveItem(ItemStack pStack) removeItemNoUpdate(int pIndex) Removes a stack from the given slot and returns it.voidreplaceWith(Inventory pPlayerInventory) Copy the ItemStack contents from another InventoryPlayer instancevoidsave(ValueOutput.TypedOutputList<ItemStackWithSlot> pOutput) voidvoidSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).setSelectedItem(ItemStack pStack) voidsetSelectedSlot(int pSlot) booleanstillValid(Player pPlayer) Don't rename this method to canInteractWith due to conflicts with Containervoidtick()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.Container
canPlaceItem, canTakeItem, countItem, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, iterator, startOpen, stopOpenMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.minecraft.world.Nameable
getCustomName, getDisplayName, hasCustomName
-
Field Details
-
POP_TIME_DURATION
public static final int POP_TIME_DURATION- See Also:
-
INVENTORY_SIZE
public static final int INVENTORY_SIZE- See Also:
-
SELECTION_SIZE
public static final int SELECTION_SIZE- See Also:
-
SLOT_OFFHAND
public static final int SLOT_OFFHAND- See Also:
-
SLOT_BODY_ARMOR
public static final int SLOT_BODY_ARMOR- See Also:
-
SLOT_SADDLE
public static final int SLOT_SADDLE- See Also:
-
NOT_FOUND_INDEX
public static final int NOT_FOUND_INDEX- See Also:
-
EQUIPMENT_SLOT_MAPPING
-
items
-
selected
private int selected -
player
-
equipment
-
timesChanged
private int timesChanged
-
-
Constructor Details
-
Inventory
-
-
Method Details
-
getSelectedSlot
public int getSelectedSlot() -
setSelectedSlot
public void setSelectedSlot(int pSlot) -
getSelectedItem
-
setSelectedItem
-
getSelectionSize
public static int getSelectionSize() -
getNonEquipmentItems
-
hasRemainingSpaceForItem
-
getFreeSlot
public int getFreeSlot() -
addAndPickItem
-
pickSlot
public void pickSlot(int pIndex) -
isHotbarSlot
public static boolean isHotbarSlot(int pIndex) -
findSlotMatchingItem
Finds the stack or an equivalent one in the main inventory -
isUsableForCrafting
-
findSlotMatchingCraftingIngredient
-
getSuitableHotbarSlot
public int getSuitableHotbarSlot() -
clearOrCountMatchingItems
-
addResource
This function stores as many items of an ItemStack as possible in a matching slot and returns the quantity of left over items. -
addResource
-
getSlotWithRemainingSpace
Stores a stack in the player's inventory. It first tries to place it in the selected slot in the player's hotbar, then the offhand slot, then any available/empty slot in the player's inventory. -
tick
public void tick() -
add
Adds the stack to the first empty slot in the player's inventory. Returnsfalseif it's not possible to place the entire stack in the inventory. -
add
Adds the stack to the specified slot in the player's inventory. Returnsfalseif it's not possible to place the entire stack in the inventory. -
placeItemBackInInventory
-
placeItemBackInInventory
-
createInventoryUpdatePacket
-
removeItem
Removes up to a specified number of items from an inventory slot and returns them in a new stack.- Specified by:
removeItemin interfaceContainer
-
removeItem
-
removeItemNoUpdate
Removes a stack from the given slot and returns it.- Specified by:
removeItemNoUpdatein interfaceContainer
-
setItem
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). -
save
-
load
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSizein interfaceContainer
-
isEmpty
public boolean isEmpty() -
getItem
Returns the stack in the given slot. -
getName
-
dropAll
public void dropAll() -
setChanged
public void setChanged()- Specified by:
setChangedin interfaceContainer
-
getTimesChanged
public int getTimesChanged() -
stillValid
Don't rename this method to canInteractWith due to conflicts with Container- Specified by:
stillValidin interfaceContainer
-
contains
Returnstrueif the specifiedItemStackexists in the inventory. -
contains
-
contains
-
replaceWith
Copy the ItemStack contents from another InventoryPlayer instance -
clearContent
public void clearContent()- Specified by:
clearContentin interfaceClearable
-
fillStackedContents
-
removeFromSelected
- Parameters:
pRemoveStack- Whether to remove the entire stack of items. Iffalse, removes a single item.
-