Record Class OneByOneItemAccess
java.lang.Object
java.lang.Record
net.neoforged.neoforge.transfer.access.OneByOneItemAccess
- All Implemented Interfaces:
ItemAccess
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ItemAccessThe field for thedelegaterecord component. -
Constructor Summary
ConstructorsConstructorDescriptionOneByOneItemAccess(ItemAccess delegate) Creates an instance of aOneByOneItemAccessrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondelegate()Returns the value of thedelegaterecord component.final booleanIndicates whether some other object is "equal to" this one.intextract(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.final inthashCode()Returns a hash code value for this object.intinsert(ItemResource resource, int amount, TransactionContext transaction) Inserts up to the given amount of an item resource into the accessed location.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.transfer.access.ItemAccess
exchange, getCapability, oneByOne
-
Field Details
-
delegate
The field for thedelegaterecord component.
-
-
Constructor Details
-
OneByOneItemAccess
OneByOneItemAccess(ItemAccess delegate) Creates an instance of aOneByOneItemAccessrecord class.- Parameters:
delegate- the value for thedelegaterecord component
-
-
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).
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
delegate
Returns the value of thedelegaterecord component.- Returns:
- the value of the
delegaterecord component
-