Class HeatExchangerLogicTicking
java.lang.Object
me.desht.pneumaticcraft.common.heat.HeatExchangerLogicTicking
- All Implemented Interfaces:
IHeatExchangerLogic,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
Field Summary
Fields inherited from interface me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic
ALL_BLOCKS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnectedExchanger(IHeatExchangerLogic exchanger, boolean reciprocate) voidaddHeat(double amount) Adds heat (= deltaT * Thermal Capacity) to this exchanger.voidaddTemperatureListener(TemperatureListener listener) Register a listener which will be called if the temperature of this heat exchanger changes.voiddeserializeNBT(net.minecraft.nbt.CompoundTag nbt) static voidexchange(IHeatExchangerLogic logic, IHeatExchangerLogic logic2) doubleGet the heat exchanger's ambient temperature, i.e.<T extends HeatBehaviour>
Optional<T>getHeatBehaviour(net.minecraft.core.BlockPos pos, Class<T> cls) Get theHeatBehaviourat 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.doubleGet the heat exchanger's current (precise) temperature.intGet the heat exchanger's current temperature to the nearest integer.doubleGet this heat exchanger's thermal capacity.doubleGet this heat exchanger's thermal resistance.voidinitializeAmbientTemperature(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Initialize this heat exchanger's ambient temperature based on the given world & position.voidinitializeAsHull(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) Discovers all heat exchanging neighbor block entities (i.e.booleanisSideConnected(net.minecraft.core.Direction side) 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.voidremoveConnectedExchanger(IHeatExchangerLogic exchanger, boolean reciprocate) voidremoveTemperatureListener(TemperatureListener listener) Removed a registered temperture listener.net.minecraft.nbt.CompoundTagvoidsetTemperature(double temperature) Set the temperature of this heat exchanger.voidsetThermalCapacity(double capacity) Set this heat exchanger's thermal capacity.voidsetThermalResistance(double thermalResistance) The higher the thermal resistance, the slower the heat disperses.voidtick()Call this to tick this logic, and make the heat disperse itself.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic
addConnectedExchanger, removeConnectedExchanger
-
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:IHeatExchangerLogicDiscovers all heat exchanging neighbor block entities (i.e. block entities who provide theIHeatExchangerLogiccapability 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:
initializeAsHullin interfaceIHeatExchangerLogic- Parameters:
world- the worldpos- the blockpos of the owning block entityblockFilter- a whitelist check; can be used to exclude certain blocks, e.g. air or fluids. In most cases,IHeatExchangerLogic.ALL_BLOCKScan 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:IHeatExchangerLogicCheck 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 inIHeatExchangerLogic.initializeAsHull(Level, BlockPos, BiPredicate, Direction...).- Specified by:
isSideConnectedin interfaceIHeatExchangerLogic- Parameters:
side- the side to check- Returns:
- true if this side has a thermal connection of any kind
-
addConnectedExchanger
- Specified by:
addConnectedExchangerin interfaceIHeatExchangerLogic- Parameters:
exchanger- the other heat exchangerreciprocate- whether the other exchanger should also add this one
-
removeConnectedExchanger
- Specified by:
removeConnectedExchangerin interfaceIHeatExchangerLogic- Parameters:
exchanger- the other heat exchangerreciprocate- 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:IHeatExchangerLogicInitialize 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 anIHeatExchangerLogicobject via capability lookup), as such heat exchangers are automatically initialized byIHeatExchangerLogic.initializeAsHull(Level, BlockPos, BiPredicate, Direction...).- Specified by:
initializeAmbientTemperaturein interfaceIHeatExchangerLogic- Parameters:
world- the worldpos- the position
-
getTemperature
public double getTemperature()Description copied from interface:IHeatExchangerLogicGet 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. UseIHeatExchangerLogic.getTemperatureAsInt()there instead.- Specified by:
getTemperaturein interfaceIHeatExchangerLogic- Returns:
- the temperature
-
getTemperatureAsInt
public int getTemperatureAsInt()Description copied from interface:IHeatExchangerLogicGet 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:
getTemperatureAsIntin interfaceIHeatExchangerLogic- Returns:
- the temperature to the nearest integer
-
setTemperature
public void setTemperature(double temperature) Description copied from interface:IHeatExchangerLogicSet 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:
setTemperaturein interfaceIHeatExchangerLogic- Parameters:
temperature- in degrees Kelvin
-
setThermalResistance
public void setThermalResistance(double thermalResistance) Description copied from interface:IHeatExchangerLogicThe 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:
setThermalResistancein interfaceIHeatExchangerLogic- Parameters:
thermalResistance- the thermal resistance; higher resistance means slower heat transfer
-
getThermalResistance
public double getThermalResistance()Description copied from interface:IHeatExchangerLogicGet this heat exchanger's thermal resistance. SeeIHeatExchangerLogic.setThermalResistance(double)for more information on thermal resistance.- Specified by:
getThermalResistancein interfaceIHeatExchangerLogic- Returns:
- the thermal resistance; higher resistance means slower heat transfer
-
setThermalCapacity
public void setThermalCapacity(double capacity) Description copied from interface:IHeatExchangerLogicSet 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:
setThermalCapacityin interfaceIHeatExchangerLogic- Parameters:
capacity- the thermal capacity
-
getThermalCapacity
public double getThermalCapacity()Description copied from interface:IHeatExchangerLogicGet this heat exchanger's thermal capacity. SeeIHeatExchangerLogic.setThermalCapacity(double)for more information.- Specified by:
getThermalCapacityin interfaceIHeatExchangerLogic- Returns:
- the thermal capacity.
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT()- Specified by:
serializeNBTin interfaceIHeatExchangerLogic- Specified by:
serializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt) - Specified by:
deserializeNBTin interfaceIHeatExchangerLogic- Specified by:
deserializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
tick
public void tick()Description copied from interface:IHeatExchangerLogicCall this to tick this logic, and make the heat disperse itself. In general this should be called each tick by the owning block entity'stick()method, on the server side only.- Specified by:
tickin interfaceIHeatExchangerLogic
-
getAmbientTemperature
public double getAmbientTemperature()Description copied from interface:IHeatExchangerLogicGet the heat exchanger's ambient temperature, i.e. the temperature at which it initially starts, dependent on its environment (biome and altitude).- Specified by:
getAmbientTemperaturein interfaceIHeatExchangerLogic- Returns:
- the ambient temperature
-
addTemperatureListener
Description copied from interface:IHeatExchangerLogicRegister 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:
addTemperatureListenerin interfaceIHeatExchangerLogic- Parameters:
listener- a listener which receives the new temperature
-
removeTemperatureListener
Description copied from interface:IHeatExchangerLogicRemoved a registered temperture listener. This should be called when the listening object goes out of scope.- Specified by:
removeTemperatureListenerin interfaceIHeatExchangerLogic- Parameters:
listener- the listener to remove
-
exchange
-
addHeat
public void addHeat(double amount) Description copied from interface:IHeatExchangerLogicAdds heat (= deltaT * Thermal Capacity) to this exchanger. Negative values will remove heat.- Specified by:
addHeatin interfaceIHeatExchangerLogic- 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:IHeatExchangerLogicGet theHeatBehaviourat 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:
getHeatBehaviourin interfaceIHeatExchangerLogic- Type Parameters:
T- the heat behaviour type- Parameters:
pos- position of the heat behaviourcls- 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
-