Class PlayerInventoryWrapper
java.lang.Object
net.neoforged.neoforge.transfer.item.VanillaContainerWrapper
net.neoforged.neoforge.transfer.item.PlayerInventoryWrapper
- All Implemented Interfaces:
ResourceHandler<ItemResource>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classSpecialized slot wrapper for one of the armor slots.private classNested classes/interfaces inherited from class net.neoforged.neoforge.transfer.item.VanillaContainerWrapper
VanillaContainerWrapper.SlotWrapper -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PlayerInventoryWrapper.DroppedItemsprivate final InventoryFields inherited from class net.neoforged.neoforge.transfer.item.VanillaContainerWrapper
size, slotWrappers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddrop(ItemResource resource, int amount, boolean dropAround, boolean includeThrowerName, TransactionContext transaction) Transactionally drops an item in the world.getArmorSlot(EquipmentSlot slot) Retrieves a wrapper around a single armor slot.Retrieves a wrapper around all 4 armor slots.getHandSlot(InteractionHand hand) Retrieves a wrapper for the slot corresponding to the given hand.Retrieves a wrapper around both hand slots.Retrieves a wrapper for the slot corresponding to the current main hand.Retrieves a wrapper around the main slots only.getSlot(int slot) Retrieves a wrapper for a specific slot.intinsert(ItemResource resource, int amount, TransactionContext transaction) Inserts items into this player inventory, trying to place items following the logic ofInventory.placeItemBackInInventory(net.minecraft.world.item.ItemStack).static PlayerInventoryWrapperGets the inventory wrapper for a player'sInventory.static PlayerInventoryWrapperGets the inventory wrapper for aPlayer.(package private) voidvoidplaceItemBackInInventory(ItemResource resource, int amount, TransactionContext transactionContext) Transactional version ofInventory.placeItemBackInInventory(net.minecraft.world.item.ItemStack): tries to insert as much as possible into the player inventory, and drops the remainder.(package private) voidresize()toString()Methods inherited from class net.neoforged.neoforge.transfer.item.VanillaContainerWrapper
extract, getAmountAsLong, getCapacityAsLong, getResource, getSlotWrapper, insert, internalOf, isValid, of, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.transfer.ResourceHandler
extract, getAmountAsInt, getCapacityAsInt
-
Field Details
-
droppedItems
-
inventory
-
-
Constructor Details
-
PlayerInventoryWrapper
PlayerInventoryWrapper(Inventory inventory)
-
-
Method Details
-
of
Gets the inventory wrapper for aPlayer. -
of
Gets the inventory wrapper for a player'sInventory. -
resize
void resize()- Overrides:
resizein classVanillaContainerWrapper
-
onRootCommit
void onRootCommit()- Overrides:
onRootCommitin classVanillaContainerWrapper
-
getSlot
Retrieves a wrapper for a specific slot. -
getMainHandSlot
Retrieves a wrapper for the slot corresponding to the current main hand. -
getHandSlot
Retrieves a wrapper for the slot corresponding to the given hand. -
getHandSlots
Retrieves a wrapper around both hand slots. -
getMainSlots
Retrieves a wrapper around the main slots only. -
getArmorSlot
Retrieves a wrapper around a single armor slot. -
getArmorSlots
Retrieves a wrapper around all 4 armor slots. -
insert
Inserts items into this player inventory, trying to place items following the logic ofInventory.placeItemBackInInventory(net.minecraft.world.item.ItemStack).- Parameters:
resource- The resource to insert. Must be non-empty.amount- The maximum amount of the resource to insert. Must be non-negative.transaction- The transaction that this operation is part of.- Returns:
- The amount that was inserted. Between
0(inclusive, nothing was inserted) andamount(inclusive, everything was inserted). - See Also:
-
placeItemBackInInventory
public void placeItemBackInInventory(ItemResource resource, int amount, TransactionContext transactionContext) Transactional version ofInventory.placeItemBackInInventory(net.minecraft.world.item.ItemStack): tries to insert as much as possible into the player inventory, and drops the remainder. -
drop
public void drop(ItemResource resource, int amount, boolean dropAround, boolean includeThrowerName, TransactionContext transaction) Transactionally drops an item in the world. -
toString
- Overrides:
toStringin classVanillaContainerWrapper
-