This commit is contained in:
Andrew Miner
2026-10-29 23:13:32 -06:00
parent 267349a830
commit 079df8575e
7 changed files with 127 additions and 59 deletions
+7 -9
View File
@@ -9,6 +9,8 @@ local Region = dofile(path.."/common/region.lua")
local table = dofile(path.."/common/table.lua")
local biomes = dofile(core.get_modpath("jvmi_biomes").."/mapenv.lua")
local check = dofile(core.get_game_info().path.."/common/check.lua")
local dump = dofile(core.get_game_info().path.."/common/dump.lua")
-- Constants ---------------------------------------------------------------------------------------
@@ -97,12 +99,12 @@ function private.assign_terrain_meta(region)
local band_end = raw_index + C.TERRAIN_BLEND / 2
local max_weight = 0
local blend = {}
for terrain_type, terrain in ipairs(TERRAIN_TYPES) do
local overlap_start = math.max(band_start, terrain.range_start)
local overlap_end = math.min(band_end, terrain.range_end)
local overlap = overlap_end - overlap_start
local blend = {}
if overlap > 0 then
local weight = overlap / C.TERRAIN_BLEND
table.append(blend, { weight = weight, terrain_type = terrain_type })
@@ -112,9 +114,9 @@ function private.assign_terrain_meta(region)
region:set_meta(Region.META.TERRAIN_TYPE, x, z, terrain_type)
end
end
region:set_meta(Region.META.TERRAIN_BLEND, x, z, blend)
end
region:set_meta(Region.META.TERRAIN_BLEND, x, z, blend)
end)
end
@@ -154,12 +156,8 @@ end
function private.fill_terrain(region)
region:iterate_fill(function(x, y, z)
local altitude = region:get_meta(Region.META.ALTITUDE, x, z)
if type(altitude) ~= "number" then
error(
"expected altitude at ("..x..","..z..") to be a number, "..
"but was a "..type(altitude)
)
end
check.is_type("altitude", altitude, "number")
if y > altitude then return end
region:set_content_id(x, y, z, STONE_ID)
end)