Class SimpleFixedFluidInv
- All Implemented Interfaces:
Convertible,FixedFluidInv,FixedFluidInvView,FluidExtractable,FluidInsertable,FluidTransferable,LimitedConsumer<FluidVolume>,Saveable
- Direct Known Subclasses:
JumboFixedFluidInv
FixedFluidInv
exposes.
Extending classes should take care to override getFilterForTank(int) if they also override
isFluidValidForTank(int, FluidKey).
Note: Generally it is better to extend JumboFixedFluidInv for inventories with a large number of similar
tanks (like a chest).
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intDeprecated, for removal: This API element is subject to removal in a future version.final FluidAmountprotected final net.minecraft.util.collection.DefaultedList<FluidVolume> -
Constructor Summary
ConstructorsConstructorDescriptionSimpleFixedFluidInv(int invSize, int tankCapacity) Deprecated, for removal: This API element is subject to removal in a future version.Replaced bySimpleFixedFluidInv(int, FluidAmount).SimpleFixedFluidInv(int invSize, FluidAmount tankCapacity) -
Method Summary
Modifier and TypeMethodDescriptionaddListener(FluidInvTankChangeListener listener, ListenerRemovalToken removalToken) Adds the given listener to this inventory, such that theFluidInvTankChangeListener.onChange(FixedFluidInvView, int, FluidVolume, FluidVolume)will be called every time that this inventory changes.attemptAnyExtraction(FluidAmount maxAmount, Simulation simulation) attemptExtraction(FluidFilter filter, FluidAmount maxAmount, Simulation simulation) attemptInsertion(FluidVolume fluid, Simulation simulation) Inserts the given stack into this insertable, and returns the excess.protected final voidfireTankChange(int tank, FluidVolume previous, FluidVolume current) voidfromTag(net.minecraft.nbt.NbtCompound tag) getFilterForTank(int tank) ExposesFixedFluidInvView.isFluidValidForTank(int, FluidKey)as a (potentially) readable filter.Returns anFluidFilterto determine ifFluidInsertable.attemptInsertion(FluidVolume, Simulation)could ever accept a fluid.getInvFluid(int tank) intgetMaxAmount(int tank) Deprecated, for removal: This API element is subject to removal in a future version.Replaced bygetMaxAmount_F(int).getMaxAmount_F(int tank) final intvoidbooleanisFluidValidForTank(int tank, FluidKey fluid) Checks to see if the given fluid would be valid for this tank, ignoring current contents.booleansetInvFluid(int tank, FluidVolume to, Simulation simulation) Sets the fluid in the given tank to the given fluid.voidsetOwnerListener(FluidInvTankChangeListener ownerListener) Sets the owner listener callback, which is never removed from the listener list wheninvalidateListeners()is called.final net.minecraft.nbt.NbtCompoundtoTag()net.minecraft.nbt.NbtCompoundtoTag(net.minecraft.nbt.NbtCompound tag) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface alexiil.mc.lib.attributes.fluid.FixedFluidInv
createLimitedFixedInv, extractFluid, forceSetInvFluid, getExtractable, getInsertable, getMappedInv, getSubInv, getTank, getTransferable, insertFluid, modifyTank, tankIterableMethods inherited from interface alexiil.mc.lib.attributes.fluid.FixedFluidInvView
convertTo, fluidIterable, getFixedView, offerSelfAsAttributeMethods inherited from interface alexiil.mc.lib.attributes.fluid.FluidExtractable
attemptAnyExtraction, attemptExtraction, couldExtractAnything, extract, extract, extract, extract, extract, extract, getPureExtractableMethods inherited from interface alexiil.mc.lib.attributes.fluid.FluidInsertable
getPureInsertable, insert, offer, offer, wouldAcceptMethods inherited from interface alexiil.mc.lib.attributes.fluid.FluidTransferable
filtered
-
Field Details
-
tankCapacity
Deprecated, for removal: This API element is subject to removal in a future version.Replaced bytankCapacity_F -
tankCapacity_F
-
tanks
-
-
Constructor Details
-
SimpleFixedFluidInv
@Deprecated(since="0.6.0", forRemoval=true) public SimpleFixedFluidInv(int invSize, int tankCapacity) Deprecated, for removal: This API element is subject to removal in a future version.Replaced bySimpleFixedFluidInv(int, FluidAmount). -
SimpleFixedFluidInv
-
-
Method Details
-
getTankCount
public final int getTankCount()- Specified by:
getTankCountin interfaceFixedFluidInvView- Returns:
- The number of tanks in this inventory.
-
getMaxAmount
Deprecated, for removal: This API element is subject to removal in a future version.Replaced bygetMaxAmount_F(int).- Specified by:
getMaxAmountin interfaceFixedFluidInvView- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- The maximum amount that the given tank can hold of the given fluid. This method will ignore the current
stack in
FixedFluidInvView.getInvFluid(int). Note that any setters that this object implements (likeFixedFluidInv.setInvFluid(int, FluidVolume, Simulation)should reject stacks that are greater than this value. (and callers should only call this if they need to check the amounts separately. Note that it is meaningless to return values greater than the maximum amount an fluid can be stacked to here, and callers are free to throw an exception if this is violated. (Basically huge single-tank inventories shouldn't implement this interface).
-
getMaxAmount_F
- Specified by:
getMaxAmount_Fin interfaceFixedFluidInvView- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- The maximum amount that the given tank can hold of the given fluid. This method will ignore the current
stack in
FixedFluidInvView.getInvFluid(int). Note that any setters that this object implements (likeFixedFluidInv.setInvFluid(int, FluidVolume, Simulation)should reject stacks that are greater than this value. (and callers should only call this if they need to check the amounts separately. Note that it is meaningless to return values greater than the maximum amount an fluid can be stacked to here, and callers are free to throw an exception if this is violated. (Basically huge single-tank inventories shouldn't implement this interface).
-
getInvFluid
- Specified by:
getInvFluidin interfaceFixedFluidInvView- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- The FluidVolume that is held in the tank at the moment. The returned volume must never be modified!
-
isFluidValidForTank
Description copied from interface:FixedFluidInvChecks to see if the given fluid would be valid for this tank, ignoring current contents. Note that this method should adhere to the requirements ofFluidFilter.matches(FluidKey), so passingemptyfluids will generally not return useful results.Note that just because an
FluidKeypasses this validity test, and is mergable with the current fluid, does not mean that you can insert the fluid into this inventory.- Specified by:
isFluidValidForTankin interfaceFixedFluidInv- Specified by:
isFluidValidForTankin interfaceFixedFluidInvView- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).
-
getFilterForTank
Description copied from interface:FixedFluidInvViewExposesFixedFluidInvView.isFluidValidForTank(int, FluidKey)as a (potentially) readable filter.- Specified by:
getFilterForTankin interfaceFixedFluidInvView- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- An
FluidFilterfor this tank. If this tank is filtered by anFluidFilterinternally then it is highly recommended that this be overridden to return that filter rather than the default opaque wrapper aroundFixedFluidInvView.isFluidValidForTank(int, FluidKey).
-
setInvFluid
Description copied from interface:FixedFluidInvSets the fluid in the given tank to the given fluid.- Specified by:
setInvFluidin interfaceFixedFluidInv- Returns:
- True if the modification was allowed, false otherwise. (For example if the given stack doesn't pass the
FixedFluidInvView.isFluidValidForTank(int, FluidKey)test).
-
getGroupedInv
- Specified by:
getGroupedInvin interfaceFixedFluidInv- Specified by:
getGroupedInvin interfaceFixedFluidInvView- Returns:
- A statistical view of this inventory.
-
addListener
public ListenerToken addListener(FluidInvTankChangeListener listener, ListenerRemovalToken removalToken) Description copied from interface:FixedFluidInvViewAdds the given listener to this inventory, such that theFluidInvTankChangeListener.onChange(FixedFluidInvView, int, FluidVolume, FluidVolume)will be called every time that this inventory changes. However if this inventory doesn't support listeners then this will return a nulltoken.- Specified by:
addListenerin interfaceFixedFluidInvViewremovalToken- A token that will be called whenever the given listener is removed from this inventory (or if this inventory itself is unloaded or otherwise invalidated).- Returns:
- A token that represents the listener, or null if the listener could not be added.
-
setOwnerListener
Sets the owner listener callback, which is never removed from the listener list wheninvalidateListeners()is called. -
invalidateListeners
public void invalidateListeners() -
fireTankChange
-
toTag
public final net.minecraft.nbt.NbtCompound toTag() -
toTag
public net.minecraft.nbt.NbtCompound toTag(net.minecraft.nbt.NbtCompound tag) -
fromTag
public void fromTag(net.minecraft.nbt.NbtCompound tag) -
attemptInsertion
Description copied from interface:FluidInsertableInserts the given stack into this insertable, and returns the excess.- Specified by:
attemptInsertionin interfaceFluidInsertable- Parameters:
fluid- The incoming fluid. Must not be modified by this call.simulation- IfSimulation.SIMULATEthen this shouldn't modify anything.- Returns:
- the excess
FluidVolumethat wasn't accepted. This will be independent of this insertable, however it might be the given object instead of a completely new object.
-
getMinimumAcceptedAmount
- Specified by:
getMinimumAcceptedAmountin interfaceFluidInsertable- Returns:
- The minimum amount of fluid that
FluidInsertable.attemptInsertion(FluidVolume, Simulation)will actually accept. Note that this only provides a guarantee thatfluid volumeswith anamountless than this will never be accepted.A null return value indicates that there is no minimum value.
-
getInsertionFilter
Description copied from interface:FluidInsertableReturns anFluidFilterto determine ifFluidInsertable.attemptInsertion(FluidVolume, Simulation)could ever accept a fluid. The default implementation is to returnConstantFluidFilter.ANYTHING, and so it is recommended that custom insertables override this to return a more accurate filter.- Specified by:
getInsertionFilterin interfaceFluidInsertable- Returns:
- A filter to determine if the given fluid could ever be inserted.
-
attemptExtraction
public FluidVolume attemptExtraction(FluidFilter filter, FluidAmount maxAmount, Simulation simulation) Description copied from interface:FluidExtractable- Specified by:
attemptExtractionin interfaceFluidExtractablemaxAmount- The maximum amount of fluid that can be extracted. Negative numbers throw an exception.simulation- IfSimulation.SIMULATEthen this should return the same result that the exact same call withSimulation.ACTIONwould do, except that the filter can be made more specific between calls if the previously simulated extracted fluid is used as a filter.For example the following code snippet should never throw an exception:
FluidExtractablefrom = // Some extractable
FluidVolumeattempted = from.attemptAnyExtraction(Integer.MAX_VALUE,Simulation.SIMULATE);
if (attempted.isEmpty()) return;
FluidVolumeextracted = from.extract(attempted.getFluidKey(), attempted.getAmount());
assert !extracted.isEmpty;
assert attempted.getAmount()== extracted.getAmount();
assert attempted.getFluidKet()== extracted.getFluidKet();
assert attempted.equals(extracted);- Returns:
- A new, independent
FluidVolumethat was extracted.
-
attemptAnyExtraction
Description copied from interface:FluidExtractable- Specified by:
attemptAnyExtractionin interfaceFluidExtractable
-
tankCapacity_F