Class SingleItemStorage
java.lang.Object
net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant<ResourceAmount<T>>
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 markDirty()
and similar calls.
This is a convenient specialization of SingleVariantStorage
for items that additionally offers methods
to read the contents of the storage from NBT.
Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
-
Field Summary
Fields inherited from class net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage
amount, variant
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final ItemVariant
Return the blank variant.void
readNbt
(NbtCompound nbt) Simple implementation of reading from NBT, to match what is written bySingleVariantStorage.writeNbt(net.minecraft.nbt.NbtCompound)
.Methods inherited from class net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage
canExtract, canInsert, createSnapshot, extract, getAmount, getCapacity, getCapacity, getResource, insert, isResourceBlank, readSnapshot, toString, writeNbt
Methods inherited from class net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant
afterOuterClose, onClose, onFinalCommit, releaseSnapshot, updateSnapshots
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage
getSlot, getSlotCount, iterator
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage
getSlots
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.Storage
exactView, getVersion, nonEmptyIterator, nonEmptyViews, simulateExtract, simulateInsert, supportsExtraction, supportsInsertion
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.StorageView
getUnderlyingView
-
Constructor Details
-
SingleItemStorage
public SingleItemStorage()
-
-
Method Details
-
getBlankVariant
Description copied from class:SingleVariantStorage
Return 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.variant
yourself.- Specified by:
getBlankVariant
in classSingleVariantStorage<ItemVariant>
-
readNbt
Simple implementation of reading from NBT, to match what is written bySingleVariantStorage.writeNbt(net.minecraft.nbt.NbtCompound)
. Other formats are allowed, this is just a suggestion.
-