diff --git a/mods/API/Mod/init.lua b/mods/API/Mod/init.lua index 8eb9317..547fcee 100644 --- a/mods/API/Mod/init.lua +++ b/mods/API/Mod/init.lua @@ -62,3 +62,5 @@ function Mod:getModClassExtended(ChildClass) return childClass end + +return Mod \ No newline at end of file diff --git a/mods/API/Require/init.lua b/mods/API/Require/init.lua index c14549b..db889df 100644 --- a/mods/API/Require/init.lua +++ b/mods/API/Require/init.lua @@ -34,3 +34,5 @@ function Require.getModRequire(modName, modPath) return require end + +return Require \ No newline at end of file diff --git a/mods/CORE/MapGen/src/MapGen.lua b/mods/CORE/MapGen/src/MapGen.lua index 1f266b4..497e8e5 100644 --- a/mods/CORE/MapGen/src/MapGen.lua +++ b/mods/CORE/MapGen/src/MapGen.lua @@ -37,7 +37,7 @@ local pastNoise2DCalc = { } } -local modInfo = Mod.getInfo() +local modInfo = Mod.getInfo('smc__core__map_gen') local require = modInfo.require ---@type MapGen.Layer @@ -70,7 +70,7 @@ local MapGen = { isRunning = false, } ----@param nodeIDs table +---@param nodeIDs table ---@return MapGen function MapGen:new(nodeIDs) ---@type MapGen @@ -623,12 +623,15 @@ local function generatorHandler(mapGenerator, data, index, x, y, z) generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z) end +---@param voxelManip VoxelManip ---@param minPos table ---@param maxPos table ---@param blockseed number -function MapGen:onMapGenerated(minPos, maxPos, blockseed) +function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed) -- We obtain a generation area for further manipulations - local voxelManip, eMin, eMax = core.get_mapgen_object('voxelmanip') + --local voxelManip, eMin, eMax = core.get_mapgen_object('voxelmanip') + + local eMin, eMax = voxelManip:get_emerged_area() if not self.peaksMultinoiseInitialized then self:initPeaksMultinoise() @@ -665,7 +668,7 @@ function MapGen:onMapGenerated(minPos, maxPos, blockseed) voxelManip:calc_lighting() voxelManip:update_liquids() - voxelManip:write_to_map() + --voxelManip:write_to_map() -- Async edit end diff --git a/mods/CORE/MapGen/src/MapGen/Layer/Cavern.lua b/mods/CORE/MapGen/src/MapGen/Layer/Cavern.lua index fb74d03..f094510 100644 --- a/mods/CORE/MapGen/src/MapGen/Layer/Cavern.lua +++ b/mods/CORE/MapGen/src/MapGen/Layer/Cavern.lua @@ -63,9 +63,9 @@ function Cavern:new(name, def) end function instance:initNoise() - if not table.is_empty(_noise) then - minetest.log('warning', 'Cavern noise has already been initialized. Re-initialization is not recommended.') - end + --if not table.is_empty(_noise) then + -- minetest.log('warning', 'Cavern noise has already been initialized. Re-initialization is not recommended.') + --end _noise = core.get_value_noise(_noiseParams) end diff --git a/mods/CORE/MapGen/src/MapGen/Peak.lua b/mods/CORE/MapGen/src/MapGen/Peak.lua index de0726b..2a8803e 100644 --- a/mods/CORE/MapGen/src/MapGen/Peak.lua +++ b/mods/CORE/MapGen/src/MapGen/Peak.lua @@ -66,9 +66,9 @@ function Peak:new(peakPos, multinoiseParams, groups) end function instance:initMultinoise() - if not table.is_empty(_multinoise) then - minetest.log('warning', 'Multinoise has already been initialized. Re-initialization is not recommended.') - end + --if not table.is_empty(_multinoise) then + -- minetest.log('warning', 'Multinoise has already been initialized. Re-initialization is not recommended.') + --end _multinoise = multinoiseParamsToMultinoise(_multinoiseParams) end diff --git a/mods/CORE/MapGen/src/MapGen/Tetrahedron.lua b/mods/CORE/MapGen/src/MapGen/Tetrahedron.lua index 17b25a4..b723bb4 100644 --- a/mods/CORE/MapGen/src/MapGen/Tetrahedron.lua +++ b/mods/CORE/MapGen/src/MapGen/Tetrahedron.lua @@ -1,6 +1,6 @@ local mathAbs = math.abs -local modInfo = Mod.getInfo() +local modInfo = Mod.getInfo('smc__core__map_gen') local require = modInfo.require ---@type MapGen.Triangle diff --git a/mods/CORE/MapGen/src/MapGen/Triangle.lua b/mods/CORE/MapGen/src/MapGen/Triangle.lua index 7d20edd..2c96b39 100644 --- a/mods/CORE/MapGen/src/MapGen/Triangle.lua +++ b/mods/CORE/MapGen/src/MapGen/Triangle.lua @@ -1,7 +1,7 @@ local mathSqrt, mathAbs = math.sqrt, math.abs -local modInfo = Mod.getInfo() +local modInfo = Mod.getInfo('smc__core__map_gen') local require = modInfo.require ---@type MapGen.Triangulation.Edge diff --git a/mods/CORE/MapGen/src/MapGen/Triangulation.lua b/mods/CORE/MapGen/src/MapGen/Triangulation.lua index 5c73384..1c95c2b 100644 --- a/mods/CORE/MapGen/src/MapGen/Triangulation.lua +++ b/mods/CORE/MapGen/src/MapGen/Triangulation.lua @@ -12,7 +12,7 @@ local assert, mathMax, tableRemove = assert, math.max, table.remove -local modInfo = Mod.getInfo() +local modInfo = Mod.getInfo('smc__core__map_gen') local require = modInfo.require ---@type MapGen.Triangle diff --git a/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua b/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua index 51de3ce..2e854a8 100644 --- a/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua +++ b/mods/CORE/MapGen/src/MapGen/Triangulation/FakePeak.lua @@ -1,4 +1,4 @@ -local modInfo = Mod.getInfo() +local modInfo = Mod.getInfo('smc__core__map_gen') local require = modInfo.require ---@type MapGen.Peak diff --git a/mods/ENVIRONMENT/MapGenerator/MapGenerator.lua b/mods/ENVIRONMENT/MapGenerator/MapGenerator.lua new file mode 100644 index 0000000..07929eb --- /dev/null +++ b/mods/ENVIRONMENT/MapGenerator/MapGenerator.lua @@ -0,0 +1,146 @@ +-- MAPGEN ENVIROMENT ONLY + +local id = core.get_content_id + +Require = dofile(core.get_modpath('smc__api__require')..'/init.lua') + +---@type Mod +Mod = dofile(core.get_modpath('smc__api__mod')..'/init.lua') +print(core.get_modpath('smc__api__mod')..'/init.lua') + +local mapGenRequire = Mod.getInfo('smc__core__map_gen').require + +---@type MapGen +local MapGen = mapGenRequire('MapGen') + +---@type MapGen +local mapGenerator = MapGen:new({ + -- Special nodes + air = id("air"), + + -- Rocks + sylite = id("rocks:sylite"), + tauitite = id("rocks:tauitite"), + iyellite = id("rocks:iyellite"), + falmyte = id("rocks:falmyte"), + hapcoryte = id("rocks:hapcoryte"), + burcite = id("rocks:burcite"), + felhor = id("rocks:felhor"), + malachite = id("rocks:malachite"), + + -- Liquids + water = id("liquids:water_source"), +}) + +mapGenerator:RegisterLayer("world", -1000, 500) + +local land1 = { + offset = -20, + scale = 5, + spread = {x = 10, y = 10, z = 10}, + seed = 47, + octaves = 3, + persistence = 0.4, + lacunarity = 2, +} + +local land2 = { + offset = 20, + scale = 5, + spread = {x = 10, y = 10, z = 10}, + seed = 47, + octaves = 3, + persistence = 0.4, + lacunarity = 2, +} + +local climat1 = { + offset = 80, + scale = 10, + spread = {x = 10, y = 10, z = 10}, + seed = 47, + octaves = 8, + persistence = 0.6, + lacunarity = 2, +} + +local climat2 = { + offset = 30, + scale = 10, + spread = {x = 10, y = 10, z = 10}, + seed = 47, + octaves = 8, + persistence = 0.6, + lacunarity = 2, +} + +local climat0 = { + offset = 50, + scale = 0, + spread = {x = 10, y = 10, z = 10}, + seed = 47, + octaves = 8, + persistence = 0.4, + lacunarity = 2, +} + +local v = vector.new + +mapGenerator:register2DPeaks("world", +{ + landscapeNoise = land1, + tempNoise = climat2, + humidityNoise = climat2, +},{ + v(500, 0, 500), + v(-500, 0, -500), + v(-500, 0, 500), + v(500, 0, -500), +}) + +mapGenerator:register2DPeaks("world", +{ + landscapeNoise = land2, + tempNoise = climat1, + humidityNoise = climat1, +},{ + v(-300, 0, 300), + v(200, 0, -400), +}) + +mapGenerator:register2DPeaks("world", +{ + landscapeNoise = land2, + tempNoise = climat2, + humidityNoise = climat2, +},{ + v(200, 0, 100), + v(-300, 0, -200), +}) + +mapGenerator:registerCavern('world', 'cavern1', { + minY = -100, + maxY = -10, + smoothDistance = 20, + noiseParams ={ + offset = 0, + scale = 1, + spread = {x = 25, y = 25, z = 25}, + seed = 5934, + octaves = 3, + persistence = 0.5, + lacunarity = 2.0 + }, +}) + +mapGenerator:registerBiome('world', "biome1", 0, 0, { + soil = "soils:clay_soil_baren", + turf = "soils:clay_soil_baren", +}, 1) + +mapGenerator:registerBiome('world', "biome2", 100, 100, { + soil = "soils:rocky_soil_baren", + turf = "soils:rocky_soil_baren", +}, 1) + +mapGenerator:run() \ No newline at end of file diff --git a/mods/ENVIRONMENT/MapGenerator/init.lua b/mods/ENVIRONMENT/MapGenerator/init.lua index f1be003..a5c1b29 100644 --- a/mods/ENVIRONMENT/MapGenerator/init.lua +++ b/mods/ENVIRONMENT/MapGenerator/init.lua @@ -1,147 +1 @@ -local id = core.get_content_id - ----@type MapGen -local mapGenerator = Core.MapGen.Class:new({ - -- Special nodes - air = id("air"), - - -- Rocks - sylite = id("rocks:sylite"), - tauitite = id("rocks:tauitite"), - iyellite = id("rocks:iyellite"), - falmyte = id("rocks:falmyte"), - hapcoryte = id("rocks:hapcoryte"), - burcite = id("rocks:burcite"), - felhor = id("rocks:felhor"), - malachite = id("rocks:malachite"), - - -- Liquids - water = id("liquids:water_source"), -}) - -mapGenerator:RegisterLayer("world", -1000, 500) - -local land1 = { - offset = -20, - scale = 5, - spread = {x = 10, y = 10, z = 10}, - seed = 47, - octaves = 3, - persistence = 0.4, - lacunarity = 2, -} - -local land2 = { - offset = 20, - scale = 5, - spread = {x = 10, y = 10, z = 10}, - seed = 47, - octaves = 3, - persistence = 0.4, - lacunarity = 2, -} - -local climat1 = { - offset = 80, - scale = 10, - spread = {x = 10, y = 10, z = 10}, - seed = 47, - octaves = 8, - persistence = 0.6, - lacunarity = 2, -} - -local climat2 = { - offset = 30, - scale = 10, - spread = {x = 10, y = 10, z = 10}, - seed = 47, - octaves = 8, - persistence = 0.6, - lacunarity = 2, -} - -local climat0 = { - offset = 50, - scale = 0, - spread = {x = 10, y = 10, z = 10}, - seed = 47, - octaves = 8, - persistence = 0.4, - lacunarity = 2, -} - -local v = vector.new - -mapGenerator:register2DPeaks("world", -{ - landscapeNoise = land1, - tempNoise = climat2, - humidityNoise = climat2, -},{ - v(500, 0, 500), - v(-500, 0, -500), - v(-500, 0, 500), - v(500, 0, -500), -}) - -mapGenerator:register2DPeaks("world", -{ - landscapeNoise = land2, - tempNoise = climat1, - humidityNoise = climat1, -},{ - v(-300, 0, 300), - v(200, 0, -400), -}) - -mapGenerator:register2DPeaks("world", -{ - landscapeNoise = land2, - tempNoise = climat2, - humidityNoise = climat2, -},{ - v(200, 0, 100), - v(-300, 0, -200), -}) - -mapGenerator:registerCavern('world', 'cavern1', -100, -10, 20, { - offset = 0, - scale = 1, - spread = {x = 25, y = 25, z = 25}, - seed = 5934, - octaves = 3, - persistence = 0.5, - lacunarity = 2.0 -}) - -mapGenerator:registerBiome('world', "biome1", 0, 0, { - soil = "soils:clay_soil_baren", - turf = "soils:clay_soil_baren", -}, 1) - -mapGenerator:registerBiome('world', "biome2", 100, 100, { - soil = "soils:rocky_soil_baren", - turf = "soils:rocky_soil_baren", -}, 1) - -mapGenerator:run() - -minetest.register_ore({ - ore_type = "blob", - ore = "soils:clay_soil_baren", - wherein = {"rocks:iyellite", "rocks:falmyte"}, - clust_scarcity = 16 * 16 * 16, - clust_size = 5, - y_max = 0, - y_min = -3100, - noise_threshold = 0.0, - noise_params = { - offset = 1, - scale = 0.5, - spread = {x = 5, y = 5, z = 5}, - seed = 2316, - octaves = 1, - persist = 0.0 - }, -}) \ No newline at end of file +core.register_mapgen_script(core.get_modpath(core.get_current_modname())..'/MapGenerator.lua') \ No newline at end of file