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 LimitedFixedFluidInv
default FluidVolume
extractFluid(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 void
forceSetInvFluid(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 FluidExtractable
default GroupedFluidInv
default FluidInsertable
default FixedFluidInv
getMappedInv(int... tanks)
default FixedFluidInv
getSubInv(int fromIndex, int toIndex)
Equivalent toList.subList(int, int)
.default SingleFluidTank
getTank(int tank)
default FluidTransferable
default FluidVolume
insertFluid(int tank, FluidVolume volume, Simulation simulation)
Attempts to insert the given fluid volume into the given tank, returning the excess.boolean
isFluidValidForTank(int tank, FluidKey fluid)
Checks to see if the given fluid would be valid for this tank, ignoring current contents.default void
modifyTank(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).boolean
setInvFluid(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 passingempty
fluids will generally not return useful results.Note that just because an
FluidKey
passes this validity test, and is mergable with the current fluid, does not mean that you can insert the fluid into this inventory.- Specified by:
isFluidValidForTank
in 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 anFluidInsertable
fromgetTank(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.SIMULATE
then this shouldn't modify anything.- Returns:
- the excess
ItemStack
that 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 anItemExtractable
fromgetTank(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.SIMULATE
then this shouldn't modify anything.- Returns:
- mergeWith (if non-empty) or the extracted stack if it is empty.
-
getTank
- Specified by:
getTank
in interfaceFixedFluidInvView
-
tankIterable
- Specified by:
tankIterable
in interfaceFixedFluidInvView
-
createLimitedFixedInv
- Returns:
- A new
LimitedFixedFluidInv
that provides a more controllable version of thisFixedFluidInv
.
-
getInsertable
- Returns:
- An
FluidInsertable
for this inventory that will attempt to insert into any of the tanks in this inventory.
-
getExtractable
- Returns:
- An
FluidExtractable
for this inventory that will attempt to extract from any of the tanks in this inventory.
-
getTransferable
- Returns:
- An
FluidTransferable
for this inventory that will attempt to extract from any of the tanks in this inventory.
-
getGroupedInv
- Specified by:
getGroupedInv
in interfaceFixedFluidInvView
- Returns:
- A statistical view of this inventory.
-
getSubInv
Description copied from interface:FixedFluidInvView
Equivalent toList.subList(int, int)
.- Specified by:
getSubInv
in 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:
getMappedInv
in 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]
-