From d53ea65da83de14efcf827b3b14c1b6cd47b0eaa Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 3 Apr 2023 14:32:02 +0000 Subject: [PATCH 01/24] Remove some code Some code has been moved to `mcl_mapgen_core` for consistency. --- mods/ITEMS/mcl_ocean/seagrass.lua | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index 26640aa3a..328328993 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -149,28 +149,3 @@ end if mod_doc then doc.add_entry_alias("nodes", "mcl_ocean:seagrass_dirt", "craftitems", "mcl_ocean:seagrass") end - -minetest.register_lbm({ - label = "Fix incorrect seagrass", - name = "mcl_ocean:fix_incorrect_seagrass", - nodenames = {"group:seagrass"}, - run_at_every_load = false, - action = function(pos, node) - if node.param2 ~= 3 then - node.param2 = 3 - minetest.set_node(pos, node) - end - end -}) - -minetest.register_on_generated(function(minp, maxp, blockseed) - local seagrass = minetest.find_nodes_in_area(minp, maxp, {"group:seagrass"}) - for _, sgpos in pairs(seagrass) do - local sgnode = minetest.get_node(sgpos) - if sgnode.param2 ~= 3 then - sgnode.param2 = 3 - minetest.set_node(sgpos, sgnode) - end - end -end -) From 76bf98b26c29f2a68163d9b04c8482007ef43379 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 3 Apr 2023 14:35:24 +0000 Subject: [PATCH 02/24] Use voxelmanip to set the correct param2 for nodes Voxelmanip is now used to set the correct `param2` for the nodes which use biome colouring or, in the case of seagrass, the correct meshoption. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 154 ++++++++++++++++++--------- 1 file changed, 106 insertions(+), 48 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 9e401a4ff..13aeb1841 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -290,6 +290,60 @@ local function set_grass_palette(minp,maxp,data2,area,biomemap,nodes) return lvm_used end +local function set_foliage_palette(minp,maxp,data2,area,biomemap,nodes) + -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: + if not biomemap then return end + local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) + local nodes = minetest.find_nodes_in_area(minp, maxp, nodes) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + local b_pos = aream:index(n.x, 0, n.z) + local bn = minetest.get_biome_name(biomemap[b_pos]) + if bn then + local biome = minetest.registered_biomes[bn] + if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index then + data2[p_pos] = biome._mcl_foliage_palette_index + lvm_used = true + end + end + end + return lvm_used +end + +local function set_water_palette(minp,maxp,data2,area,biomemap,nodes) + -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: + if not biomemap then return end + local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) + local nodes = minetest.find_nodes_in_area(minp, maxp, nodes) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + local b_pos = aream:index(n.x, 0, n.z) + local bn = minetest.get_biome_name(biomemap[b_pos]) + if bn then + local biome = minetest.registered_biomes[bn] + if biome and biome._mcl_biome_type and biome._mcl_water_palette_index then + data2[p_pos] = biome._mcl_water_palette_index + lvm_used = true + end + end + end + return lvm_used +end + +local function set_seagrass_param2(minp,maxp,data2,area,biomemap,nodes) + local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) + local nodes = minetest.find_nodes_in_area(minp, maxp, nodes) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + data2[p_pos] = 3 + lvm_used = true + end + return lvm_used +end + -- Below the bedrock, generate air/void local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap --ymin, ymax @@ -346,23 +400,47 @@ local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, bl end local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, blockseed) - if maxp.y < mcl_vars.mg_overworld_min then - --minetest.log("Exit grass fix") - return - else - --minetest.log("Grass fixes") - end - - local biomemap = minetest.get_mapgen_object("biomemap") - local lvm_used = false - - if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then - -- Set param2 (=color) of nodes which use the grass colour palette. - lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,{"group:grass_palette"}) - end - return lvm_used + local biomemap = minetest.get_mapgen_object("biomemap") + local lvm_used = false + local pr = PseudoRandom(blockseed) + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- Set param2 (=color) of nodes which use the grass colour palette. + lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,{"group:grass_palette"}) + end + return lvm_used end +local function block_fixes_foliage(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + local biomemap = minetest.get_mapgen_object("biomemap") + local lvm_used = false + local pr = PseudoRandom(blockseed) + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- Set param2 (=color) of nodes which use the foliage colour palette. + lvm_used = set_foliage_palette(minp,maxp,data2,area,biomemap,{"group:foliage_palette"}) + end + return lvm_used +end + +local function block_fixes_water(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + local biomemap = minetest.get_mapgen_object("biomemap") + local lvm_used = false + local pr = PseudoRandom(blockseed) + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- Set param2 (=color) of nodes which use the water colour palette. + lvm_used = set_water_palette(minp,maxp,data2,area,biomemap,{"group:water_palette"}) + end + return lvm_used +end + +local function block_fixes_seagrass(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + local lvm_used = false + local pr = PseudoRandom(blockseed) + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- Set param2 of seagrass to 3. + lvm_used = set_seagrass_param2(minp,maxp,data2,area,biomemap,{"group:seagrass"}) + end + return lvm_used +end -- End block fixes: local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) @@ -391,6 +469,9 @@ end, 9999, true) if mg_name ~= "v6" and mg_name ~= "singlenode" then mcl_mapgen_core.register_generator("block_fixes_grass", block_fixes_grass, nil, 9999, true) + mcl_mapgen_core.register_generator("block_fixes_foliage", block_fixes_foliage, nil, 9999, true) + mcl_mapgen_core.register_generator("block_fixes_water", block_fixes_water, nil, 9999, true) + mcl_mapgen_core.register_generator("block_fixes_seagrass", block_fixes_seagrass, nil, 9999, true) end if mg_name == "v6" then @@ -467,28 +548,6 @@ minetest.register_lbm({ end }) -minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of foliage in new mapblocks. - local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) - local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) - for _, fpos in pairs(foliage) do - local fnode = minetest.get_node(fpos) - local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(fpos).foliage_palette_index - if fnode.param2 ~= foliage_palette_index and fnode.name ~= "mcl_core:vine" then - fnode.param2 = foliage_palette_index - minetest.set_node(fpos, fnode) - elseif fnode.name == "mcl_core:vine" then - local biome_param2 = foliage_palette_index - local rotation_param2 = mcl_util.get_colorwallmounted_rotation(fpos) - local final_param2 = (biome_param2 * 8) + rotation_param2 - if fnode.param2 ~= final_param2 then - fnode.param2 = final_param2 - minetest.set_node(fpos, fnode) - end - end - end -end -) - minetest.register_lbm({ label = "Fix water palette indexes", -- Set correct palette indexes of water in old mapblocks. name = "mcl_mapgen_core:fix_water_palette_indexes", @@ -503,16 +562,15 @@ minetest.register_lbm({ end }) -minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of water in new mapblocks. - local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) - local water = minetest.find_nodes_in_area(pos1, pos2, {"group:water_palette"}) - for _, wpos in pairs(water) do - local wnode = minetest.get_node(wpos) - local water_palette_index = mcl_util.get_palette_indexes_from_pos(wpos).water_palette_index - if wnode.param2 ~= water_palette_index then - wnode.param2 = water_palette_index - minetest.set_node(wpos, wnode) +minetest.register_lbm({ + label = "Fix incorrect seagrass", -- Set correct param2 of seagrass in old mapblocks. + name = "mcl_mapgen_core:fix_incorrect_seagrass", + nodenames = {"group:seagrass"}, + run_at_every_load = false, + action = function(pos, node) + if node.param2 ~= 3 then + node.param2 = 3 + minetest.set_node(pos, node) end end -end -) +}) From d8d83dd21cbe3eda2b73f217fe5c73e0d7f1081a Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 4 Apr 2023 10:59:28 +0000 Subject: [PATCH 03/24] Make vines use voxelmanip colouring as well This commit adds some code to the `set_foliage_palette` function which checks for the `param2` of the foliage node in question to see whether or not said `param2` value is `0` upon first being generated. If it isn't, then it's safe to assume that said foliage is a vine, and therefore needs to use the other method of calculating the final `param2` value. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 13aeb1841..401532c07 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -302,9 +302,12 @@ local function set_foliage_palette(minp,maxp,data2,area,biomemap,nodes) local bn = minetest.get_biome_name(biomemap[b_pos]) if bn then local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index then + if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] == 0 then data2[p_pos] = biome._mcl_foliage_palette_index lvm_used = true + elseif biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] ~= 0 then + data2[p_pos] = (biome._mcl_foliage_palette_index * 8) + data2[p_pos] + lvm_used = true end end end @@ -416,7 +419,7 @@ local function block_fixes_foliage(vm, data, data2, emin, emax, area, minp, maxp local pr = PseudoRandom(blockseed) if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then -- Set param2 (=color) of nodes which use the foliage colour palette. - lvm_used = set_foliage_palette(minp,maxp,data2,area,biomemap,{"group:foliage_palette"}) + lvm_used = set_foliage_palette(minp,maxp,data2,area,biomemap,{"group:foliage_palette", "group:foliage_palette_wallmounted"}) end return lvm_used end From aac6af4c20e8453c526725c60dcbd6403bef9652 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 7 Apr 2023 07:30:05 +0000 Subject: [PATCH 04/24] Small change to account for mangrove leaves --- mods/MAPGEN/mcl_mapgen_core/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 401532c07..153da255b 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -305,7 +305,7 @@ local function set_foliage_palette(minp,maxp,data2,area,biomemap,nodes) if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] == 0 then data2[p_pos] = biome._mcl_foliage_palette_index lvm_used = true - elseif biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] ~= 0 then + elseif biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] > 1 then data2[p_pos] = (biome._mcl_foliage_palette_index * 8) + data2[p_pos] lvm_used = true end From d28dcb1b10b96fd8f3ea6ea7317d7710ccd73b6d Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 7 Apr 2023 07:36:01 +0000 Subject: [PATCH 05/24] Another small change to account for mangrove leaves This one should actually work as expected. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 153da255b..a6930bc2e 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -302,7 +302,7 @@ local function set_foliage_palette(minp,maxp,data2,area,biomemap,nodes) local bn = minetest.get_biome_name(biomemap[b_pos]) if bn then local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] == 0 then + if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] <= 1 then data2[p_pos] = biome._mcl_foliage_palette_index lvm_used = true elseif biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index and data2[p_pos] > 1 then From 01ac9ad685685666a87cda4cab6466dc97ef364a Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 16 Apr 2023 09:55:05 +0000 Subject: [PATCH 06/24] Add old method back for foliage This commit adds back the old `set_node` method for the foliage, since the foliage is much more difficult to work with via the VoxelManip method due to them being part of schematics that could span across mapblocks in some cases. The old method will complement the new one by running after the VoxelManip has done its job, and fixes any foliage that the VoxelManip had missed. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index a6930bc2e..8154bb66b 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -577,3 +577,25 @@ minetest.register_lbm({ end end }) + +minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of missed foliage. + local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) + local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) + for _, fpos in pairs(foliage) do + local fnode = minetest.get_node(fpos) + local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(fpos).foliage_palette_index + if fnode.param2 ~= foliage_palette_index and fnode.name ~= "mcl_core:vine" then + fnode.param2 = foliage_palette_index + minetest.set_node(fpos, fnode) + elseif fnode.name == "mcl_core:vine" then + local biome_param2 = foliage_palette_index + local rotation_param2 = mcl_util.get_colorwallmounted_rotation(fpos) + local final_param2 = (biome_param2 * 8) + rotation_param2 + if fnode.param2 ~= final_param2 then + fnode.param2 = final_param2 + minetest.set_node(fpos, fnode) + end + end + end +end +) From 31b65bac91745cb29f0038d6ad233e9b0d82569f Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sun, 16 Apr 2023 17:08:48 +0100 Subject: [PATCH 07/24] Move generator code to functions to aid in profiling --- mods/MAPGEN/mcl_mapgen_core/api.lua | 68 ++++++++++++++++++----------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/api.lua b/mods/MAPGEN/mcl_mapgen_core/api.lua index 630270444..978fb7cda 100644 --- a/mods/MAPGEN/mcl_mapgen_core/api.lua +++ b/mods/MAPGEN/mcl_mapgen_core/api.lua @@ -11,6 +11,43 @@ local function roundN(n, d) return math.floor(n * m + 0.5) / m end +local function run_generators (p1, p2, blockseed) + if nodes > 0 then + for _, rec in ipairs(registered_generators) do + if rec.nf then + rec.nf(p1, p2, blockseed) + end + end + end +end + +local function update_data (vm, data, data2) + -- Write stuff + vm:set_data(data) + if param2 > 0 then + vm:set_param2_data(data2) + end +end + +local function post_generator_processing(vm, minp, maxp, deco_used, deco_table, ore_used, ore_table) + if deco_table then + minetest.generate_decorations(vm,vector.new(minp.x,deco_table.min,minp.z),vector.new(maxp.x,deco_table.max,maxp.z)) + elseif deco_used then + minetest.generate_decorations(vm) + end + if ore_table then + minetest.generate_ores(vm,vector.new(minp.x,ore_table.min,minp.z),vector.new(maxp.x,ore_table.max,maxp.z)) + elseif ore_used then + minetest.generate_ores(vm) + end +end + +local function post_generator_processing_2(vm, p1, p2, shadow) + vm:calc_lighting(p1, p2, shadow) + vm:write_to_map() + vm:update_liquids() +end + minetest.register_on_generated(function(minp, maxp, blockseed) local t1 = os.clock() local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} @@ -49,34 +86,13 @@ minetest.register_on_generated(function(minp, maxp, blockseed) end if lvm_used then - -- Write stuff - vm:set_data(data) - if param2 > 0 then - vm:set_param2_data(data2) - end - if deco_table then - minetest.generate_decorations(vm,vector.new(minp.x,deco_table.min,minp.z),vector.new(maxp.x,deco_table.max,maxp.z)) - elseif deco_used then - minetest.generate_decorations(vm) - end - if ore_table then - minetest.generate_ores(vm,vector.new(minp.x,ore_table.min,minp.z),vector.new(maxp.x,ore_table.max,maxp.z)) - elseif ore_used then - minetest.generate_ores(vm) - end - vm:calc_lighting(p1, p2, shadow) - vm:write_to_map() - vm:update_liquids() + update_data (vm, data, data2) + post_generator_processing(vm, minp, maxp, deco_used, deco_table, ore_used, ore_table) + post_generator_processing_2(vm, p1, p2, shadow) end end - if nodes > 0 then - for _, rec in ipairs(registered_generators) do - if rec.nf then - rec.nf(p1, p2, blockseed) - end - end - end + run_generators (p1, p2, blockseed) mcl_vars.add_chunk(minp) if logging then @@ -84,6 +100,8 @@ minetest.register_on_generated(function(minp, maxp, blockseed) end end) + + function minetest.register_on_generated(node_function) mcl_mapgen_core.register_generator("mod_"..minetest.get_current_modname().."_"..tostring(#registered_generators+1), nil, node_function) end From 1015f5a569e2494cc9d8caaf9848b97fe416edfd Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sun, 16 Apr 2023 17:10:17 +0100 Subject: [PATCH 08/24] Optimize folliage fixes code --- mods/MAPGEN/mcl_mapgen_core/init.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 8154bb66b..467d02134 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -578,8 +578,11 @@ minetest.register_lbm({ end }) -minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of missed foliage. - local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) +-- We go outside x and y for where trees are placed next to a biome that has already been generated. +-- We go above maxp.y because trees can often get placed close to the top of a generated area and folliage may not +-- be coloured correctly. +local function fix_folliage_missed (minp, maxp) + local pos1, pos2 = vector.offset(minp, -4, 0, -4), vector.offset(maxp, 4, 10, 4) local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) for _, fpos in pairs(foliage) do local fnode = minetest.get_node(fpos) @@ -598,4 +601,10 @@ minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct pa end end end -) + +minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of missed foliage. + if maxp.y < 0 then + return + end + fix_folliage_missed (minp, maxp) +end) From 3b1464ecc88d73eb7d2c9c0d3276f4aeff05bd0e Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sun, 16 Apr 2023 17:49:27 +0100 Subject: [PATCH 09/24] Tweak leaf generator numbers to catch missed jungle leaves --- mods/MAPGEN/mcl_mapgen_core/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 467d02134..e6420f91d 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -582,7 +582,7 @@ minetest.register_lbm({ -- We go above maxp.y because trees can often get placed close to the top of a generated area and folliage may not -- be coloured correctly. local function fix_folliage_missed (minp, maxp) - local pos1, pos2 = vector.offset(minp, -4, 0, -4), vector.offset(maxp, 4, 10, 4) + local pos1, pos2 = vector.offset(minp, -6, 0, -6), vector.offset(maxp, 6, 14, 6) local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) for _, fpos in pairs(foliage) do local fnode = minetest.get_node(fpos) From 65aa185ffa7ed5d31aaed1498cca7392ede5e1bc Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Sat, 15 Apr 2023 17:09:37 +0200 Subject: [PATCH 10/24] global 'bed button' cooldown --- mods/ITEMS/mcl_beds/functions.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 56e4a232b..2ca620236 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -438,12 +438,14 @@ local playermessagecounter = {} It gets reset after 10 secs using a globalstep --]] +local chatbuttonused = false local globalstep_timer = 0 minetest.register_globalstep(function(dtime) globalstep_timer = globalstep_timer + dtime if globalstep_timer >= 10 then globalstep_timer = 0 playermessagecounter = {} + chatbuttonused = false end end) @@ -480,7 +482,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end if fields.defaultmessage then + if chatbuttonused then + minetest.chat_send_player(player:get_player_name(),S("Sorry, but you have to wait @1 seconds until you may use this button again!",tostring(math.ceil(10-globalstep_timer)))) + return + end + if (not exceeded_rate_limit(player:get_player_name())) and shout_priv_check(player) then + chatbuttonused = true minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), S("Hey! Would you guys mind sleeping?"))) end return From 326e805798d370fa16b4e483ea99972b4a8af94b Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Sat, 15 Apr 2023 17:11:47 +0200 Subject: [PATCH 11/24] update translation stuff --- mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr | 3 ++- mods/ITEMS/mcl_beds/locale/template.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr index ae035f3bb..97867b44b 100644 --- a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr +++ b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr @@ -45,4 +45,5 @@ Chat:=Chat: send!=senden! You are missing the 'shout' privilege! It's required in order to talk in chat...=Ihnen fehlt das 'shout' Privileg! Es wird benötigt, um im Chat reden zu können... You exceeded the maximum number of messages per 10 seconds!=Sie haben die maximale Anzahl an Chatnachrichten pro 10 Sekunden überschritten! -Hey! Would you guys mind sleeping?=Hey, würdet Ihr bitte zu Bett gehen? \ No newline at end of file +Hey! Would you guys mind sleeping?=Hey, würdet Ihr bitte zu Bett gehen? +Sorry, but you have to wait @1 seconds until you may use this button again!=Sie müssen leider noch @1 Sekunden warten, bevor sie diesen Knopf erneut benutzen können! \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/locale/template.txt b/mods/ITEMS/mcl_beds/locale/template.txt index dd58d74e8..42e59509e 100644 --- a/mods/ITEMS/mcl_beds/locale/template.txt +++ b/mods/ITEMS/mcl_beds/locale/template.txt @@ -45,4 +45,5 @@ Chat:= send!= You are missing the 'shout' privilege! It's required in order to talk in chat...= You exceeded the maximum number of messages per 10 seconds!= -Hey! Would you guys mind sleeping?= \ No newline at end of file +Hey! Would you guys mind sleeping?= +Sorry, but you have to wait @1 seconds until you may use this button again!= \ No newline at end of file From b374301ebfb8a4502ae81619140b75264957c08c Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Wed, 19 Apr 2023 13:54:25 +0100 Subject: [PATCH 12/24] Throttle applies to default or custom sleep message --- mods/ITEMS/mcl_beds/functions.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 2ca620236..59eea5f33 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -474,22 +474,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return end + local custom_sleep_message if fields.chatsubmit and fields.chatmessage ~= "" then - if (not exceeded_rate_limit(player:get_player_name())) and shout_priv_check(player) then - minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), fields.chatmessage)) - end - return + custom_sleep_message = fields.chatmessage end - if fields.defaultmessage then + if custom_sleep_message or fields.defaultmessage then if chatbuttonused then - minetest.chat_send_player(player:get_player_name(),S("Sorry, but you have to wait @1 seconds until you may use this button again!",tostring(math.ceil(10-globalstep_timer)))) + local time_to_wait = math.ceil(10-globalstep_timer) + minetest.chat_send_player(player:get_player_name(),S("Sorry, but you have to wait @1 seconds until you may use this button again!", tostring(time_to_wait))) return end if (not exceeded_rate_limit(player:get_player_name())) and shout_priv_check(player) then chatbuttonused = true - minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), S("Hey! Would you guys mind sleeping?"))) + local message = custom_sleep_message or S("Hey! Would you guys mind sleeping?") + minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), message)) end return end From cdb2bc20b08b670f73448d8789b9d425ae254739 Mon Sep 17 00:00:00 2001 From: Johannes Fritz Date: Thu, 13 Apr 2023 14:16:19 -0500 Subject: [PATCH 13/24] solar panels: No crash when minetest.get_natural_light() return nil --- .../REDSTONE/mesecons_solarpanel/init.lua | 51 +------------------ 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua index 7780cbfee..f4e63b78a 100644 --- a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua @@ -1,55 +1,8 @@ local S = minetest.get_translator(minetest.get_current_modname()) -local function path_to_sunlight_exists(position, light_level) - local neighbours = { - { x = 0, y = 0, z =-1 }, - { x = 0, y = 0, z = 1 }, - { x = 0, y =-1, z = 0 }, - { x = 0, y = 1, z = 0 }, - { x =-1, y = 0, z = 0 }, - { x = 1, y = 0, z = 0 }, - } - for i=1, #neighbours do - local offset = neighbours[i] - local position_new = vector.add( - position, - offset - ) - local light_level_new = minetest.get_node_light( - position_new, - nil - ) - if 15 == light_level_new then - -- found the sunlight - return true - elseif light_level_new > light_level then - -- search where light is brighter - if path_to_sunlight_exists( - position_new, - light_level_new - ) then - return true - end - end - end -end - local function sunlight_visible(position) - local light_level = mcl_util.get_natural_light (position) - if light_level >= 12 then - --minetest.log("Light is greater than 12") - return true - else - local time = minetest.get_timeofday() * 24000 - -- only check light level during day - if time > 6000 and time < 18000 then - light_level = minetest.get_node_light(position, nil) - if light_level >= 12 then - return path_to_sunlight_exists(position, 12) - end - end - end - return false + local light_level = mcl_util.get_natural_light(position) + return light_level ~= nil and light_level >= 12 end local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } From 5db1e1876c140bdec180d18828cd8b1c002e59c6 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Wed, 19 Apr 2023 19:32:21 +0200 Subject: [PATCH 14/24] playerbound music toggle (between 94e554aa1a and 5481f0109c) --- mods/PLAYER/mcl_music/init.lua | 118 ++++++++++++++----- mods/PLAYER/mcl_music/locale/mcl_music.de.tr | 7 ++ mods/PLAYER/mcl_music/locale/template.txt | 7 ++ 3 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 mods/PLAYER/mcl_music/locale/mcl_music.de.tr create mode 100644 mods/PLAYER/mcl_music/locale/template.txt diff --git a/mods/PLAYER/mcl_music/init.lua b/mods/PLAYER/mcl_music/init.lua index 0d2f9c52e..7f8be5acf 100644 --- a/mods/PLAYER/mcl_music/init.lua +++ b/mods/PLAYER/mcl_music/init.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) @@ -46,7 +48,7 @@ local function pick_track(dimension, underground) minetest.log("action", "[mcl_music] Playing track: " .. chosen_track .. ", for context: " .. track_key) return chosen_track else - --? + -- ? end return nil @@ -102,38 +104,40 @@ local function play() local day_count = minetest.get_day_count() for _, player in pairs(minetest.get_connected_players()) do - local player_name = player:get_player_name() - local hp = player:get_hp() - local pos = player:get_pos() - local dimension = mcl_worlds.pos_to_dimension(pos) + if not player:get_meta():get("mcl_music:disable") then + local player_name = player:get_player_name() + local hp = player:get_hp() + local pos = player:get_pos() + local dimension = mcl_worlds.pos_to_dimension(pos) - local listener = listeners[player_name] - local handle = listener and listener.handle + local listener = listeners[player_name] + local handle = listener and listener.handle - --local old_hp = listener and listener.hp - --local is_hp_changed = old_hp and (math.abs(old_hp - hp) > 0.00001) or false + --local old_hp = listener and listener.hp + --local is_hp_changed = old_hp and (math.abs(old_hp - hp) > 0.00001) or false - local old_dimension = listener and listener.dimension - local is_dimension_changed = old_dimension and (old_dimension ~= dimension) or false + local old_dimension = listener and listener.dimension + local is_dimension_changed = old_dimension and (old_dimension ~= dimension) or false - --minetest.log("handle: " .. dump (handle)) - if is_dimension_changed then - stop_music_for_listener_name(player_name) - if not listeners[player_name] then - listeners[player_name] = {} - end - listeners[player_name].hp = hp - listeners[player_name].dimension = dimension - elseif not handle and (not listener or (listener.day_count ~= day_count)) then - local underground = dimension == "overworld" and pos and pos.y < 0 - local track = pick_track(dimension, underground) - if track then - play_song(track, player_name, dimension, day_count) + -- minetest.log("handle: " .. dump (handle)) + if is_dimension_changed then + stop_music_for_listener_name(player_name) + if not listeners[player_name] then + listeners[player_name] = {} + end + listeners[player_name].hp = hp + listeners[player_name].dimension = dimension + elseif not handle and (not listener or (listener.day_count ~= day_count)) then + local underground = dimension == "overworld" and pos and pos.y < 0 + local track = pick_track(dimension, underground) + if track then + play_song(track, player_name, dimension, day_count) + else + --minetest.log("no track found. weird") + end else - --minetest.log("no track found. weird") + --minetest.log("else") end - else - --minetest.log("else") end end @@ -149,6 +153,10 @@ if music_enabled then stop_music_for_listener_name(player_name) end) + minetest.register_on_leaveplayer(function(player, timed_out) + listeners[player:get_player_name()] = nil + end) + minetest.register_on_respawnplayer(function(player) local player_name = player:get_player_name() stop_music_for_listener_name(player_name) @@ -156,3 +164,59 @@ if music_enabled then else minetest.log("action", "[mcl_music] In-game music is deactivated") end + +minetest.register_chatcommand("music", { + params = "[on|off|invert []]", + description = S("Turns music for yourself or another player on or off."), + func = function(sender_name, params) + local argtable = {} + for str in string.gmatch(params, "([^%s]+)") do + table.insert(argtable, str) + end + + local action = argtable[1] + local playername = argtable[2] + + local sender = minetest.get_player_by_name(sender_name) + local target_player = nil + + if not action or action == "" then action = "invert" end + + if not playername or playername == "" or sender_name == playername then + target_player = sender + playername =sender_name + elseif not minetest.check_player_privs(sender, "debug") then -- Self-use handled above + minetest.chat_send_player(sender_name, S("You need the debug privilege in order to turn ingame music on or off for somebody else!")) + return + else -- Admin + target_player = minetest.get_player_by_name(playername) + end + + if not target_player then + minetest.chat_send_player(sender_name, S("Couldn't find player @1!", playername)) + return + end + + local meta = target_player:get_meta() + local display_new_state = "unknown" -- Should never be displayed -> no translation + + if action == "invert" then + if not meta:get("mcl_music:disable") then + meta:set_int("mcl_music:disable", 1) + display_new_state = S("off") + else + meta:set_string("mcl_music:disable", "") -- This deletes the meta value! + display_new_state = S("on") + end + elseif action == "on" then + meta:set_string("mcl_music:disable", "") -- Delete + display_new_state = S("on") + else + meta:set_int("mcl_music:disable", 1) + display_new_state = S("off") + end + + stop_music_for_listener_name(playername) + minetest.chat_send_player(sender_name, S("Set music for @1 to: @2", playername, display_new_state)) + end, +}) \ No newline at end of file diff --git a/mods/PLAYER/mcl_music/locale/mcl_music.de.tr b/mods/PLAYER/mcl_music/locale/mcl_music.de.tr new file mode 100644 index 000000000..83621545f --- /dev/null +++ b/mods/PLAYER/mcl_music/locale/mcl_music.de.tr @@ -0,0 +1,7 @@ +# textdomain: mcl_music +You need the debug privilege in order to turn ingame music on or off for somebody else!=Sie benötigen das „debug“ Privileg, um die Musik (im Spiel) für jemand anders ein oder aus zu schalten! +Couldn't find player @1!= Spieler @1 konnte nicht gefunden werden! +Set music for @1 to: @2=Musik für @1 auf @2 gesetzt +Turns music for yourself or another player on or off.=Schaltet die Musik für Sie selbst oder jemand anders ein oder aus. +on=an +off=aus \ No newline at end of file diff --git a/mods/PLAYER/mcl_music/locale/template.txt b/mods/PLAYER/mcl_music/locale/template.txt new file mode 100644 index 000000000..66d60e9f5 --- /dev/null +++ b/mods/PLAYER/mcl_music/locale/template.txt @@ -0,0 +1,7 @@ +# textdomain: mcl_music +You need the debug privilege in order to turn ingame music on or off for somebody else!= +Couldn't find player @1!= +Set music for @1 to: @2= +Turns music for yourself or another player on or off.= +on= +off= \ No newline at end of file From 198eb630e1b12f75d9524f586fa1a5cc723106c7 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Tue, 4 Apr 2023 21:57:28 +0200 Subject: [PATCH 15/24] replace globalstep with abm --- mods/ITEMS/mcl_beacons/init.lua | 54 ++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 4614d5ce1..f0a3a15ef 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -178,6 +178,24 @@ local function beacon_blockcheck(pos) end end +local function is_obstructed(pos) --also removes beacon beam if true + + for y=pos.y+1, pos.y+100 do + + local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name + if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "mcl_core:void" and nodename ~= "ignore" then --ignore means not loaded, let's just assume that's air + if nodename ~="mcl_beacons:beacon_beam" then + if minetest.get_item_group(nodename,"glass") == 0 and minetest.get_item_group(nodename,"material_glass") == 0 then + remove_beacon_beam(pos) + return true + end + end + end + end + + return false +end + local function effect_player(effect,pos,power_level, effect_level,player) local distance = vector.distance(player:get_pos(), pos) if distance > (power_level+1)*10 then return end @@ -192,6 +210,7 @@ local function effect_player(effect,pos,power_level, effect_level,player) end end +--[[ local function globalstep_function(pos,player) local meta = minetest.get_meta(pos) local power_level = beacon_blockcheck(pos) @@ -219,6 +238,25 @@ local function globalstep_function(pos,player) effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),player) end end +--]] + +local function abm_func(pos) + local meta = minetest.get_meta(pos) + local power_level = beacon_blockcheck(pos) + local effect_string = meta:get_string("effect") + + if meta:get_int("effect_level") == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :Pi + return + end + + for _, obj in ipairs(minetest.get_objects_inside_radius(pos, (power_level+1)*10)) do + if obj:is_player() then + if not is_obstructed(pos) then + effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),obj) + end + end + end +end minetest.register_node("mcl_beacons:beacon", { description = S"Beacon", @@ -330,7 +368,8 @@ minetest.register_node("mcl_beacons:beacon", { minetest.set_node({x=pos.x,y=y,z=pos.z},{name="mcl_beacons:beacon_beam",param2=beam_palette_index}) end end - globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it + abm_func(pos) --call it once outside the globalstep so the player gets the effect right after selecting it + --globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it end end end, @@ -354,6 +393,7 @@ end local timer = 0 +--[[ minetest.register_globalstep(function(dtime) timer = timer + dtime if timer >= 3 then @@ -367,6 +407,7 @@ minetest.register_globalstep(function(dtime) timer = 0 end end) +--]] minetest.register_abm{ @@ -392,6 +433,17 @@ minetest.register_abm{ end, } + +minetest.register_abm{ + label="apply beacon effects to players", + nodenames = {"mcl_beacons:beacon"}, + interval = 3, + chance = 1, + action = function(pos) + abm_func(pos) -- for some FUC**** reason I can't just say abm_func directly, so this is a dirty workaround + end, +} + minetest.register_craft({ output = "mcl_beacons:beacon", recipe = { From 181cb73e45a3e8ddb404656cb58749ebf7330edb Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Tue, 4 Apr 2023 21:58:33 +0200 Subject: [PATCH 16/24] remove commented out code --- mods/ITEMS/mcl_beacons/init.lua | 49 +-------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index f0a3a15ef..12c483d4b 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -210,36 +210,6 @@ local function effect_player(effect,pos,power_level, effect_level,player) end end ---[[ -local function globalstep_function(pos,player) - local meta = minetest.get_meta(pos) - local power_level = beacon_blockcheck(pos) - local effect_string = meta:get_string("effect") - if meta:get_int("effect_level") == 2 and power_level < 4 then - return - else - local obstructed = false - for y=pos.y+1, pos.y+100 do - - local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name - if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "mcl_core:void" and nodename ~= "ignore" then --ignore means not loaded, let's just assume that's air - if nodename ~="mcl_beacons:beacon_beam" then - if minetest.get_item_group(nodename,"glass") == 0 and minetest.get_item_group(nodename,"material_glass") == 0 then - obstructed = true - remove_beacon_beam(pos) - return - end - end - end - end - if obstructed then - return - end - effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),player) - end -end ---]] - local function abm_func(pos) local meta = minetest.get_meta(pos) local power_level = beacon_blockcheck(pos) @@ -368,9 +338,7 @@ minetest.register_node("mcl_beacons:beacon", { minetest.set_node({x=pos.x,y=y,z=pos.z},{name="mcl_beacons:beacon_beam",param2=beam_palette_index}) end end - abm_func(pos) --call it once outside the globalstep so the player gets the effect right after selecting it - --globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it - end + abm_func(pos) --call it once outside the globalstep so the player gets the effect right after selecting it end end end, light_source = 14, @@ -393,21 +361,6 @@ end local timer = 0 ---[[ -minetest.register_globalstep(function(dtime) - timer = timer + dtime - if timer >= 3 then - for _, player in ipairs(minetest.get_connected_players()) do - local player_pos = player:get_pos() - local pos_list = minetest.find_nodes_in_area({x=player_pos.x-50, y=player_pos.y-50, z=player_pos.z-50}, {x=player_pos.x+50, y=player_pos.y+50, z=player_pos.z+50},"mcl_beacons:beacon") - for _, pos in ipairs(pos_list) do - globalstep_function(pos,player) - end - end - timer = 0 - end -end) ---]] minetest.register_abm{ From 80cde37e6517591715c466c8c5f5eb82ff531ded Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Tue, 4 Apr 2023 21:59:50 +0200 Subject: [PATCH 17/24] remove empty lines and unneeded code --- mods/ITEMS/mcl_beacons/init.lua | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 12c483d4b..ee9c5a67b 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -179,9 +179,7 @@ local function beacon_blockcheck(pos) end local function is_obstructed(pos) --also removes beacon beam if true - for y=pos.y+1, pos.y+100 do - local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "mcl_core:void" and nodename ~= "ignore" then --ignore means not loaded, let's just assume that's air if nodename ~="mcl_beacons:beacon_beam" then @@ -359,10 +357,6 @@ function register_beaconfuel(itemstring) table.insert(beacon_fuellist, itemstring) end -local timer = 0 - - - minetest.register_abm{ label="update beacon beam", nodenames = {"mcl_beacons:beacon_beam"}, @@ -386,7 +380,6 @@ minetest.register_abm{ end, } - minetest.register_abm{ label="apply beacon effects to players", nodenames = {"mcl_beacons:beacon"}, From 1a1473e8c0adfdf7697b7e9e944328958b3e2f56 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Tue, 4 Apr 2023 22:03:29 +0200 Subject: [PATCH 18/24] insert missing end --- mods/ITEMS/mcl_beacons/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index ee9c5a67b..0a13c87be 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -337,6 +337,7 @@ minetest.register_node("mcl_beacons:beacon", { end end abm_func(pos) --call it once outside the globalstep so the player gets the effect right after selecting it end + end end end, light_source = 14, From a8c989edd85dabc8878a594e4fafe61705aef604 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Wed, 19 Apr 2023 16:27:35 +0200 Subject: [PATCH 19/24] don't get all objects in radius --- mods/ITEMS/mcl_beacons/init.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 0a13c87be..e738aeec2 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -213,16 +213,15 @@ local function abm_func(pos) local power_level = beacon_blockcheck(pos) local effect_string = meta:get_string("effect") - if meta:get_int("effect_level") == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :Pi + if meta:get_int("effect_level") == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :P return end - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, (power_level+1)*10)) do - if obj:is_player() then - if not is_obstructed(pos) then - effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),obj) - end - end + for _, obj in pairs(minetest.get_connected_players()) do + if vector.distance(pos,obj:get_pos()) > (power_level+1)*10 then return end --I used Pythagoras at first, and ignored this method lol + if not is_obstructed(pos) then + effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),obj) + end end end From b15482012edc6187b2d8a46cc53655bc294e30f7 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Thu, 27 Apr 2023 19:04:36 +0100 Subject: [PATCH 20/24] Implement review feedback. --- mods/ITEMS/mcl_beacons/init.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index e738aeec2..30a80bc32 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -178,7 +178,7 @@ local function beacon_blockcheck(pos) end end -local function is_obstructed(pos) --also removes beacon beam if true +local function clear_obstructed_beam(pos) for y=pos.y+1, pos.y+100 do local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "mcl_core:void" and nodename ~= "ignore" then --ignore means not loaded, let's just assume that's air @@ -208,20 +208,25 @@ local function effect_player(effect,pos,power_level, effect_level,player) end end -local function abm_func(pos) - local meta = minetest.get_meta(pos) - local power_level = beacon_blockcheck(pos) +local function apply_effects_to_all_players(pos) + local meta = minetest.get_meta(pos) local effect_string = meta:get_string("effect") + local effect_level = meta:get_int("effect_level") - if meta:get_int("effect_level") == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :P + local power_level = beacon_blockcheck(pos) + + if effect_level == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :P return end - for _, obj in pairs(minetest.get_connected_players()) do - if vector.distance(pos,obj:get_pos()) > (power_level+1)*10 then return end --I used Pythagoras at first, and ignored this method lol - if not is_obstructed(pos) then - effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),obj) - end + local beacon_distance = (power_level + 1) * 10 + + for _, player in pairs(minetest.get_connected_players()) do + if vector.distance(pos, player:get_pos()) <= beacon_distance then + if not clear_obstructed_beam(pos) then + effect_player(effect_string, pos, power_level, effect_level, player) + end + end end end @@ -335,7 +340,7 @@ minetest.register_node("mcl_beacons:beacon", { minetest.set_node({x=pos.x,y=y,z=pos.z},{name="mcl_beacons:beacon_beam",param2=beam_palette_index}) end end - abm_func(pos) --call it once outside the globalstep so the player gets the effect right after selecting it end + apply_effects_to_all_players(pos) --call it once outside the globalstep so the player gets the effect right after selecting it end end end, @@ -386,7 +391,7 @@ minetest.register_abm{ interval = 3, chance = 1, action = function(pos) - abm_func(pos) -- for some FUC**** reason I can't just say abm_func directly, so this is a dirty workaround + apply_effects_to_all_players(pos) end, } From 7dc09e3ebdfa830a96b301d4a9da031582d9523b Mon Sep 17 00:00:00 2001 From: megustanlosfrijoles Date: Thu, 27 Apr 2023 19:50:10 +0000 Subject: [PATCH 21/24] Add spanish translations (#3659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I just added some translations to Spanish that were missing Co-authored-by: José Muñoz Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3659 Reviewed-by: ancientmarinerdev Co-authored-by: megustanlosfrijoles Co-committed-by: megustanlosfrijoles --- .../ENTITIES/mcl_boats/locale/mcl_boats.es.tr | 3 + .../mcl_paintings/locale/mcl_paintings.es.tr | 2 + .../locale/mcl_achievements.es.tr | 65 +++++++++++++++++++ mods/PLAYER/mcl_skins/locale/mcl_skins.es.tr | 14 ++++ 4 files changed, 84 insertions(+) create mode 100644 mods/ENTITIES/mcl_paintings/locale/mcl_paintings.es.tr create mode 100644 mods/PLAYER/mcl_skins/locale/mcl_skins.es.tr diff --git a/mods/ENTITIES/mcl_boats/locale/mcl_boats.es.tr b/mods/ENTITIES/mcl_boats/locale/mcl_boats.es.tr index 644efdb6b..d3596e056 100644 --- a/mods/ENTITIES/mcl_boats/locale/mcl_boats.es.tr +++ b/mods/ENTITIES/mcl_boats/locale/mcl_boats.es.tr @@ -8,3 +8,6 @@ Jungle Boat=Barca de la selva Oak Boat=Barca de roble Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Rightclick the boat again to leave it, punch the boat to make it drop as an item.=Haga clic derecho en una fuente de agua para colocar el barco. Haga clic derecho en el barco para entrar. Utilice [Izquierda] y [Derecha] para dirigir, [Adelante] para acelerar y [Atrás] para reducir la velocidad o retroceder. Haga clic derecho en el barco nuevamente para dejarlo, golpee el barco para que se caiga como un artículo. Spruce Boat=Barca de abeto +Water vehicle=Vehículo acuático +Sneak to dismount=Agáchate para bajar +Obsidian Boat=Barca de obsidiana diff --git a/mods/ENTITIES/mcl_paintings/locale/mcl_paintings.es.tr b/mods/ENTITIES/mcl_paintings/locale/mcl_paintings.es.tr new file mode 100644 index 000000000..d1e4d3f24 --- /dev/null +++ b/mods/ENTITIES/mcl_paintings/locale/mcl_paintings.es.tr @@ -0,0 +1,2 @@ +# textdomain:mcl_paintings +Painting=Cuadro diff --git a/mods/HUD/mcl_achievements/locale/mcl_achievements.es.tr b/mods/HUD/mcl_achievements/locale/mcl_achievements.es.tr index 2044e8261..c398bb14c 100644 --- a/mods/HUD/mcl_achievements/locale/mcl_achievements.es.tr +++ b/mods/HUD/mcl_achievements/locale/mcl_achievements.es.tr @@ -47,3 +47,68 @@ Use a crafting table to craft a wooden hoe from wooden planks and sticks.=Usa un Use a crafting table to craft a wooden pickaxe from wooden planks and sticks.=Usa una mesa de trabajo para hacer un pico de madera con tablas de madera procesada y palos de madera. Use obsidian and a fire starter to construct a Nether portal.=Usa obsidiana y un iniciador de fuego para construir un portal abisal. Use wheat to craft a bread.=Usa trigo para elaborar pan. +Who is Cutting Onions?=¿Quién esta cortando cebollas? +Pick up a crying obsidian from the floor.=Recoge una obsidiana llorosa del suelo +Hidden in the Depths=Oculto en las profundidades +Pick up an Ancient Debris from the floor.=Recoge un Escombro Ancestral del suelo +The Nether=El Nether +Bring summer clothes.@nHint: Enter the Nether.=Tráete ropa de verano.@nSugerencia: Entra al Nether +Isn't It Iron Pick=¿No es hierrónico? +Craft a iron pickaxe using sticks and iron.=Crea un pico de hierro usando palos y hierro. +Postmortal=Post mortem +Use a Totem of Undying to cheat death.=Usa un tótem de inmortalidad para engañar a la muerte +Sweet Dreams=Dulces sueños +Sleep in a bed to change your respawn point.=Duerme en una cama para cambiar tu punto de reaparición. +Not Quite "Nine" Lives=No "siete" vidas exactamente +Charge a Respawn Anchor to the maximum.=Carga un nexo de reaparición al máximo. +What A Deal!=¡Qué buen trato! +Successfully trade with a Villager.=Comercia con un aldeano. +Withering Heights=Dr. Witherstein +Summon the wither from the dead.=Invoca al wither desde los muertos. +The Cutest Predator=El depredador más lindo +Catch an Axolotl with a bucket!=Atrapa a un ajolote en un cubo +Fishy Business=Un asuno escamoso +Catch a fish.@nHint: Catch a fish, salmon, clownfish, or pufferfish.=Atrapa un pez.@nSugerencia: Atrapa un pez, salmón, pez payaso, o pez globo. +Country Lode, Take Me Home=Magnetita llévame a casita +Use a compass on a Lodestone.=Usa una brújula sobre una magnetita +Serious Dedication=Dedicación seria +Use a Netherite Ingot to upgrade a hoe, and then completely reevaluate your life choices.=Usa un lingote de netherita para mejorar una azada, y luego revalúa lo que estás haciendo con tu vida. +Local Brewery=Destilería local +Brew a Potion.@nHint: Take a potion or glass bottle out of the brewing stand.=Prepara una poción.@nSugerencia: Saca una poción o botella de vidrio de la destiladora +Enchanter=Aprendiz de mago +Enchant an item using an Enchantment Table.=Encanta un objeto usando la mesa de encantamientos +Bring Home the Beacon=Hágase la luz +Use a beacon.=Usa un faro. +Beaconator=Faroneitor +Use a fully powered beacon.=Utiliza un faro a máxima potencia. +The Next Generation=La nueva generación +Hold the Dragon Egg.@nHint: Pick up the egg from the ground and have it in your inventory.=Consigue el huevo de dragón.@nSugerencia: Recoge el huevo del suelo, y colócalo en tu inventario. +The End... Again...=El fin... de nuevo... +Respawn the Ender Dragon.=Vuelve a invocar al Enderdragón. +Sky's the Limit=El cielo es el límite +Find the elytra and prepare to fly above and beyond!=¿Encuentra los élitros y prepárate para volar al infinito y más allá! +Free the End=Libera el End +Kill the ender dragon. Good Luck!=Mata al Enderdragón. Buena suerte! +Bee Our Guest=Abelante, esta es tu casa +Use a campfire to collect a bottle of honey from a beehive without aggrivating the bees inside.=Usa una fogata y una botella para obtener miel de una colmena sin enojar a las abejas. +Total Beelocation=Abejémonos de aquí +Move a bee nest, with 3 bees inside, using a silk touch enchanted tool.=Mueve una colmena que tenga 3 abejas usando una herramienta con toque de seda. +Wax On=Encerando ando +Apply honeycomb to a copper block to protect it from the elements.=Encera un bloque de cobre con un panal de abejas para protegerlo de los elementos. +Wax Off=Pulir cera +Scrape wax off of a copper block.=Quita la cera de un bloque de cobre +The End?=¿El End? +Or the beginning?@nHint: Enter an end portal.=¿O el principio?@nSugerencia: Entra al portal del End +Stone Age=La edad de piedra +Mine a stone with new pickaxe.=Mina piedra con tu nuevo pico. +Ice Bucket Challenge=Mente fría +Obtain an obsidian block.=Consigue un bloque de obsidiana. +Hot Stuff=¡La cosa está que arde! +Put lava in a bucket.=Pon lava en un cubo. +Hero of the Village=Héroe de la aldea +Successfully defend a village from a raid=Defiende una aldea de una invasión +Voluntary Exile=Exilio voluntario +Kill a raid captain. Maybe consider staying away from the local villages for the time being...=Mata al capitán de una invasión. +Sería mejor alejarte de las aldeas por un tiempo... +Tactical Fishing=Pesca táctica +Catch a fish... without a fishing rod!=Atrapa a un pez... ¡sin una caña de pescar! diff --git a/mods/PLAYER/mcl_skins/locale/mcl_skins.es.tr b/mods/PLAYER/mcl_skins/locale/mcl_skins.es.tr new file mode 100644 index 000000000..840d1a520 --- /dev/null +++ b/mods/PLAYER/mcl_skins/locale/mcl_skins.es.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_skins +Skins=Aspectos +Templates=Plantillas +Arm size=Tamaño de los brazos +Bases=Bases +Footwears=Calzado +Eyes=Ojos +Mouths=Bocas +Bottoms=Parte inferior +Tops=Parte superior +Hairs=Cabellos +Headwears=Accesorios para la cabeza +Open skin configuration screen.=Abrir pantalla de configuración de aspectos +Select=Seleccionar From ec5b0903be5eb5abce822a2c7b87eef918452228 Mon Sep 17 00:00:00 2001 From: MrRar Date: Tue, 4 Apr 2023 14:05:15 -0600 Subject: [PATCH 22/24] Make enchanted elytra usable --- mods/PLAYER/mcl_playerplus/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 8ace0a9a9..782ac039e 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -239,7 +239,7 @@ minetest.register_globalstep(function(dtime) elytra.speed = 1 - (direction.y/2 + 0.5) end - elytra.active = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" + elytra.active = player:get_inventory():get_stack("armor", 3):get_name():find("mcl_armor:elytra") and not parent and (elytra.active or (is_just_jumped and player_velocity.y < -0)) and ((not minetest.registered_nodes[fly_node].walkable) or fly_node == "ignore") From 1a7f9fe8eccb69bda023de67a55897b73625d325 Mon Sep 17 00:00:00 2001 From: FlamingRCCars Date: Tue, 4 Apr 2023 14:06:41 -0600 Subject: [PATCH 23/24] Make elytra enchantable --- mods/ITEMS/mcl_armor/register.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_armor/register.lua b/mods/ITEMS/mcl_armor/register.lua index 89ff5ca9f..29a53003b 100644 --- a/mods/ITEMS/mcl_armor/register.lua +++ b/mods/ITEMS/mcl_armor/register.lua @@ -219,7 +219,7 @@ minetest.register_tool("mcl_armor:elytra", { _doc_items_longdesc = mcl_armor.longdesc, _doc_items_usagehelp = mcl_armor.usage, inventory_image = "mcl_armor_inv_elytra.png", - groups = {armor = 1, non_combat_armor = 1, armor_torso = 1, non_combat_torso = 1, mcl_armor_uses = 10}, + groups = {armor = 1, non_combat_armor = 1, armor_torso = 1, non_combat_torso = 1, mcl_armor_uses = 10, enchantability = 1}, sounds = { _mcl_armor_equip = "mcl_armor_equip_leather", _mcl_armor_unequip = "mcl_armor_unequip_leather", From b001e4e06f6de1c61d9a8a2f36a2f445fe330f33 Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Thu, 27 Apr 2023 13:16:15 -0600 Subject: [PATCH 24/24] Make elytra active checks use groups instead So that modders can easily add their own varients of elytra that work --- mods/ITEMS/mcl_armor/register.lua | 2 +- mods/PLAYER/mcl_playerplus/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_armor/register.lua b/mods/ITEMS/mcl_armor/register.lua index 29a53003b..c7fa91475 100644 --- a/mods/ITEMS/mcl_armor/register.lua +++ b/mods/ITEMS/mcl_armor/register.lua @@ -219,7 +219,7 @@ minetest.register_tool("mcl_armor:elytra", { _doc_items_longdesc = mcl_armor.longdesc, _doc_items_usagehelp = mcl_armor.usage, inventory_image = "mcl_armor_inv_elytra.png", - groups = {armor = 1, non_combat_armor = 1, armor_torso = 1, non_combat_torso = 1, mcl_armor_uses = 10, enchantability = 1}, + groups = {armor = 1, non_combat_armor = 1, armor_torso = 1, non_combat_torso = 1, mcl_armor_uses = 10, enchantability = 1, elytra = 1}, sounds = { _mcl_armor_equip = "mcl_armor_equip_leather", _mcl_armor_unequip = "mcl_armor_unequip_leather", diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 782ac039e..1de839456 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -239,7 +239,7 @@ minetest.register_globalstep(function(dtime) elytra.speed = 1 - (direction.y/2 + 0.5) end - elytra.active = player:get_inventory():get_stack("armor", 3):get_name():find("mcl_armor:elytra") + elytra.active = minetest.get_item_group(player:get_inventory():get_stack("armor", 3):get_name(), "elytra") ~= 0 and not parent and (elytra.active or (is_just_jumped and player_velocity.y < -0)) and ((not minetest.registered_nodes[fly_node].walkable) or fly_node == "ignore")