Interface IAirHandlerMachine
- All Superinterfaces:
IAirHandler,IManoMeasurable,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- All Known Implementing Classes:
MachineAirHandler
public interface IAirHandlerMachine
extends IAirHandler, IManoMeasurable, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
An extended air handler which is used by tile entities. It supports the concept of connected neighbouring
air handlers, and will push air to neighbouring air handlers with lower pressure. It will also explode if
over-pressurized.
Don't implement this class yourself! Use one of the methods in IAirHandulerMachineFactory to obtain
a suitable implementation for your block entity.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a connection to a neighbouring air handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidDisallow any safety venting.voidenableSafetyVenting(Predicate<Float> pressureCheck, net.minecraft.core.Direction dir) Allow this air handler to vent air when over-pressure.getConnectedAirHandlers(net.minecraft.world.level.block.entity.BlockEntity ownerTE) Get a list of all air handlers connected to this one.floatGet the "critical" pressure level, which is the hard maximum pressure for this handler.floatGet the "danger" pressure level.net.minecraft.core.DirectionGet the side which is leaking air, if any.voidsetConnectedFaces(List<net.minecraft.core.Direction> sides) Set the connected faces of this air handler.voidsetPressure(float newPressure) Set the pressure of this handler directly.voidsetSideLeaking(net.minecraft.core.Direction dir) Mark a face of the air handler as leaking or otherwise.voidsetVolumeUpgrades(int newVolumeUpgrades) Should be called by the owning block entity when its volume upgrades change.voidtick(net.minecraft.world.level.block.entity.BlockEntity ownerTE) Must be called every tick by the owning block entity.Methods inherited from interface me.desht.pneumaticcraft.api.tileentity.IAirHandler
addAir, getAir, getBaseVolume, getPressure, getVolume, maxPressure, setBaseVolumeMethods inherited from interface me.desht.pneumaticcraft.api.tileentity.IManoMeasurable
printManometerMessageMethods inherited from interface net.minecraftforge.common.util.INBTSerializable
deserializeNBT, serializeNBT
-
Method Details
-
getDangerPressure
float getDangerPressure()Get the "danger" pressure level. If air is added to the handler and the pressure level is above the danger level, there is a chance of explosion, which increases as the pressure increases.- Returns:
- the danger pressure level, in bar
-
getCriticalPressure
float getCriticalPressure()Get the "critical" pressure level, which is the hard maximum pressure for this handler. If air is added and the pressure is at or above this level, an explosion is inevitable!- Returns:
- the critical pressure level, in bar
-
setPressure
void setPressure(float newPressure) Set the pressure of this handler directly. This is generally only used for creative-type tile entities, to maintain a constant pressure; in nearly all cases, theIAirHandler.addAir(int)method should be used.- Parameters:
newPressure- the new pressure, in bar
-
setVolumeUpgrades
void setVolumeUpgrades(int newVolumeUpgrades) Should be called by the owning block entity when its volume upgrades change. This will cause the air handler to recalculate its current volume. A decrease in volume will cause air to be lost, keeping the pressure constant. An increase in volume will keep the air constant, causing a pressure drop.- Parameters:
newVolumeUpgrades- new number of volume upgrades
-
enableSafetyVenting
Allow this air handler to vent air when over-pressure.- Parameters:
pressureCheck- a predicate to test if venting is requireddir- direction to leak air in
-
disableSafetyVenting
void disableSafetyVenting()Disallow any safety venting. -
tick
void tick(net.minecraft.world.level.block.entity.BlockEntity ownerTE) Must be called every tick by the owning block entity. This is called on both server and client (client needs to handle sounds and particles if the air handler is leaking).- Parameters:
ownerTE- the owning block entity
-
setSideLeaking
void setSideLeaking(@Nullable net.minecraft.core.Direction dir) Mark a face of the air handler as leaking or otherwise. When called server-side, changes will be automatically synced to clients on the next tick so that particles and sound effects can be played there. The amount of air leaked in a tick is pressure-dependent; the exact amount ispressure * 40 + 20 mL.(Note: in theory, an air handler could leak in multiple directions at once, but this is a simplified implementation to keep the code straightforward & efficient, while still being effective)
- Parameters:
dir- the direction the leak is occurring (affects particle velocities), or null for no leak
-
getSideLeaking
@Nullable net.minecraft.core.Direction getSideLeaking()Get the side which is leaking air, if any.- Returns:
- the leaking side, or null if there's no leak
-
getConnectedAirHandlers
List<IAirHandlerMachine.Connection> getConnectedAirHandlers(net.minecraft.world.level.block.entity.BlockEntity ownerTE) Get a list of all air handlers connected to this one.- Parameters:
ownerTE- the owning block entity- Returns:
- a list of all connected air handlers
-
setConnectedFaces
Set the connected faces of this air handler. This should be called on the first server tick, and when neighbouring blocks change (i.e. viaBlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean))This also invalidates any cached neighbour data.
- Parameters:
sides- a list of sides on which this air handler should be offered as a capability
-