Skip to content

Temperature Data System

Real Ant Engineer edited this page Nov 2, 2025 · 1 revision

This page explains how temperature-related data is defined, stored, and encoded for blocks, fluids, and biomes in the mod.


📂 Datapack Locations

Each type of data (temperature, conduction, and resilience) is stored in a datapack under the following paths:

Data Type Registry Path
Block Temperature Registries.BLOCK data/crowns/float_map/blocks/temperatures.json
Block Conduction Registries.BLOCK data/crowns/float_map/blocks/conduction.json
Block Resilience Registries.BLOCK data/crowns/float_map/blocks/resilience.json
Fluid Temperature Registries.FLUID data/crowns/float_map/fluids/temperatures.json
Fluid Conduction Registries.FLUID data/crowns/float_map/fluids/conduction.json
Fluid Resilience Registries.FLUID data/crowns/float_map/fluids/resilience.json
Biome Temperature Registries.BIOME data/crowns/float_map/biomes/temperatures.json

All of these are handled by instances of the FloatMap Data Loader from the Formic API.

🧩 Example JSON (Datapack)

{
  "replace": false,
  "values": {
    "#minecraft:stone_ore_replaceables": 295.15,
    "minecraft:lava": 4000.0,
    "minecraft:water": 293.15
  }
}

Explanation

  • # before a name means it’s a tag reference.
  • Plain names are direct registry entries.
  • The "replace" field determines whether to overwrite or merge with existing datapack values.

Each file follows this same format for temperatures, conduction, and resilience. Be careful with the precision: values are not stored as floats directly, so minor truncation may occur.


🧊 Section-Level Data Storage

Each chunk section (16×16×16 blocks) stores local physical values for:

  • Temperature
  • Conduction coefficient
  • Resilience

Each value type uses a dedicated data layer class optimized for storage and serialization.

Layer Type Storage Precision Value Range Purpose
TemperatureDataLayer int 4 bytes 1e-5 K 0–~8000 K Absolute temperature
ConductionDataLayer custom 8-bit mini-float 1 byte ~10% relative 2⁻¹⁶–2⁴⁷ Thermal conductivity
ResilienceDataLayer byte 1 byte 1/255 0–1 Temperature stability factor

🌡️ TemperatureDataLayer

Purpose

Stores temperature per block in Kelvin. This data is used by the temperature computation system (discretization scheme) to simulate heat transfer between adjacent blocks and fluids.

Default Temperature Priority

When determining the initial temperature of a position, the system checks in the following order:

  1. Fluids (if the block contains or is submerged in one)
  2. Blocks (if no fluid temperature is available)
  3. Biome (as a fallback background temperature)

This ensures liquids always define the dominant thermal environment, followed by solid material and then environmental temperature.

Encoding

  • Each block’s temperature is stored as a 32-bit integer (int).
  • Value is scaled by 1e5 (fixed 5-decimal precision) for accuracy.
  • The integer is centered around Integer.MAX_VALUE to use the full positive range.

Formulae

Operation Formula
Encoding stored = Integer.MAX_VALUE + (int)(temperature * 1e5f)
Decoding temperature = (stored - Integer.MAX_VALUE) / 1e5f

🔥 ConductionDataLayer

Purpose

Stores the thermal conduction coefficient per block, using a custom 8-bit “mini-float” format that encodes both magnitude and scale.

Encoding Format


[EEEEEE MM]
 |      |-- 2-bit mantissa (0–3 → 1.0–1.75)
 |------|   6-bit exponent (0–63 → -16 to +47) 

Equivalent to the classical float representation value = (1 + mantissa / 4) * 2^(exponent).

Range and Precision

  • Range: 2⁻¹⁶ to 1.75 × 2⁴⁷
  • Average precision: ~10–15% (logarithmic spacing)
  • Storage: 1 byte per block

🧱 ResilienceDataLayer

Purpose

Stores a resilience factor in the range [0, 1], representing the material’s tendency to resist or recover from temperature changes.

In other words, resilience determines how strongly a block or fluid returns to its default temperature when no external heat transfer occurs.

  • Low resilience (0.0–0.3): The block quickly adapts to its environment.
  • Medium resilience (0.4–0.7): The block gradually stabilizes near its base temperature.
  • High resilience (0.8–1.0): The block resists temperature changes and keeps its default state longer.

Encoding

  • Stored as a signed byte (-128 → 127).
  • Mapped linearly to the [0,1] range using an offset.
Operation Formula
Encoding stored = (byte)(round(resilience * 255) - 128)
Decoding resilience = (stored + 128) / 255f