Class PlayerInventoryWrapper.ArmorSlotWrapper
java.lang.Object
net.neoforged.neoforge.transfer.transaction.SnapshotJournal<ItemStack>
net.neoforged.neoforge.transfer.item.ItemStackResourceHandler
net.neoforged.neoforge.transfer.item.VanillaContainerWrapper.SlotWrapper
net.neoforged.neoforge.transfer.item.PlayerInventoryWrapper.ArmorSlotWrapper
- All Implemented Interfaces:
ValueIOSerializable, ResourceHandler<ItemResource>
- Enclosing class:
PlayerInventoryWrapper
Specialized slot wrapper for one of the armor slots.
Limits size to 1, disallows insertion of non-equippable items, and extraction of cursed items for non-creative players.
-
Field Summary
FieldsFields inherited from class ItemStackResourceHandler
VALUE_IO_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintextract(int index, ItemResource resource, int amount, TransactionContext transaction) Extracts up to the given amount of a resource from the handler at the given index.protected intgetCapacity(ItemResource resource) Special cases because vanilla checks the current stack in the following functions (which it shouldn't):AbstractFurnaceBlockEntity.canPlaceItem(int, ItemStack).BrewingStandBlockEntity.canPlaceItem(int, ItemStack).protected booleanisValid(ItemResource resource) Returntrueif the passed non-empty item resource can fit in this handler,falseotherwise.Methods inherited from class VanillaContainerWrapper.SlotWrapper
getStack, insert, onRootCommit, setStack, toString, updateSnapshotsMethods inherited from class ItemStackResourceHandler
createSnapshot, deserialize, getAmountAsLong, getCapacityAsLong, getResource, isValid, revertToSnapshot, serialize, sizeMethods inherited from class SnapshotJournal
releaseSnapshotMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceHandler
extract, getAmountAsInt, getCapacityAsInt, insert
-
Field Details
-
slot
-
-
Constructor Details
-
ArmorSlotWrapper
ArmorSlotWrapper(int index, EquipmentSlot slot)
-
-
Method Details
-
isValid
Description copied from class:ItemStackResourceHandlerReturntrueif the passed non-empty item resource can fit in this handler,falseotherwise.The result of this function is used in the provided implementations of:
ItemStackResourceHandler.isValid(int, ItemResource), to report which items are valid;ItemStackResourceHandler.getCapacityAsLong(int, ItemResource), to report a capacity of0for invalid items;ItemStackResourceHandler.insert(int, ItemResource, int, TransactionContext), to reject items that cannot fit in this handler.
- Overrides:
isValidin classVanillaContainerWrapper.SlotWrapper
-
getCapacity
Description copied from class:VanillaContainerWrapper.SlotWrapperSpecial cases because vanilla checks the current stack in the following functions (which it shouldn't):AbstractFurnaceBlockEntity.canPlaceItem(int, ItemStack).BrewingStandBlockEntity.canPlaceItem(int, ItemStack).
Should these extra checks cause performance issues, we can switch to subclasses.
- Overrides:
getCapacityin classVanillaContainerWrapper.SlotWrapper- Returns:
- The maximum capacity of this handler for the passed item resource.
-
extract
Description copied from interface:ResourceHandlerExtracts up to the given amount of a resource from the handler at the given index.Changes to the handler are made in the context of a transaction.
- Specified by:
extractin interfaceResourceHandler<ItemResource>- Overrides:
extractin classVanillaContainerWrapper.SlotWrapper- Parameters:
index- The index to extract the resource from.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). - See Also:
-