Interface FluidTankRebarBlock
-
- All Implemented Interfaces:
-
io.github.pylonmc.rebar.block.interfaces.BlockBreakRebarBlockHandler,io.github.pylonmc.rebar.block.interfaces.EntityHolderRebarBlock,io.github.pylonmc.rebar.block.interfaces.FluidRebarBlock
public interface FluidTankRebarBlock implements FluidRebarBlock
A common pattern is a 'fluid tank' which can only store one fluid at a time, but can store many types of fluids.
RebarFluidTankimplements this pattern.You must call setCapacity for this block to work.
As with FluidBufferRebarBlock, you do not need to handle saving buffers or implement any of the FluidRebarBlock methods for this; this is all done automatically.
-
-
Method Summary
Modifier and Type Method Description default voidsetFluidType(RebarFluid fluid)Sets the type of fluid in the fluid tank default voidsetCapacity(Double capacity)Sets the capacity of the fluid tank default BooleancanSetFluid(Double amount)Checks if a new amount of fluid is greater than zero and fits inside the tank. default BooleancanAddFluid(Double amount)Checks if adding a certain amount of fluid would result in a valid fluid amount. default BooleancanAddFluid(RebarFluid fluid, Double amount)Checks if adding a certain amount of fluid of a certain type would result in a valid fluid amount. default BooleansetFluid(Double amount)Sets the fluid amount only if the new amount of fluid is greater than zero and fits in the tank. default BooleanaddFluid(Double amount)Adds to the tank only if the new amount of fluid is greater than zero and fits in the tank. default BooleanremoveFluid(Double amount)Removes from the tank only if the new amount of fluid is greater than zero and fits in the tank. BooleanisAllowedFluid(RebarFluid fluid)default DoublefluidAmountRequested(RebarFluid fluid)Returns the amount of the given fluid that the machine wants to receive next tick. default List<Pair<RebarFluid, Double>>getSuppliedFluids()Returns a list of fluid types - and their corresponding amounts - that can be supplied by the block for this fluid tick. default voidonFluidAdded(RebarFluid fluid, Double amount)amountis always at mostgetRequestedFluids().get(fluid)and will never be zero or less.default voidonFluidRemoved(RebarFluid fluid, Double amount)amountis always at leastgetSuppliedFluids().get(fluid)and will never be zero or less.default RebarFluidgetFluidType()The type of fluid stored in the tank default DoublegetFluidCapacity()The capacity of the tank default DoublegetFluidAmount()The amount of fluid stored in the tank default DoublegetFluidSpaceRemaining()The amount of space remaining in the tank -
Methods inherited from class io.github.pylonmc.rebar.block.interfaces.FluidRebarBlock
createFluidPoint, createFluidPoint, createFluidPoint, createFluidPoint, getFluidPointDisplay, getFluidPointDisplayOrThrow, onBlockBreak -
Methods inherited from class io.github.pylonmc.rebar.block.interfaces.EntityHolderRebarBlock
addEntity, addEntity, areAllHeldEntitiesLoaded, getBlock, getHeldEntities, getHeldEntity, getHeldEntity, getHeldEntityOrThrow, getHeldEntityOrThrow, getHeldEntityUuid, getHeldEntityUuidOrThrow, getHeldRebarEntity, getHeldRebarEntity, getHeldRebarEntityOrThrow, isHeldEntityPresent, tryRemoveAllEntities, tryRemoveEntity, whenHeldRebarEntityLoads, whenHeldRebarEntityLoads -
Methods inherited from class io.github.pylonmc.rebar.block.interfaces.BlockBreakRebarBlockHandler
onPostBlockBreak, onPreBlockBreak -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
setFluidType
default void setFluidType(RebarFluid fluid)
Sets the type of fluid in the fluid tank
-
setCapacity
default void setCapacity(Double capacity)
Sets the capacity of the fluid tank
-
canSetFluid
default Boolean canSetFluid(Double amount)
Checks if a new amount of fluid is greater than zero and fits inside the tank.
-
canAddFluid
default Boolean canAddFluid(Double amount)
Checks if adding a certain amount of fluid would result in a valid fluid amount.
-
canAddFluid
default Boolean canAddFluid(RebarFluid fluid, Double amount)
Checks if adding a certain amount of fluid of a certain type would result in a valid fluid amount.
-
setFluid
default Boolean setFluid(Double amount)
Sets the fluid amount only if the new amount of fluid is greater than zero and fits in the tank.
- Returns:
true only if the fluid amount was set successfully
-
addFluid
default Boolean addFluid(Double amount)
Adds to the tank only if the new amount of fluid is greater than zero and fits in the tank.
- Returns:
true only if the tank was added to successfully
-
removeFluid
default Boolean removeFluid(Double amount)
Removes from the tank only if the new amount of fluid is greater than zero and fits in the tank.
- Returns:
true only if the tank was added to successfully
-
isAllowedFluid
Boolean isAllowedFluid(RebarFluid fluid)
-
fluidAmountRequested
default Double fluidAmountRequested(RebarFluid fluid)
Returns the amount of the given fluid that the machine wants to receive next tick.
If you have a machine that consumes 5 water per tick, it should request 5*RebarConfig.fluidTickInterval of water, and return 0 for every other fluid.
Any implementation of this method must NEVER call the same method for any other connection point, otherwise you risk creating infinite loops.
Called at most once for any given fluid type per tick.
-
getSuppliedFluids
default List<Pair<RebarFluid, Double>> getSuppliedFluids()
Returns a list of fluid types - and their corresponding amounts - that can be supplied by the block for this fluid tick.
If you have a machine that can supply up to 100 fluid per second, it should supply 5 * RebarConfig.fluidTickInterval of that fluid
Any implementation of this method must NEVER call the same method for any other connection point, otherwise you risk creating infinite loops.
Called exactly one per fluid tick.
-
onFluidAdded
default void onFluidAdded(RebarFluid fluid, Double amount)
amountis always at mostgetRequestedFluids().get(fluid)and will never be zero or less.Called at most once per fluid tick.
-
onFluidRemoved
default void onFluidRemoved(RebarFluid fluid, Double amount)
amountis always at leastgetSuppliedFluids().get(fluid)and will never be zero or less.Called at most once per fluid tick.
-
getFluidType
default RebarFluid getFluidType()
The type of fluid stored in the tank
-
getFluidCapacity
default Double getFluidCapacity()
The capacity of the tank
-
getFluidAmount
default Double getFluidAmount()
The amount of fluid stored in the tank
-
getFluidSpaceRemaining
default Double getFluidSpaceRemaining()
The amount of space remaining in the tank
-
-
-
-