-
Notifications
You must be signed in to change notification settings - Fork 0
DataLoaders
Data Loaders in the Formic API allow mods to dynamically load numeric or tabulated data from datapacks at runtime.
They are the foundation for defining physical or simulation parameters such as temperature, conduction, or material properties.
A generic data loader that associates float values with entries from any Minecraft registry โ blocks, fluids, biomes, etc.
It supports both direct entries and tag-based definitions (using #).
Too use an instance of said loader you need to make a json file in data/<floatmap_namespace>/float_map/<registry_namespace>/<registry_path>/<floatmap_path>.json
// Example: Registering a FloatMapDataLoader for block hardness values
public static final FloatMapDataLoader<Block> BLOCK_HARDNESS =
new FloatMapDataLoader<>("modid", "blocks/hardness", Registries.BLOCK);
// Register your loader during the data reload event
forgeEventBus.addListener(FormicDataLoaders::onAddReloadListeners);
public static void onAddReloadListeners(AddReloadListenerEvent event) {
event.addListener(BLOCK_HARDNESS);
}
// Example usage: get the hardness of a block, with a fallback value
public static float getBlockHardness(BlockState state) {
// Default hardness = 1.0f
return BLOCK_HARDNESS.getValue(state.getBlock(), 1.0f);
}{
"replace": false,
"values": {
"#minecraft:stone_ore_replaceables": 3.0,
"minecraft:stone": 5.0,
"minecraft:dirt": 0.5,
"minecraft:obsidian": 50.0,
"minecraft:air": 0.0
}
}Loads 2D tabulated functions from datapacks, allowing interpolation of numerical models such as thermodynamic surfaces or simulation data.
Each dataset defines a function f(x, y) as a grid of precomputed samples.
At runtime, the loader performs bilinear interpolation to provide smooth results.
Used during data generation (datagen) to export and structure function tables for use with TwoDTabulatedFunctionLoader.
This enables creating reusable simulation tables without manual JSON authoring.
๐ Related Pages:
- Math โ tabulated function logic and solvers
- Formic API Home