Package alexiil.mc.lib.attributes.fluid
Interface FixedFluidInv
- All Superinterfaces:
Convertible,FixedFluidInvView
- All Known Subinterfaces:
LimitedFixedFluidInv
- All Known Implementing Classes:
CombinedFixedFluidInv,DelegatingFixedFluidInv,EmptyFixedFluidInv,JumboFixedFluidInv,MappedFixedFluidInv,SimpleFixedFluidInv,SimpleLimitedFixedFluidInv,SubFixedFluidInv
A
FixedFluidInvView that can have it's contents changed. Note that this does not imply that the contents can
be changed to anything the caller wishes them to be.
The attribute is stored in FluidAttributes.FIXED_INV.
-
Method Summary
Modifier and TypeMethodDescriptiondefault LimitedFixedFluidInvdefault FluidVolumeextractFluid(int tank, FluidFilter filter, FluidVolume mergeWith, FluidAmount maxAmount, Simulation simulation) Attempts to extract part of the fluid volume that is held in the given tank.default voidforceSetInvFluid(int slot, FluidVolume to) Sets the stack in the given slot to the given stack, or throws an exception if it was not permitted.default FluidExtractabledefault GroupedFluidInvdefault FluidInsertabledefault FixedFluidInvgetMappedInv(int... tanks) default FixedFluidInvgetSubInv(int fromIndex, int toIndex) Equivalent toList.subList(int, int).default SingleFluidTankgetTank(int tank) default FluidTransferabledefault FluidVolumeinsertFluid(int tank, FluidVolume volume, Simulation simulation) Attempts to insert the given fluid volume into the given tank, returning the excess.booleanisFluidValidForTank(int tank, FluidKey fluid) Checks to see if the given fluid would be valid for this tank, ignoring current contents.default voidmodifyTank(int tank, Function<FluidVolume, FluidVolume> function) Applies the given function to the stack held in the slot, and usesforceSetInvFluid(int, FluidVolume)on the result (Which will throw an exception if the returned stack is not valid for this inventory).booleansetInvFluid(int tank, FluidVolume to, Simulation simulation) Sets the fluid in the given tank to the given fluid.default Iterable<? extends SingleFluidTank>Methods inherited from interface alexiil.mc.lib.attributes.fluid.FixedFluidInvView
addListener, convertTo, fluidIterable, getFilterForTank, getFixedView, getInvFluid, getMaxAmount, getMaxAmount_F, getTankCount, offerSelfAsAttribute
-
Method Details
-
isFluidValidForTank
Checks 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 interfaceFixedFluidInvView- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).
-
setInvFluid
Sets the fluid in the given tank to the given fluid.- Returns:
- True if the modification was allowed, false otherwise. (For example if the given stack doesn't pass the
FixedFluidInvView.isFluidValidForTank(int, FluidKey)test).
-
forceSetInvFluid
Sets the stack in the given slot to the given stack, or throws an exception if it was not permitted. -
modifyTank
Applies the given function to the stack held in the slot, and usesforceSetInvFluid(int, FluidVolume)on the result (Which will throw an exception if the returned stack is not valid for this inventory). -
insertFluid
Attempts to insert the given fluid volume into the given tank, returning the excess.(This is a tank-based version of
FluidInsertable.attemptInsertion(FluidVolume, Simulation)- if you want to use any of the other tank specific methods then it's recommended you get anFluidInsertablefromgetTank(int)).- Parameters:
tank- The tank index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).volume- The incoming fluid volume. Must not be modified by this call.simulation- IfSimulation.SIMULATEthen this shouldn't modify anything.- Returns:
- the excess
ItemStackthat wasn't accepted. This will be independent of this insertable, however it might be the given stack instead of a completely new object. - Throws:
RuntimeException- if the given slot wasn't a valid index.
-
extractFluid
default FluidVolume extractFluid(int tank, @Nullable FluidFilter filter, FluidVolume mergeWith, FluidAmount maxAmount, Simulation simulation) Attempts to extract part of the fluid volume that is held in the given tank.This is a tank based version of
FluidExtractable.attemptExtraction(FluidFilter, FluidAmount, Simulation), however it includes a number of additional arguments. If you want to use any of the simpler methods than it's recommenced that you get anItemExtractablefromgetTank(int).- Parameters:
tank- The slot index. Must be a value between 0 (inclusive) andFixedFluidInvView.getTankCount()(exclusive) to be valid. (Like in arrays, lists, etc).filter- If non-null then this will be checked against the stored stack to see if anything can be extracted.mergeWith- If non-empty then this will be merged with the extracted stack, and as such they should be equal.maxAmount- The maximum amount of fluid to extract.simulation- IfSimulation.SIMULATEthen this shouldn't modify anything.- Returns:
- mergeWith (if non-empty) or the extracted stack if it is empty.
-
getTank
- Specified by:
getTankin interfaceFixedFluidInvView
-
tankIterable
- Specified by:
tankIterablein interfaceFixedFluidInvView
-
createLimitedFixedInv
- Returns:
- A new
LimitedFixedFluidInvthat provides a more controllable version of thisFixedFluidInv.
-
getInsertable
- Returns:
- An
FluidInsertablefor this inventory that will attempt to insert into any of the tanks in this inventory.
-
getExtractable
- Returns:
- An
FluidExtractablefor this inventory that will attempt to extract from any of the tanks in this inventory.
-
getTransferable
- Returns:
- An
FluidTransferablefor this inventory that will attempt to extract from any of the tanks in this inventory.
-
getGroupedInv
- Specified by:
getGroupedInvin interfaceFixedFluidInvView- Returns:
- A statistical view of this inventory.
-
getSubInv
Description copied from interface:FixedFluidInvViewEquivalent toList.subList(int, int).- Specified by:
getSubInvin interfaceFixedFluidInvView- Parameters:
fromIndex- The first tank to exposetoIndex- The tank after the last tank to expose.- Returns:
- a view of this inventory that only exposes the given number of tanks. Might return "this" if fromIndex is
0 and toIndex is equal to
FixedFluidInvView.getTankCount().
-
getMappedInv
- Specified by:
getMappedInvin interfaceFixedFluidInvView- Parameters:
tanks- The tanks to expose.- Returns:
- a view of this inventory that only exposes the given number of tanks. Might return "this" if the tank
array is just [0,1, ...
FixedFluidInvView.getTankCount()-1]
-