From 74257f5ff22e2505059e382804d68880516cb1c3 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 14 Mar 2022 20:32:36 +0400 Subject: [PATCH] Update mcl_mapgen and mcl_time --- mods/CORE/mcl_mapgen/init.lua | 40 +++++++++---------- mods/CORE/mcl_time/README.md | 2 +- mods/CORE/mcl_time/init.lua | 13 +++--- mods/MAPGEN/mcl_strongholds/init.lua | 1 + mods/MAPGEN/mcl_strongholds/mod.conf | 3 ++ .../MAPGEN/mcl_structures/noise_indicator.lua | 37 ++++++++++------- mods/MAPGEN/mcl_villages/init.lua | 6 +-- settingtypes.txt | 4 +- 8 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 mods/MAPGEN/mcl_strongholds/init.lua create mode 100644 mods/MAPGEN/mcl_strongholds/mod.conf diff --git a/mods/CORE/mcl_mapgen/init.lua b/mods/CORE/mcl_mapgen/init.lua index 1efde8bcf..6f4442d81 100644 --- a/mods/CORE/mcl_mapgen/init.lua +++ b/mods/CORE/mcl_mapgen/init.lua @@ -14,28 +14,28 @@ local order = { -- mcl_mapgen.order... -- Begin of Compatibility stuff local function unsigned(v) - if v < 0 then - v = 0x100000000 - (math.abs(v) % 0x100000000) - end - return v % 0x100000000 + if v < 0 then + v = 0x100000000 - (math.abs(v) % 0x100000000) + end + return v % 0x100000000 end if bit == nil then - bit = {} - function bit.bxor(a, b) - local a = unsigned(a) - local b = unsigned(b) - local c = 0 - for n = 31, 0, -1 do - local mask = math.floor(2^n) - if (a >= mask) ~= (b >= mask) then - c = c + mask - end - a = a % mask - b = b % mask - end - return c - end + bit = {} + function bit.bxor(a, b) + local a = unsigned(a) + local b = unsigned(b) + local c = 0 + for n = 31, 0, -1 do + local mask = math.floor(2^n) + if (a >= mask) ~= (b >= mask) then + c = c + mask + end + a = a % mask + b = b % mask + end + return c + end end if vector.metatable == nil then @@ -455,7 +455,7 @@ mcl_mapgen.bedrock_is_rough = normal overworld.min = -62 if superflat then mcl_mapgen.ground = tonumber(minetest.get_mapgen_setting("mgflat_ground_level")) or 8 - overworld.min = ground - 3 + overworld.min = mcl_mapgen.ground - 3 end -- if singlenode then mcl_mapgen.overworld.min = -66 end -- DONT KNOW WHY overworld.max = mcl_mapgen.EDGE_MAX diff --git a/mods/CORE/mcl_time/README.md b/mods/CORE/mcl_time/README.md index 24a4cd1cd..ff4263f3f 100644 --- a/mods/CORE/mcl_time/README.md +++ b/mods/CORE/mcl_time/README.md @@ -1,4 +1,4 @@ -# mcl_time v2.0 +# mcl_time v2.2 ## by kay27 for MineClone 5 --------------------------- This mod counts time when all players sleep or some area is inactive. diff --git a/mods/CORE/mcl_time/init.lua b/mods/CORE/mcl_time/init.lua index 2d7e93f9e..90e6df6b6 100644 --- a/mods/CORE/mcl_time/init.lua +++ b/mods/CORE/mcl_time/init.lua @@ -61,10 +61,10 @@ local function get_seconds_irl() next_save_seconds_irl = seconds_irl + save_to_storage_interval end - return seconds_irl + return math.floor(seconds_irl) end -local seconds_irl_public = get_seconds_irl() +seconds_irl_public = get_seconds_irl() function mcl_time.get_seconds_irl() return seconds_irl_public @@ -102,7 +102,7 @@ function mcl_time.get_number_of_times_at_pos(pos, interval, chance) local meta = minetest.get_meta(pos) local last_time = meta:get_int(meta_name) meta:set_int(meta_name, seconds_irl_public) - local number_of_times = (last_time == 0) and 0 or get_number_of_times(last_time, interval, chance) + local number_of_times = (last_time <= 0) and 0 or get_number_of_times(last_time, interval, chance) return number_of_times end @@ -125,7 +125,7 @@ function mcl_time.get_irl_seconds_passed_at_pos(pos) local meta = minetest.get_meta(pos) local last_time = meta:get_int(meta_name) meta:set_int(meta_name, seconds_irl_public) - local irl_seconds_passed = (last_time == 0) and 0 or (seconds_irl_public - last_time) + local irl_seconds_passed = (last_time <= 0) and 0 or (seconds_irl_public - last_time) return irl_seconds_passed end @@ -135,7 +135,7 @@ function mcl_time.get_irl_seconds_passed_at_pos_or_1(pos) local meta = minetest.get_meta(pos) local last_time = meta:get_int(meta_name) meta:set_int(meta_name, seconds_irl_public) - local irl_seconds_passed = (last_time == 0) and 1 or (seconds_irl_public - last_time) + local irl_seconds_passed = (last_time <= 0) and 1 or (seconds_irl_public - last_time) return irl_seconds_passed end @@ -145,9 +145,10 @@ function mcl_time.get_irl_seconds_passed_at_pos_or_nil(pos) local meta = minetest.get_meta(pos) local last_time = meta:get_int(meta_name) meta:set_int(meta_name, seconds_irl_public) - if last_time == 0 then return end + if last_time <= 0 then return end local delta_time = seconds_irl_public - last_time if delta_time <= 0 then return end + meta:set_int(meta_name, seconds_irl_public) return delta_time end diff --git a/mods/MAPGEN/mcl_strongholds/init.lua b/mods/MAPGEN/mcl_strongholds/init.lua new file mode 100644 index 000000000..f46218e15 --- /dev/null +++ b/mods/MAPGEN/mcl_strongholds/init.lua @@ -0,0 +1 @@ +-- moved into mcl_structures diff --git a/mods/MAPGEN/mcl_strongholds/mod.conf b/mods/MAPGEN/mcl_strongholds/mod.conf new file mode 100644 index 000000000..0c52f6f13 --- /dev/null +++ b/mods/MAPGEN/mcl_strongholds/mod.conf @@ -0,0 +1,3 @@ +name = mcl_strongholds +author = Wuzzy +description = Mod has been moved into mcl_structures. This is a dummy thing to overwrite the old thing, kay27 01/25/22 diff --git a/mods/MAPGEN/mcl_structures/noise_indicator.lua b/mods/MAPGEN/mcl_structures/noise_indicator.lua index 0a3038bb2..3845e5784 100644 --- a/mods/MAPGEN/mcl_structures/noise_indicator.lua +++ b/mods/MAPGEN/mcl_structures/noise_indicator.lua @@ -1,5 +1,4 @@ local step = 1 -local chunk_borders = false local levels = { [-9] = "black", @@ -31,21 +30,24 @@ local mcl_structures_get_perlin_noise_level = mcl_structures.get_perlin_noise_le local noise_offset_x_and_z = math_floor(mcl_mapgen.CS_NODES/2) mcl_mapgen.register_mapgen(function(minp, maxp, seed, vm_context) - local y0 = minp.y - for x0 = minp.x, maxp.x, step do - for z0 = minp.z, maxp.z, step do - local current_noise_level = mcl_structures_get_perlin_noise_level({x = x0 - noise_offset_x_and_z, y = y0, z = z0 - noise_offset_x_and_z}) - local amount - if current_noise_level < 0 then - amount = math_max(math_ceil(current_noise_level * 9), -9) - else - amount = math_min(math_floor(current_noise_level * 9), 9) + if minetest.settings:get_bool("mcl_debug_struct_noise", false) then + local y0 = minp.y + for x0 = minp.x, maxp.x, step do + for z0 = minp.z, maxp.z, step do + local current_noise_level = mcl_structures_get_perlin_noise_level({x = x0 - noise_offset_x_and_z, y = y0, z = z0 - noise_offset_x_and_z}) + local amount + if current_noise_level < 0 then + amount = math_max(math_ceil(current_noise_level * 9), -9) + else + amount = math_min(math_floor(current_noise_level * 9), 9) + end + local y0 = maxp.y - 9 + amount + minetest.set_node({x=x0, y=y0, z=z0}, {name = "mcl_core:glass_"..levels[amount]}) end - local y0 = maxp.y - 9 + amount - minetest.set_node({x=x0, y=y0, z=z0}, {name = "mcl_core:glass_"..levels[amount]}) end end - if chunk_borders then + + if minetest.settings:get_bool("mcl_debug_chunk_borders", false) then for x0 = minp.x, maxp.x, step do for y0 = minp.y, maxp.y, step do minetest.set_node({x=x0, y=y0, z=maxp.z}, {name = "mcl_core:glass"}) @@ -56,5 +58,12 @@ mcl_mapgen.register_mapgen(function(minp, maxp, seed, vm_context) minetest.set_node({x=maxp.x, y=y0, z=z0}, {name = "mcl_core:glass"}) end end + for z0 = minp.z, maxp.z, step do + for x0 = minp.x, maxp.x, step do + minetest.set_node({x=x0, y=maxp.y, z=z0}, {name = "mcl_core:glass"}) + end + end + if not minetest.settings:get_bool("mcl_debug_struct_noise", false) then + end end -end, 99999999999999) +end, 999999999999) diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index 55b1df887..37052a9b6 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -1,6 +1,6 @@ mcl_villages = {} -local chance_per_chunk = 90 -local chunk_offset_top = 15 +local chance_per_chunk = 100 +local chunk_offset_top = 16 local chunk_offset_bottom = 3 local max_height_difference = 12 local minp_min = -64 @@ -436,7 +436,7 @@ local function build_a_village(minp, maxp, pr, placer) end -- Disable natural generation in singlenode. -if mcl_mapgen.name ~= "singlenode" then +if not mcl_mapgen.singlenode then local scan_last_node = mcl_mapgen.LAST_BLOCK * mcl_mapgen.BS - 1 local scan_offset = mcl_mapgen.BS mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed) diff --git a/settingtypes.txt b/settingtypes.txt index 542711675..2681d79dd 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -159,4 +159,6 @@ enable_real_maps (Enable Real Maps) bool true [Debugging] # If enabled, this will show the itemstring of an item in the description. -mcl_item_id_debug (Item ID Debug) bool false \ No newline at end of file +mcl_item_id_debug (Item ID Debug) bool false +mcl_debug_struct_noise (Show Structures Perlin Noise) bool false +mcl_debug_chunk_borders (Show Chunk Borders) bool false