Interface IAirHandlerMachine

All Superinterfaces:
IAirHandler, IManoMeasurable
All Known Implementing Classes:
MachineAirHandler

public interface IAirHandlerMachine extends IAirHandler, IManoMeasurable
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 IAirHandlerMachineFactory to obtain a suitable implementation for your block entity.

  • 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, the IAirHandler.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

      void enableSafetyVenting(Predicate<Float> pressureCheck, net.minecraft.core.Direction dir)
      Allow this air handler to vent air when over-pressure.
      Parameters:
      pressureCheck - a predicate to test if venting is required
      dir - 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 is pressure * 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
    • serializeNBT

      net.minecraft.nbt.Tag serializeNBT()
    • deserializeNBT

      void deserializeNBT(net.minecraft.nbt.CompoundTag compound)
    • setConnectedFaces

      void setConnectedFaces(List<net.minecraft.core.Direction> sides)
      Set the connected faces of this air handler. This should be called on the first server tick, and when neighbouring blocks change (i.e. via BlockBehaviour.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