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.
  • Constructor Details

    • MachineAirHandler

      public MachineAirHandler(PressureTier tier, int volume)
  • Method Details

    • getVolume

      public int getVolume()
      Description copied from interface: IAirHandler
      Get the effective volume of this air handler. This may have been increased by Volume Upgrades, and also other external modifiers (see IItemRegistry.registerPneumaticVolumeModifier(ItemVolumeModifier)).
      Specified by:
      getVolume in interface IAirHandler
      Overrides:
      getVolume in class BasicAirHandler
      Returns:
      the effective volume, in mL
    • getDangerPressure

      public float getDangerPressure()
      Description copied from interface: IAirHandlerMachine
      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.
      Specified by:
      getDangerPressure in interface IAirHandlerMachine
      Returns:
      the danger pressure level, in bar
    • getCriticalPressure

      public float getCriticalPressure()
      Description copied from interface: IAirHandlerMachine
      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!
      Specified by:
      getCriticalPressure in interface IAirHandlerMachine
      Returns:
      the critical pressure level, in bar
    • setPressure

      public void setPressure(float pressure)
      Description copied from interface: IAirHandlerMachine
      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.
      Specified by:
      setPressure in interface IAirHandlerMachine
      Parameters:
      pressure - the new pressure, in bar
    • setVolumeUpgrades

      public void setVolumeUpgrades(int newVolumeUpgrades)
      Description copied from interface: IAirHandlerMachine
      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.
      Specified by:
      setVolumeUpgrades in interface IAirHandlerMachine
      Parameters:
      newVolumeUpgrades - new number of volume upgrades
    • enableSafetyVenting

      public void enableSafetyVenting(it.unimi.dsi.fastutil.floats.FloatPredicate pressureCheck, net.minecraft.core.Direction dir)
      Description copied from interface: IAirHandlerMachine
      Allow this air handler to vent air when over-pressure.
      Specified by:
      enableSafetyVenting in interface IAirHandlerMachine
      Parameters:
      pressureCheck - a predicate to test if venting is required
      dir - direction to leak air in
    • disableSafetyVenting

      public void disableSafetyVenting()
      Description copied from interface: IAirHandlerMachine
      Disallow any safety venting.
      Specified by:
      disableSafetyVenting in interface IAirHandlerMachine
    • setConnectedFaces

      public void setConnectedFaces(List<net.minecraft.core.Direction> sides)
      Description copied from interface: IAirHandlerMachine
      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.

      Specified by:
      setConnectedFaces in interface IAirHandlerMachine
      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: IAirHandlerMachine
      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).
      Specified by:
      tick in interface IAirHandlerMachine
      Parameters:
      ownerTE - the owning block entity
    • setSideLeaking

      public void setSideLeaking(@Nullable net.minecraft.core.Direction dir)
      Description copied from interface: IAirHandlerMachine
      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)

      Specified by:
      setSideLeaking in interface IAirHandlerMachine
      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: IAirHandlerMachine
      Get the side which is leaking air, if any.
      Specified by:
      getSideLeaking in interface IAirHandlerMachine
      Returns:
      the leaking side, or null if there's no leak
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT()
      Specified by:
      serializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      serializeNBT in class BasicAirHandler
    • deserializeNBT

      public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt)
      Specified by:
      deserializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      deserializeNBT in class BasicAirHandler
    • getConnectedAirHandlers

      public List<IAirHandlerMachine.Connection> getConnectedAirHandlers(net.minecraft.world.level.block.entity.BlockEntity ownerTE)
      Description copied from interface: IAirHandlerMachine
      Get a list of all air handlers connected to this one.
      Specified by:
      getConnectedAirHandlers in interface IAirHandlerMachine
      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: IManoMeasurable
      This method is invoked by the Manometer when a player right-clicks a BE or Entity with this interface implemented.
      Specified by:
      printManometerMessage in interface IManoMeasurable
      Parameters:
      player - player who is right-clicking the measurable BE, and therefore needs to get the message
      curInfo - list you can append info to. If you don't append any info no air will be used.