Class PlayerItemAccess
java.lang.Object
net.neoforged.neoforge.transfer.access.PlayerItemAccess
- All Implemented Interfaces:
ItemAccess
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PlayerInventoryWrapperprivate final ResourceHandler<ItemResource> -
Constructor Summary
ConstructorsConstructorDescriptionPlayerItemAccess(PlayerInventoryWrapper inventoryWrapper, ResourceHandler<ItemResource> slot) -
Method Summary
Modifier and TypeMethodDescriptionintextract(ItemResource resource, int amount, TransactionContext transaction) Extracts up to the given amount of an item resource from the accessed location.intReturns the currently stored amount of the current resource.Returns the currently stored item resource.intinsert(ItemResource resource, int amount, TransactionContext transaction) Inserts up to the given amount of an item resource into the accessed location.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.transfer.access.ItemAccess
exchange, getCapability, oneByOne
-
Field Details
-
inventoryWrapper
-
slot
-
-
Constructor Details
-
PlayerItemAccess
public PlayerItemAccess(PlayerInventoryWrapper inventoryWrapper, ResourceHandler<ItemResource> slot)
-
-
Method Details
-
getResource
Description copied from interface:ItemAccessReturns the currently stored item resource.- Specified by:
getResourcein interfaceItemAccess
-
getAmount
public int getAmount()Description copied from interface:ItemAccessReturns the currently stored amount of the current resource.The returned amount must be non-negative. If the stored resource is empty, the amount must be 0.
- Specified by:
getAmountin interfaceItemAccess
-
insert
Description copied from interface:ItemAccessInserts up to the given amount of an item resource into the accessed location.If the inserted item is not stackable with the current item, it may be inserted in a place that is inaccessible by
ItemAccess.extract(net.neoforged.neoforge.transfer.item.ItemResource, int, net.neoforged.neoforge.transfer.transaction.TransactionContext), such as the player inventory.Changes to the accessed location are made in the context of a transaction.
- Specified by:
insertin interfaceItemAccess- 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).
-
extract
Description copied from interface:ItemAccessExtracts up to the given amount of an item resource from the accessed location.Changes to the accessed location are made in the context of a transaction.
- Specified by:
extractin interfaceItemAccess- Parameters:
resource- The resource to extract. Must be non-empty.amount- The maximum amount of the resource to extract. Must be non-negative.transaction- The transaction that this operation is part of.- Returns:
- The amount that was extracted. Between
0(inclusive, nothing was extracted) andamount(inclusive, everything was extracted).
-