Add BiomeDefinition & OreDefinition.

This commit is contained in:
Alexander Chibrikin
2026-01-21 13:01:27 +03:00
parent 2489230502
commit ff574bbc72
2 changed files with 276 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
--- @class BiomeDefinition
--- Definition of a biome for use with `core.register_biome`.
local BiomeDefinition = {
--- Name of the biome.
--- @type string
name = '',
--- Node dropped onto upper surface after all else is generated.
--- For example, `"default:snow"`.
--- @type string?
node_dust = '',
--- Node forming surface layer of biome.
--- For example, `"default:dirt_with_snow"`.
--- Thickness of this layer can be defined with 'depth_top'.
--- @type string?
node_top = '',
--- Thickness of surface layer, defined with 'node_top'.
--- @type integer?
depth_top = 0,
--- Node forming lower layer of biome.
--- For example, `"default:permafrost"`.
--- Thickness of this layer can be defined with 'depth_filler'.
--- @type string?
node_filler = '',
--- Thickness of lower layer, defined with 'node_filler'.
--- @type integer?
depth_filler = 0,
--- Node that replaces all stone nodes between roughly y_min and y_max.
--- For example, `"default:granite"`.
--- @type string?
node_stone = '',
--- Node forming a surface layer in seawater.
--- For example, `"default:ice"`.
--- Thickness of this layer can be defined with 'depth_water_top'.
--- @type string?
node_water_top = '',
--- Thickness of surface layer in seawater, defined with 'node_water_top'.
--- @type integer?
depth_water_top = 0,
--- Node that replaces all seawater nodes not in the surface layer
--- @type string?
node_water = '',
--- Node that replaces river water in mapgens that use `default:river_water`.
--- @type string?
node_river_water = '',
--- Node placed under river water.
--- For example, `"default:gravel"`.
--- Thickness of this layer can be defined with 'depth_riverbed'.
--- @type string?
node_riverbed = 'default:gravel',
--- Thickness of layer under river water, defined with 'node_riverbed'.
--- @type integer?
depth_riverbed = 2,
--- Nodes placed inside 50% of the medium size caves.
--- Multiple nodes can be specified, each cave will use a randomly
--- chosen node from the list.
--- If this field is left out or 'nil', cave liquids fall back to
--- classic behavior of lava and water distributed using 3D noise.
--- For no cave liquid, specify "air".
--- `node_cave_liquid = "default:lava_source",`
--- `node_cave_liquid = {"default:water_source", "default:lava_source"},`
--- @type string|string[]|nil
node_cave_liquid = nil,
--- Node used for primary dungeon structure.
--- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
--- alias, if that is also absent, dungeon nodes fall back to the biome
--- 'node_stone'.
--- Example: `'default:cobble'`.
--- If present, the following two nodes are also used.
--- @type string?
node_dungeon = '',
--- Node used for randomly-distributed alternative structure nodes.
--- If alternative structure nodes are not wanted leave this absent.
--- Example: `'default:mossycobble'`.
--- @type string?
node_dungeon_alt = '',
--- Node used for dungeon stairs.
--- If absent, stairs fall back to 'node_dungeon'.
--- Example: `'stairs:stair_cobble'`.
--- @type string?
node_dungeon_stair = 'stairs:stair_cobble',
--- Upper limit for biome.
--- Alternatively you can use xyz limits via 'max_pos' and 'min_pos'.
--- @type integer?
y_max = 31000,
--- Lower limit for biome.
--- Alternatively you can use xyz limits via 'max_pos' and 'min_pos'.
--- @type integer?
y_min = 1,
--- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
--- Biome is limited to a cuboid defined by these positions.
--- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
--- 31000 in 'max_pos'.
--- @type Position|{x:integer?,y:integer?,z:integer?}|nil
max_pos = { x = 31000, y = 128, z = 31000 },
--- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
--- Biome is limited to a cuboid defined by these positions.
--- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
--- 31000 in 'max_pos'.
--- @type Position|{x:integer?,y:integer?,z:integer?}|nil
min_pos = { x = -31000, y = 9, z = -31000 },
--- Vertical distance in nodes above 'y_max' over which the biome will
--- blend with the biome above.
--- Set to 0 for no vertical blend. Defaults to 0.
--- @type integer?
vertical_blend = 0,
--- Characteristic temperature for the biome.
---
--- Values `heat_point` & `humidity_point` create 'biome points' on a voronoi diagram with heat and
--- humidity as axes. The resulting voronoi cells determine the
--- distribution of the biomes.
---
--- Have average values of 50, vary mostly between
--- 0 and 100 but can exceed these values.
--- @type integer|number?
heat_point = 0,
--- Characteristic humidity for the biome.
---
--- Values `heat_point` & `humidity_point` create 'biome points' on a voronoi diagram with heat and
--- humidity as axes. The resulting voronoi cells determine the
--- distribution of the biomes.
---
--- Have average values of 50, vary mostly between
--- 0 and 100 but can exceed these values.
--- @type integer|number?
humidity_point = 50,
--- Relative weight of the biome in the Voronoi diagram.
--- A value of 0 (or less) is ignored and equivalent to 1.0.
--- @type number?
weight = 1.0,
}

View File

@@ -0,0 +1,127 @@
--- @class OreDefinition
--- Defines an ore to be registered with `core.register_ore`.
--- See https://api.luanti.org/ores/ for details.
local OreDefinition = {
--- If set, `core.registered_ores[that_name]` will return this definition.
--- @type string?
name = "",
--- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
--- @type string?
ore_type = "",
--- Ore node to place
--- @type string
ore = "",
--- Param2 to set for ore (e.g. facedir rotation)
--- @type integer?
ore_param2 = 0,
--- Node to place ore in. Multiple are possible by passing a list.
--- @type string|string[]|nil
wherein = "",
--- Ore has a 1 out of clust_scarcity chance of spawning in a node.
--- If the desired average distance between ores is 'd', set this to
--- d * d * d.
--- @type integer?
clust_scarcity = 8 * 8 * 8,
--- Number of ores in a cluster
--- @type integer?
clust_num_ores = 8,
--- Size of the bounding box of the cluster.
--- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
--- nodes are coal ore.
--- @type integer?
clust_size = 3,
--- Lower limit for ore (inclusive)
--- @type integer?
y_min = -31000,
--- Upper limit for ore (inclusive)
--- @type integer?
y_max = 31000,
--- Attributes for the ore generation, see [Ore attributes](https://api.luanti.org/ores/#ore-attributes) section.
--- @type string?
flags = "",
--- If noise is above this threshold, ore is placed. Not needed for a
--- uniform distribution.
--- @type number?
noise_threshold = 0,
--- NoiseParams structure describing one of the noises used for
--- ore distribution.
--- Needed by "sheet", "puff", "blob" and "vein" ores.
--- Omit from "scatter" ore for a uniform ore distribution.
--- Omit from "stratum" ore for a simple horizontal strata from y_min to
--- y_max.
---
--- Example:
--- ```lua
--- {
--- offset = 0,
--- scale = 1,
--- spread = {x = 100, y = 100, z = 100},
--- seed = 23,
--- octaves = 3,
--- persistence = 0.7
--- }
--- ```
--- @type NoiseParams?
noise_params = nil,
--- List of biomes in which this ore occurs.
--- Occurs in all biomes if this is omitted, and ignored if the Mapgen
--- being used does not support biomes.
--- Can be a list of (or a single) biome names, IDs, or definitions.
--- Example: `{ "desert", "rainforest" }`
--- @type (string|integer|BiomeDefinition)[]?
biomes = {},
--- Used for `ore_type = "sheet"`
column_height_min = 1,
--- Used for `ore_type = "sheet"`
column_height_max = 16,
--- Used for `ore_type = "sheet"`
column_midpoint_factor = 0.5,
--- Used for `ore_type = "puff"`
np_puff_top = {
offset = 4,
scale = 2,
spread = {x = 100, y = 100, z = 100},
seed = 47,
octaves = 3,
persistence = 0.7
},
--- Used for `ore_type = "puff"`
np_puff_bottom = {
offset = 4,
scale = 2,
spread = {x = 100, y = 100, z = 100},
seed = 11,
octaves = 3,
persistence = 0.7
},
--- Used for `ore_type = "vein"`
random_factor = 1.0,
--- Used for `ore_type = "stratum"`
np_stratum_thickness = {
offset = 8,
scale = 4,
spread = {x = 100, y = 100, z = 100},
seed = 17,
octaves = 3,
persistence = 0.7
},
--- only used if no noise defined
stratum_thickness = 8,
}