Class SingleFluidStorage
java.lang.Object
net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant<ResourceAmount<FluidVariant>>
net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage<FluidVariant>
net.fabricmc.fabric.api.transfer.v1.fluid.base.SingleFluidStorage
- All Implemented Interfaces:
Iterable<StorageView<FluidVariant>>
,SingleSlotStorage<FluidVariant>
,SlottedStorage<FluidVariant>
,Storage<FluidVariant>
,StorageView<FluidVariant>
,TransactionContext.CloseCallback
,TransactionContext.OuterCloseCallback
A storage that can store a single fluid variant at any given time.
Implementors should at least override
getCapacity(FluidVariant)
,
and probably SnapshotParticipant.onFinalCommit()
as well for markDirty()
and similar calls.
This is a convenient specialization of SingleVariantStorage
for fluids that additionally offers methods
to read the contents of the storage from NBT.
-
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 FluidVariant
Return the blank variant.void
readNbt
(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) Simple implementation of reading from NBT, to match what is written bywriteNbt(net.minecraft.nbt.NbtCompound, net.minecraft.registry.RegistryWrapper.WrapperLookup)
.static SingleFluidStorage
withFixedCapacity
(long capacity, Runnable onChange) Create a fluid storage with a fixed capacity and a change handler.void
writeNbt
(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) Simple implementation of writing to NBT.Methods inherited from class net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage
canExtract, canInsert, createSnapshot, extract, getAmount, getCapacity, getCapacity, getResource, insert, isResourceBlank, readNbt, 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
getVersion, nonEmptyIterator, nonEmptyViews, supportsExtraction, supportsInsertion
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.StorageView
getUnderlyingView
-
Constructor Details
-
SingleFluidStorage
public SingleFluidStorage()
-
-
Method Details
-
withFixedCapacity
Create a fluid storage with a fixed capacity and a change handler.- Parameters:
capacity
- Fixed capacity of the fluid storage. Must be non-negative.onChange
- Change handler, generally formarkDirty()
or similar calls. May not be null.
-
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<FluidVariant>
-
readNbt
Simple implementation of reading from NBT, to match what is written bywriteNbt(net.minecraft.nbt.NbtCompound, net.minecraft.registry.RegistryWrapper.WrapperLookup)
. Other formats are allowed, this is just a suggestion. -
writeNbt
Simple implementation of writing to NBT. Other formats are allowed, this is just a convenient suggestion.
-