This commit is contained in:
Andrew Miner
2026-10-30 21:16:18 -06:00
parent cac0557036
commit a1ee82308c
18 changed files with 381 additions and 155 deletions
+6 -7
View File
@@ -1,14 +1,13 @@
-- Imports & Exports -------------------------------------------------------------------------------
-- Imports -----------------------------------------------------------------------------------------
local core = _G.core
local jvmi = _G.jvmi
-- Registrations -----------------------------------------------------------------------------------
local path = core.get_modpath("jvmi_mapgen")
core.register_mapgen_script(path.."/mapenv.lua")
local mod = jvmi.register_mod("jvmi_mapgen")
-- Script ------------------------------------------------------------------------------------------
core.log("info", "jvmi_mapgen loaded")
if jvmi.env == "main" then
core.register_mapgen_script(mod.base_dir.."/mapgen.lua")
end
@@ -1,16 +1,14 @@
-- Imports & Exports -------------------------------------------------------------------------------
local core = _G.core
local jvmi = _G.jvmi
local vector = _G.vector
local path = core.get_game_info().path
local C = dofile(path.."/common/constants.lua")
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")
local biomes = jvmi.require_mod("jvmi_biomes")
local C = jvmi.C
local check = jvmi.check
local Region = jvmi.Region
local table = jvmi.table
-- Constants ---------------------------------------------------------------------------------------
@@ -19,7 +17,8 @@ local A = C.ALTITUDE
local TERRAIN_TYPES = nil
local TERRAIN_TYPE_NOISE = nil
-- Common Node Content Ids -----------------------------------------------------
-- Content Ids -----------------------------------------------------
local AIR_ID = core.CONTENT_AIR
local BEDROCK_ID = core.get_content_id("jvmi_nodes:bedrock")
@@ -193,6 +192,31 @@ function private.on_load()
TERRAIN_TYPE_NOISE = core.get_value_noise(C.TERRAIN_TYPE_NOISE_PARAMS)
end
--[[
Starting from scratch, populate all the blocks in the indicated region.
Args:
voxels:VoxelManip - a voxel manipulator containing the current state of the region
fill_min:vector - the lowest corner of the region to fill
fill_max:vector - the highest corner of the region to fill
]]--
function private.populate_region(voxels, fill_min, fill_max)
local region = private.region
region:read_voxels(voxels, fill_min, fill_max)
private.assign_terrain_meta(region)
private.assign_altitudes(region)
private.fill_terrain(region)
private.fill_bedrock(region)
private.fill_ocean(region)
biomes.apply_to(region)
region:save_voxels()
end
--[[
Clone the `C.TERRAIN_TYPES` table and add pre-computed values to it.
@@ -227,26 +251,7 @@ function private.prepare_terrain_table()
end
-- Registrations -----------------------------------------------------------------------------------
core.register_on_generated(function(voxels, fill_min, fill_max)
local region = private.region
region:read_voxels(voxels, fill_min, fill_max)
private.assign_terrain_meta(region)
private.assign_altitudes(region)
private.fill_terrain(region)
private.fill_bedrock(region)
private.fill_ocean(region)
biomes.apply_to(region)
region:save_voxels()
end)
-- Script ------------------------------------------------------------------------------------------
private.on_load()
core.register_on_generated(private.populate_region)