Depth & Altitude - Momo-Softworks/Cold-Sweat GitHub Wiki
Depth is a factor of the world that can influence the player's temperature. The world is broken up into vertical "regions", which have different properties and y-level ranges. By default, there are three main vertical regions of the world:
-
Between bedrock and 20 blocks below ground level:
- Temperature remains constant, at 75 °F (24 °C)
-
Between -20 and -4:
- Temperature gradually changes from 75 °F (24 °C) to the temperature of the biome at the surface
-
Between -4 and the maximum world height:
- Temperature gradually becomes colder, at a rate that depends on the humidity and temperature of the biome below.
- In a plains (neutral) biome, this rate is about 1 °F (0.55 °C) per 8 blocks.
The player's depth is calculated by sampling the height of ground level at regular intervals within a roughly 5x5-chunk area. Using many samples in an area around the player ensures smooth transitions in temperature as the player explores underground, or as they enter the mouth of a cave.
[Expand] A graphic of the depth formula's search radius
Below is a rough depiction of the formula's search pattern. White dots represent the positions of each sample, with the black dot in the middle representing the player's current location.
The red squares represent the weight of each region in the calculation. Brighter areas hold more weight in determining the player's average depth:
Note:
These values are weighted according to their distance from the player, so the world height of an area 30 block away will have less of an impact than the height of the world at the player's current X and Z coordinates.
These values are then averaged (according to their relative weights) and compared against player's current y-level to get their average depth.
Finally, the player's depth is offset by the level of sky light at their position. For example, if the sky light at the player's position is 15, then the player will be perceived to be 15 blocks higher than they are. This accounts for the fact that the player would not be as well protected when they are exposed to air.
Altitude is much more straightforward to calculate. Temperature decreases at a linear rate as the player travels up from sea level to the build limit. At the maximum altitude, the world is at least 27 °F (15 °C) colder than at sea level.