Class HeatExchangerLogicTicking

java.lang.Object
me.desht.pneumaticcraft.common.heat.HeatExchangerLogicTicking
All Implemented Interfaces:
IHeatExchangerLogic, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>

public class HeatExchangerLogicTicking extends Object implements IHeatExchangerLogic
  • Constructor Details

    • HeatExchangerLogicTicking

      public HeatExchangerLogicTicking()
  • Method Details

    • initializeAsHull

      public void initializeAsHull(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, BiPredicate<net.minecraft.world.level.LevelAccessor,net.minecraft.core.BlockPos> blockFilter, net.minecraft.core.Direction... validSides)
      Description copied from interface: IHeatExchangerLogic
      Discovers all heat exchanging neighbor block entities (i.e. block entities who provide the IHeatExchangerLogic capability on that side) and adds them as connected heat exchangers. It also accounts for neighbouring blocks with special heat properties, like Magma or Lava, and other special cases like Heat Frames (which are entities).

      This should be called by the owning block entity on first tick (IForgeBlockEntity.onLoad() is suitable) and when neighboring blocks update (BlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean).

      You don't need to call this method if this heat exchanger is not connected to the outside world (e.g. the internal connecting heat exchanger within a Vortex Tube).

      Specified by:
      initializeAsHull in interface IHeatExchangerLogic
      Parameters:
      world - the world
      pos - the blockpos of the owning block entity
      blockFilter - a whitelist check; can be used to exclude certain blocks, e.g. air or fluids. In most cases, IHeatExchangerLogic.ALL_BLOCKS can be passed here.
      validSides - an array of sides to check for heat exchanging neighbours
    • isSideConnected

      public boolean isSideConnected(net.minecraft.core.Direction side)
      Description copied from interface: IHeatExchangerLogic
      Check if this side of the heat exchanger has a thermal connection of any kind to the neighbouring block in the given direction; whether to another heat exchanger, a static heat source like air, or a custom handler such as a furnace or heat frame. The connection data is initialized in IHeatExchangerLogic.initializeAsHull(Level, BlockPos, BiPredicate, Direction...).
      Specified by:
      isSideConnected in interface IHeatExchangerLogic
      Parameters:
      side - the side to check
      Returns:
      true if this side has a thermal connection of any kind
    • addConnectedExchanger

      public void addConnectedExchanger(IHeatExchangerLogic exchanger, boolean reciprocate)
      Specified by:
      addConnectedExchanger in interface IHeatExchangerLogic
      Parameters:
      exchanger - the other heat exchanger
      reciprocate - whether the other exchanger should also add this one
    • removeConnectedExchanger

      public void removeConnectedExchanger(IHeatExchangerLogic exchanger, boolean reciprocate)
      Specified by:
      removeConnectedExchanger in interface IHeatExchangerLogic
      Parameters:
      exchanger - the other heat exchanger
      reciprocate - whether the other exchanger should also remove this one
    • initializeAmbientTemperature

      public void initializeAmbientTemperature(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
      Description copied from interface: IHeatExchangerLogic
      Initialize this heat exchanger's ambient temperature based on the given world & position. You don't need to call this method if your heat exchanger is a hull exchanger (i.e. provides an IHeatExchangerLogic object via capability lookup), as such heat exchangers are automatically initialized by IHeatExchangerLogic.initializeAsHull(Level, BlockPos, BiPredicate, Direction...).
      Specified by:
      initializeAmbientTemperature in interface IHeatExchangerLogic
      Parameters:
      world - the world
      pos - the position
    • getTemperature

      public double getTemperature()
      Description copied from interface: IHeatExchangerLogic
      Get the heat exchanger's current (precise) temperature. This should only be used on the server where precise values are required; it isn't synced to clients by default for performance reasons. Use IHeatExchangerLogic.getTemperatureAsInt() there instead.
      Specified by:
      getTemperature in interface IHeatExchangerLogic
      Returns:
      the temperature
    • getTemperatureAsInt

      public int getTemperatureAsInt()
      Description copied from interface: IHeatExchangerLogic
      Get the heat exchanger's current temperature to the nearest integer. This is sync'd to clients rather than the precise floating-point temperature to avoid excessive network chatter.
      Specified by:
      getTemperatureAsInt in interface IHeatExchangerLogic
      Returns:
      the temperature to the nearest integer
    • setTemperature

      public void setTemperature(double temperature)
      Description copied from interface: IHeatExchangerLogic
      Set the temperature of this heat exchanger. By default, heat exchangers start with a temperature equal to the ambient temperature (in the case of non-hull exchangers which have not been initialized, the default temperature is 300K, the Forge-defined temperature of water).
      Specified by:
      setTemperature in interface IHeatExchangerLogic
      Parameters:
      temperature - in degrees Kelvin
    • setThermalResistance

      public void setThermalResistance(double thermalResistance)
      Description copied from interface: IHeatExchangerLogic
      The higher the thermal resistance, the slower the heat disperses. The effective resistance is the sum of this resistance plus the neighbour's resistance; if both exchangers have a resistance of 1, heat will equalize in a single tick under normal circumstances.
      Specified by:
      setThermalResistance in interface IHeatExchangerLogic
      Parameters:
      thermalResistance - the thermal resistance; higher resistance means slower heat transfer
    • getThermalResistance

      public double getThermalResistance()
      Description copied from interface: IHeatExchangerLogic
      Get this heat exchanger's thermal resistance. See IHeatExchangerLogic.setThermalResistance(double) for more information on thermal resistance.
      Specified by:
      getThermalResistance in interface IHeatExchangerLogic
      Returns:
      the thermal resistance; higher resistance means slower heat transfer
    • setThermalCapacity

      public void setThermalCapacity(double capacity)
      Description copied from interface: IHeatExchangerLogic
      Set this heat exchanger's thermal capacity.

      The higher the capacity, the more heat can be 'stored'. E.g. an object with a heat capacity of double the heat capacity of another object will require twice as much heat gain or loss to adjust the temperature by the same amount.

      Specified by:
      setThermalCapacity in interface IHeatExchangerLogic
      Parameters:
      capacity - the thermal capacity
    • getThermalCapacity

      public double getThermalCapacity()
      Description copied from interface: IHeatExchangerLogic
      Get this heat exchanger's thermal capacity. See IHeatExchangerLogic.setThermalCapacity(double) for more information.
      Specified by:
      getThermalCapacity in interface IHeatExchangerLogic
      Returns:
      the thermal capacity.
    • serializeNBT

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

      public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt)
      Specified by:
      deserializeNBT in interface IHeatExchangerLogic
      Specified by:
      deserializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
    • tick

      public void tick()
      Description copied from interface: IHeatExchangerLogic
      Call this to tick this logic, and make the heat disperse itself. In general this should be called each tick by the owning block entity's tick() method, on the server side only.
      Specified by:
      tick in interface IHeatExchangerLogic
    • getAmbientTemperature

      public double getAmbientTemperature()
      Description copied from interface: IHeatExchangerLogic
      Get the heat exchanger's ambient temperature, i.e. the temperature at which it initially starts, dependent on its environment (biome and altitude).
      Specified by:
      getAmbientTemperature in interface IHeatExchangerLogic
      Returns:
      the ambient temperature
    • addTemperatureListener

      public void addTemperatureListener(TemperatureListener listener)
      Description copied from interface: IHeatExchangerLogic
      Register a listener which will be called if the temperature of this heat exchanger changes. This is ignored for heat exchangers with constant temperature (i.e. ambient temperatures or non-block-entity blocks).
      Specified by:
      addTemperatureListener in interface IHeatExchangerLogic
      Parameters:
      listener - a listener which receives the new temperature
    • removeTemperatureListener

      public void removeTemperatureListener(TemperatureListener listener)
      Description copied from interface: IHeatExchangerLogic
      Removed a registered temperture listener. This should be called when the listening object goes out of scope.
      Specified by:
      removeTemperatureListener in interface IHeatExchangerLogic
      Parameters:
      listener - the listener to remove
    • exchange

      public static void exchange(IHeatExchangerLogic logic, IHeatExchangerLogic logic2)
    • addHeat

      public void addHeat(double amount)
      Description copied from interface: IHeatExchangerLogic
      Adds heat (= deltaT * Thermal Capacity) to this exchanger. Negative values will remove heat.
      Specified by:
      addHeat in interface IHeatExchangerLogic
      Parameters:
      amount - the heat amount
    • getHeatBehaviour

      public <T extends HeatBehaviour> Optional<T> getHeatBehaviour(net.minecraft.core.BlockPos pos, Class<T> cls)
      Description copied from interface: IHeatExchangerLogic
      Get the HeatBehaviour at the given position, which must be adjacent to this heat exchanger's owning tile entity, and in this heat exchanger's list of heat behaviours that it handles.
      Specified by:
      getHeatBehaviour in interface IHeatExchangerLogic
      Type Parameters:
      T - the heat behaviour type
      Parameters:
      pos - position of the heat behaviour
      cls - required class of the heat behaviour (any heat behaviour which extends this class will match)
      Returns:
      an optional heat behaviour, or Optional.empty() if the position is invalid or there is no matching heat behaviour there