Class HeatExchangerLogicConstant

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

public class HeatExchangerLogicConstant extends Object implements IHeatExchangerLogic
Used for blocks like lava/ice, which have a constant heat. These are effectively an infinite heat source/sink, unless there is a transitioning heat behaviour attached.
  • Constructor Details

    • HeatExchangerLogicConstant

      public HeatExchangerLogicConstant(double temperature, double thermalResistance)
  • Method Details

    • 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
    • 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> loseHeatToAir, 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
      loseHeatToAir - 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
    • 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
    • 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
    • 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
    • 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
    • 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.
    • 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
    • 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