1
0
Fork 0

Update mcl_mapgen and mcl_time

This commit is contained in:
kay27 2022-03-14 20:32:36 +04:00
parent ca37c60511
commit 74257f5ff2
8 changed files with 61 additions and 45 deletions

View File

@ -14,28 +14,28 @@ local order = { -- mcl_mapgen.order...
-- Begin of Compatibility stuff -- Begin of Compatibility stuff
local function unsigned(v) local function unsigned(v)
if v < 0 then if v < 0 then
v = 0x100000000 - (math.abs(v) % 0x100000000) v = 0x100000000 - (math.abs(v) % 0x100000000)
end end
return v % 0x100000000 return v % 0x100000000
end end
if bit == nil then if bit == nil then
bit = {} bit = {}
function bit.bxor(a, b) function bit.bxor(a, b)
local a = unsigned(a) local a = unsigned(a)
local b = unsigned(b) local b = unsigned(b)
local c = 0 local c = 0
for n = 31, 0, -1 do for n = 31, 0, -1 do
local mask = math.floor(2^n) local mask = math.floor(2^n)
if (a >= mask) ~= (b >= mask) then if (a >= mask) ~= (b >= mask) then
c = c + mask c = c + mask
end end
a = a % mask a = a % mask
b = b % mask b = b % mask
end end
return c return c
end end
end end
if vector.metatable == nil then if vector.metatable == nil then
@ -455,7 +455,7 @@ mcl_mapgen.bedrock_is_rough = normal
overworld.min = -62 overworld.min = -62
if superflat then if superflat then
mcl_mapgen.ground = tonumber(minetest.get_mapgen_setting("mgflat_ground_level")) or 8 mcl_mapgen.ground = tonumber(minetest.get_mapgen_setting("mgflat_ground_level")) or 8
overworld.min = ground - 3 overworld.min = mcl_mapgen.ground - 3
end end
-- if singlenode then mcl_mapgen.overworld.min = -66 end -- DONT KNOW WHY -- if singlenode then mcl_mapgen.overworld.min = -66 end -- DONT KNOW WHY
overworld.max = mcl_mapgen.EDGE_MAX overworld.max = mcl_mapgen.EDGE_MAX

View File

@ -1,4 +1,4 @@
# mcl_time v2.0 # mcl_time v2.2
## by kay27 for MineClone 5 ## by kay27 for MineClone 5
--------------------------- ---------------------------
This mod counts time when all players sleep or some area is inactive. This mod counts time when all players sleep or some area is inactive.

View File

@ -61,10 +61,10 @@ local function get_seconds_irl()
next_save_seconds_irl = seconds_irl + save_to_storage_interval next_save_seconds_irl = seconds_irl + save_to_storage_interval
end end
return seconds_irl return math.floor(seconds_irl)
end end
local seconds_irl_public = get_seconds_irl() seconds_irl_public = get_seconds_irl()
function mcl_time.get_seconds_irl() function mcl_time.get_seconds_irl()
return seconds_irl_public 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 meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name) local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public) 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 return number_of_times
end end
@ -125,7 +125,7 @@ function mcl_time.get_irl_seconds_passed_at_pos(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name) local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public) 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 return irl_seconds_passed
end end
@ -135,7 +135,7 @@ function mcl_time.get_irl_seconds_passed_at_pos_or_1(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name) local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public) 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 return irl_seconds_passed
end end
@ -145,9 +145,10 @@ function mcl_time.get_irl_seconds_passed_at_pos_or_nil(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name) local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public) 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 local delta_time = seconds_irl_public - last_time
if delta_time <= 0 then return end if delta_time <= 0 then return end
meta:set_int(meta_name, seconds_irl_public)
return delta_time return delta_time
end end

View File

@ -0,0 +1 @@
-- moved into mcl_structures

View File

@ -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

View File

@ -1,5 +1,4 @@
local step = 1 local step = 1
local chunk_borders = false
local levels = { local levels = {
[-9] = "black", [-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) local noise_offset_x_and_z = math_floor(mcl_mapgen.CS_NODES/2)
mcl_mapgen.register_mapgen(function(minp, maxp, seed, vm_context) mcl_mapgen.register_mapgen(function(minp, maxp, seed, vm_context)
local y0 = minp.y if minetest.settings:get_bool("mcl_debug_struct_noise", false) then
for x0 = minp.x, maxp.x, step do local y0 = minp.y
for z0 = minp.z, maxp.z, step do for x0 = minp.x, maxp.x, 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}) for z0 = minp.z, maxp.z, step do
local amount 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})
if current_noise_level < 0 then local amount
amount = math_max(math_ceil(current_noise_level * 9), -9) if current_noise_level < 0 then
else amount = math_max(math_ceil(current_noise_level * 9), -9)
amount = math_min(math_floor(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 end
local y0 = maxp.y - 9 + amount
minetest.set_node({x=x0, y=y0, z=z0}, {name = "mcl_core:glass_"..levels[amount]})
end end
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 x0 = minp.x, maxp.x, step do
for y0 = minp.y, maxp.y, step do for y0 = minp.y, maxp.y, step do
minetest.set_node({x=x0, y=y0, z=maxp.z}, {name = "mcl_core:glass"}) 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"}) minetest.set_node({x=maxp.x, y=y0, z=z0}, {name = "mcl_core:glass"})
end end
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
end, 99999999999999) end, 999999999999)

View File

@ -1,6 +1,6 @@
mcl_villages = {} mcl_villages = {}
local chance_per_chunk = 90 local chance_per_chunk = 100
local chunk_offset_top = 15 local chunk_offset_top = 16
local chunk_offset_bottom = 3 local chunk_offset_bottom = 3
local max_height_difference = 12 local max_height_difference = 12
local minp_min = -64 local minp_min = -64
@ -436,7 +436,7 @@ local function build_a_village(minp, maxp, pr, placer)
end end
-- Disable natural generation in singlenode. -- 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_last_node = mcl_mapgen.LAST_BLOCK * mcl_mapgen.BS - 1
local scan_offset = mcl_mapgen.BS local scan_offset = mcl_mapgen.BS
mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed) mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed)

View File

@ -160,3 +160,5 @@ enable_real_maps (Enable Real Maps) bool true
[Debugging] [Debugging]
# If enabled, this will show the itemstring of an item in the description. # If enabled, this will show the itemstring of an item in the description.
mcl_item_id_debug (Item ID Debug) bool false 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