Class CarriedSlotWrapper
java.lang.Object
net.neoforged.neoforge.transfer.transaction.SnapshotJournal<ItemStack>
net.neoforged.neoforge.transfer.item.ItemStackResourceHandler
net.neoforged.neoforge.transfer.item.CarriedSlotWrapper
- All Implemented Interfaces:
ValueIOSerializable, ResourceHandler<ItemResource>
ResourceHandler<ItemResource> implementation for the carried slot of an AbstractContainerMenu.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AbstractContainerMenuprivate static final Map<AbstractContainerMenu, CarriedSlotWrapper> SeeVanillaContainerWrapper.wrapperswhich is similar.Fields inherited from class ItemStackResourceHandler
VALUE_IO_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ItemStackgetStack()Return the stack of this handler.static ResourceHandler<ItemResource> of(AbstractContainerMenu menu) Return a wrapper around the carried slot of a menu, i.e. the stack that can be manipulated withAbstractContainerMenu.getCarried()andAbstractContainerMenu.setCarried(ItemStack).protected voidSet the stack of this handler.toString()Methods inherited from class ItemStackResourceHandler
createSnapshot, deserialize, extract, getAmountAsLong, getCapacity, getCapacityAsLong, getResource, insert, isValid, isValid, revertToSnapshot, serialize, sizeMethods inherited from class SnapshotJournal
onRootCommit, releaseSnapshot, updateSnapshotsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceHandler
extract, getAmountAsInt, getCapacityAsInt, insert
-
Field Details
-
wrappers
SeeVanillaContainerWrapper.wrapperswhich is similar.We use weak keys and values to avoid keeping a strong reference to the
AbstractContainerMenuuntil the next time the map is cleaned. As long as a wrapper is used, there is a strong reference to theAbstractContainerMenuclass, which ensures that the entries remain in the map at least as long as the wrappers are in use.
-
-
Constructor Details
-
CarriedSlotWrapper
-
-
Method Details
-
of
Return a wrapper around the carried slot of a menu, i.e. the stack that can be manipulated withAbstractContainerMenu.getCarried()andAbstractContainerMenu.setCarried(ItemStack). -
getStack
Description copied from class:ItemStackResourceHandlerReturn the stack of this handler. It will be modified directly sometimes to avoid needless copies. However, any mutation of the stack will directly be followed by a call toItemStackResourceHandler.setStack(ItemStack). This means that either returning the backing stack directly or a copy is safe. If returning a copy, consider overridingItemStackResourceHandler.getAmountAsLong(int)andItemStackResourceHandler.getResource(int)to avoid unnecessary copies.- Specified by:
getStackin classItemStackResourceHandler- Returns:
- The current stack.
-
setStack
Description copied from class:ItemStackResourceHandlerSet the stack of this handler.- Specified by:
setStackin classItemStackResourceHandler
-
toString
- Overrides:
toStringin classItemStackResourceHandler
-