Class SingleItemStorage
java.lang.Object
net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant<ResourceAmount<ItemVariant>>
net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage<ItemVariant>
net.fabricmc.fabric.api.transfer.v1.item.base.SingleItemStorage
- All Implemented Interfaces:
Iterable<StorageView<ItemVariant>>, SingleSlotStorage<ItemVariant>, SlottedStorage<ItemVariant>, Storage<ItemVariant>, StorageView<ItemVariant>, TransactionContext.CloseCallback, TransactionContext.OuterCloseCallback
A storage that can store a single item variant at any given time.
Implementors should at least override
getCapacity(ItemVariant),
and probably SnapshotParticipant.onFinalCommit() as well for setChanged() and similar calls.
This is a convenient specialization of SingleVariantStorage for items that additionally offers methods
to deserialize the contents of the storage.
-
Field Summary
Fields inherited from class SingleVariantStorage
amount, variant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final ItemVariantReturn the blank variant.voidreadValue(net.minecraft.world.level.storage.ValueInput data) Simple implementation of reading fromValueInput, to match what is written bywriteValue(ValueOutput).voidwriteValue(net.minecraft.world.level.storage.ValueOutput data) Simple implementation of writing toValueOutput.Methods inherited from class SingleVariantStorage
canExtract, canInsert, createSnapshot, extract, getAmount, getCapacity, getCapacity, getResource, insert, isResourceBlank, readSnapshot, readValue, toString, writeValueMethods inherited from class SnapshotParticipant
afterOuterClose, onClose, onFinalCommit, releaseSnapshot, updateSnapshotsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface SingleSlotStorage
getSlot, getSlotCount, iteratorMethods inherited from interface SlottedStorage
getSlotsMethods inherited from interface Storage
getVersion, nonEmptyIterator, nonEmptyViews, supportsExtraction, supportsInsertionMethods inherited from interface StorageView
getUnderlyingView
-
Constructor Details
-
SingleItemStorage
public SingleItemStorage()
-
-
Method Details
-
getBlankVariant
Description copied from class:SingleVariantStorageReturn the blank variant.Note: this is called very early in the constructor. If fields need to be accessed from this function, make sure to re-initialize
SingleVariantStorage.variantyourself.- Specified by:
getBlankVariantin classSingleVariantStorage<ItemVariant>
-
readValue
public void readValue(net.minecraft.world.level.storage.ValueInput data) Simple implementation of reading fromValueInput, to match what is written bywriteValue(ValueOutput). Other formats are allowed, this is just a suggestion. -
writeValue
public void writeValue(net.minecraft.world.level.storage.ValueOutput data) Simple implementation of writing toValueOutput. Other formats are allowed, this is just a suggestion.
-