From 1144006cdd77993daf8a1f37e8775d2f077ba06a Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 4 Apr 2021 15:16:06 +0200 Subject: [PATCH] Add End main island generation --- mods/MAPGEN/mcl_end_island/init.lua | 36 +++++++++++++++++++++++++++++ mods/MAPGEN/mcl_end_island/mod.conf | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 mods/MAPGEN/mcl_end_island/init.lua create mode 100644 mods/MAPGEN/mcl_end_island/mod.conf diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua new file mode 100644 index 00000000..fb062bf7 --- /dev/null +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -0,0 +1,36 @@ +local noisemap = PerlinNoiseMap({ + offset = 0.5, + scale = 0.5, + spread = {x = 84, y = 84, z = 84}, + seed = minetest.get_mapgen_setting("seed") + 99999, + octaves = 4, + persist = 0.85, +}, {x = 151, y = 30, z = 151}):get_3d_map({x = 0, y = 0, z = 0}) + +local c_end_stone = minetest.get_content_id("mcl_end:end_stone") + +local x_offset = mcl_vars.mg_end_platform_pos.x - 27 +local y_offset = -2 + +minetest.register_on_generated(function(minp, maxp) + if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < (-75 + x_offset) or minp.x > (75 + x_offset) or maxp.z < -75 or minp.z > 75 then + return + end + + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local data = vm:get_data() + local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) + + for idx in area:iter(math.max(minp.x, -75 + x_offset), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -75), math.min(maxp.x, 75 + x_offset), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, 75)) do + local pos = area:position(idx) + local y = 27025 + pos.y - y_offset + if noisemap[pos.x + 75 - x_offset + 1][y + 1][pos.z + 75 + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs((pos.x - x_offset) / 75) ^ 2 + math.abs(pos.z / 75) ^ 2) then + data[idx] = c_end_stone + end + end + + vm:set_data(data) + vm:calc_lighting() + vm:update_liquids() + vm:write_to_map() +end) diff --git a/mods/MAPGEN/mcl_end_island/mod.conf b/mods/MAPGEN/mcl_end_island/mod.conf new file mode 100644 index 00000000..90432792 --- /dev/null +++ b/mods/MAPGEN/mcl_end_island/mod.conf @@ -0,0 +1,4 @@ +name = mcl_end_island +author = Fleckenstein +depends = mcl_mapgen_core, mcl_end +description = Generate the end main island for MCL2