Class MachineAirHandler
java.lang.Object
me.desht.pneumaticcraft.common.capabilities.BasicAirHandler
me.desht.pneumaticcraft.common.capabilities.MachineAirHandler
- All Implemented Interfaces:
IAirHandler,IAirHandlerMachine,IManoMeasurable,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
public class MachineAirHandler
extends BasicAirHandler
implements IAirHandlerMachine, IManoMeasurable
A ticking air handler owned by a block entity, which disperses air to those neighbouring air handlers
which have lower pressure than it does.
-
Nested Class Summary
Nested classes/interfaces inherited from interface me.desht.pneumaticcraft.api.tileentity.IAirHandlerMachine
IAirHandlerMachine.Connection -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserializeNBT(net.minecraft.nbt.CompoundTag nbt) voidDisallow 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.intGet the effective volume of this air handler.voidprintManometerMessage(net.minecraft.world.entity.player.Player player, List<net.minecraft.network.chat.Component> curInfo) This method is invoked by the Manometer when a player right-clicks a BE or Entity with this interface implemented.net.minecraft.nbt.CompoundTagvoidsetConnectedFaces(List<net.minecraft.core.Direction> sides) Set the connected faces of this air handler.voidsetPressure(float pressure) 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 class me.desht.pneumaticcraft.common.capabilities.BasicAirHandler
addAir, getAir, getBaseVolume, getPressure, maxPressure, setBaseVolumeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.desht.pneumaticcraft.api.tileentity.IAirHandler
addAir, getAir, getBaseVolume, getPressure, maxPressure, setBaseVolume
-
Constructor Details
-
MachineAirHandler
-
-
Method Details
-
getVolume
public int getVolume()Description copied from interface:IAirHandlerGet the effective volume of this air handler. This may have been increased by Volume Upgrades, and also other external modifiers (seeIItemRegistry.registerPneumaticVolumeModifier(ItemVolumeModifier)).- Specified by:
getVolumein interfaceIAirHandler- Overrides:
getVolumein classBasicAirHandler- Returns:
- the effective volume, in mL
-
getDangerPressure
public float getDangerPressure()Description copied from interface:IAirHandlerMachineGet 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.- Specified by:
getDangerPressurein interfaceIAirHandlerMachine- Returns:
- the danger pressure level, in bar
-
getCriticalPressure
public float getCriticalPressure()Description copied from interface:IAirHandlerMachineGet 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!- Specified by:
getCriticalPressurein interfaceIAirHandlerMachine- Returns:
- the critical pressure level, in bar
-
setPressure
public void setPressure(float pressure) Description copied from interface:IAirHandlerMachineSet 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.- Specified by:
setPressurein interfaceIAirHandlerMachine- Parameters:
pressure- the new pressure, in bar
-
setVolumeUpgrades
public void setVolumeUpgrades(int newVolumeUpgrades) Description copied from interface:IAirHandlerMachineShould 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.- Specified by:
setVolumeUpgradesin interfaceIAirHandlerMachine- Parameters:
newVolumeUpgrades- new number of volume upgrades
-
enableSafetyVenting
Description copied from interface:IAirHandlerMachineAllow this air handler to vent air when over-pressure.- Specified by:
enableSafetyVentingin interfaceIAirHandlerMachine- Parameters:
pressureCheck- a predicate to test if venting is requireddir- direction to leak air in
-
disableSafetyVenting
public void disableSafetyVenting()Description copied from interface:IAirHandlerMachineDisallow any safety venting.- Specified by:
disableSafetyVentingin interfaceIAirHandlerMachine
-
setConnectedFaces
Description copied from interface:IAirHandlerMachineSet 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.
- Specified by:
setConnectedFacesin interfaceIAirHandlerMachine- Parameters:
sides- a list of sides on which this air handler should be offered as a capability
-
tick
public void tick(net.minecraft.world.level.block.entity.BlockEntity ownerTE) Description copied from interface:IAirHandlerMachineMust 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).- Specified by:
tickin interfaceIAirHandlerMachine- Parameters:
ownerTE- the owning block entity
-
setSideLeaking
public void setSideLeaking(@Nullable net.minecraft.core.Direction dir) Description copied from interface:IAirHandlerMachineMark 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)
- Specified by:
setSideLeakingin interfaceIAirHandlerMachine- Parameters:
dir- the direction the leak is occurring (affects particle velocities), or null for no leak
-
getSideLeaking
@Nullable public net.minecraft.core.Direction getSideLeaking()Description copied from interface:IAirHandlerMachineGet the side which is leaking air, if any.- Specified by:
getSideLeakingin interfaceIAirHandlerMachine- Returns:
- the leaking side, or null if there's no leak
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT()- Specified by:
serializeNBTin interfaceIAirHandlerMachine- Specified by:
serializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
serializeNBTin classBasicAirHandler
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt) - Specified by:
deserializeNBTin interfaceIAirHandlerMachine- Specified by:
deserializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
deserializeNBTin classBasicAirHandler
-
getConnectedAirHandlers
public List<IAirHandlerMachine.Connection> getConnectedAirHandlers(net.minecraft.world.level.block.entity.BlockEntity ownerTE) Description copied from interface:IAirHandlerMachineGet a list of all air handlers connected to this one.- Specified by:
getConnectedAirHandlersin interfaceIAirHandlerMachine- Parameters:
ownerTE- the owning block entity- Returns:
- a list of all connected air handlers
-
printManometerMessage
public void printManometerMessage(net.minecraft.world.entity.player.Player player, List<net.minecraft.network.chat.Component> curInfo) Description copied from interface:IManoMeasurableThis method is invoked by the Manometer when a player right-clicks a BE or Entity with this interface implemented.- Specified by:
printManometerMessagein interfaceIManoMeasurable- Parameters:
player- player who is right-clicking the measurable BE, and therefore needs to get the messagecurInfo- list you can append info to. If you don't append any info no air will be used.
-