From c7e43e31d4e6c1a161b57f64338fc1b6db5ddccb Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 28 May 2024 19:05:00 -0500 Subject: [PATCH 1/7] Convert crash to a warning --- mods/ITEMS/mcl_potions/functions.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 90ac35004..fc03b9012 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -1832,6 +1832,10 @@ end function mcl_potions.give_effect_by_level(name, object, level, duration, no_particles) if level == 0 then return false end + if not registered_effects[name] then + minetest.log("warning", "[mcl_potions] Trying to give unknown effect "..name) + return false + end if not registered_effects[name].uses_factor then return mcl_potions.give_effect(name, object, 0, duration, no_particles) end From 95228500a9466b3b016bcb9c45dba57da11a473e Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 28 May 2024 20:02:58 -0500 Subject: [PATCH 2/7] Don't crash when name == nil --- mods/ITEMS/mcl_potions/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index fc03b9012..429c177bb 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -1833,7 +1833,7 @@ end function mcl_potions.give_effect_by_level(name, object, level, duration, no_particles) if level == 0 then return false end if not registered_effects[name] then - minetest.log("warning", "[mcl_potions] Trying to give unknown effect "..name) + minetest.log("warning", "[mcl_potions] Trying to give unknown effect "..tostring(name)) return false end if not registered_effects[name].uses_factor then From 2fc3d9255038baf0711e16a38cb35d547d22a77c Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 28 May 2024 20:19:51 -0500 Subject: [PATCH 3/7] Convert 'strenght' to 'strength' in beacons and guard against no effect string metadata set, fix whitespace in mcl_beacons/init.lua --- mods/ITEMS/mcl_beacons/init.lua | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 953d036d3..f2d2916f7 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -159,7 +159,7 @@ local function remove_beacon_beam(pos) minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z}) node = minetest.get_node({x=pos.x,y=y,z=pos.z}) end - + if node.name == "mcl_beacons:beacon_beam" then minetest.remove_node({x=pos.x,y=y,z=pos.z}) end @@ -212,24 +212,29 @@ local function effect_player(effect,pos,power_level, effect_level,player) end local function apply_effects_to_all_players(pos) - local meta = minetest.get_meta(pos) + local meta = minetest.get_meta(pos) local effect_string = meta:get_string("effect") - local effect_level = meta:get_int("effect_level") + local effect_level = meta:get_int("effect_level") - local power_level = beacon_blockcheck(pos) + 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 + if effect_string == "strenght" then + effect_string = "strength" + meta:set_string("effect", effect_string) + end + + if effect_string == "" or ( effect_level == 2 and power_level < 4 ) then --no need to run loops when beacon is in an invalid setup :P return end - local beacon_distance = (power_level + 1) * 10 + 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 + 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 @@ -271,7 +276,7 @@ minetest.register_node("mcl_beacons:beacon", { local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local input = inv:get_stack("input",1) - + if input:is_empty() then return end @@ -353,7 +358,7 @@ minetest.register_node("mcl_beacons:beacon", { awards.unlock(sender:get_player_name(),"mcl:beacon") input:take_item() inv:set_stack("input",1,input) - + local beam_palette_index = 0 remove_beacon_beam(pos) for y = pos.y +1, pos.y + 201 do @@ -362,7 +367,6 @@ minetest.register_node("mcl_beacons:beacon", { minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z}) node = minetest.get_node({x=pos.x,y=y,z=pos.z}) end - if minetest.get_item_group(node.name, "glass") ~= 0 or minetest.get_item_group(node.name,"material_glass") ~= 0 then beam_palette_index = get_beacon_beam(node.name) From 468c2bc68fdbe44d817d3f9dc9a838e01c9ad13f Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 29 May 2024 06:26:22 -0500 Subject: [PATCH 4/7] Change to conversion table --- mods/ITEMS/mcl_beacons/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index f2d2916f7..20dc63dd1 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -84,6 +84,9 @@ local pallete_order = { pane_magenta_flat = 16, pane_magenta = 16 } +local EFFECT_CONVERSIONS = { + strenght = "strength" +} local function get_beacon_beam(glass_nodename) if glass_nodename == "air" then return 0 end @@ -218,8 +221,9 @@ local function apply_effects_to_all_players(pos) local power_level = beacon_blockcheck(pos) - if effect_string == "strenght" then - effect_string = "strength" + local new_effect_string = EFFECT_CONVERSION[effect_string] + if new_effect_string then + effect_string = new_effect_string meta:set_string("effect", effect_string) end From 7d0f49a21880f984394b5a891cdf700f6da4ab9c Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 29 May 2024 06:33:59 -0500 Subject: [PATCH 5/7] Fix typo --- mods/ITEMS/mcl_beacons/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 20dc63dd1..1ef0d8db3 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -221,7 +221,7 @@ local function apply_effects_to_all_players(pos) local power_level = beacon_blockcheck(pos) - local new_effect_string = EFFECT_CONVERSION[effect_string] + local new_effect_string = EFFECT_CONVERSIONS[effect_string] if new_effect_string then effect_string = new_effect_string meta:set_string("effect", effect_string) From f621e3c1de391ed23c287fe327d8d62554599514 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 29 May 2024 06:45:51 -0500 Subject: [PATCH 6/7] Fix up formspecs on pre-0.87.0 beacons, fix typo --- mods/ITEMS/mcl_beacons/init.lua | 13 ++++++++++--- mods/ITEMS/mcl_hoppers/init.lua | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 1ef0d8db3..398d1173f 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -253,8 +253,7 @@ minetest.register_node("mcl_beacons:beacon", { local meta = minetest.get_meta(pos) local inv = meta:get_inventory() inv:set_size("input", 1) - local form = formspec_string - meta:set_string("formspec", form) + meta:set_string("formspec", formspec_string) end, on_destruct = function(pos) local meta = minetest.get_meta(pos) @@ -434,10 +433,18 @@ minetest.register_abm{ apply_effects_to_all_players(pos) end, } +minetest.register_lbm({ + label = "Update beacon formspecs (0.87.1)", + nodenames = { "mcl_beacons:beacon" }, + action = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", form) + end +}) minetest.register_craft({ output = "mcl_beacons:beacon", - recipe = { + recipe = { {"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"}, {"mcl_core:glass", "mcl_mobitems:nether_star", "mcl_core:glass"}, {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"} diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 7577e01cc..ec7f7ab8f 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -654,7 +654,7 @@ end minetest.register_alias("mcl_hoppers:hopper_item", "mcl_hoppers:hopper") minetest.register_lbm({ - label = "Update hopper formspecs (0.60.0", + label = "Update hopper formspecs (0.60.0)", name = "mcl_hoppers:update_formspec_0_60_0", nodenames = {"group:hopper"}, run_at_every_load = false, From 6c8771485c4c4785b9287dce837c4102724e03f2 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 29 May 2024 06:50:02 -0500 Subject: [PATCH 7/7] Fix variable name --- mods/ITEMS/mcl_beacons/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 398d1173f..ef6f6cb65 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -435,10 +435,11 @@ minetest.register_abm{ } minetest.register_lbm({ label = "Update beacon formspecs (0.87.1)", + name = "mcl_beacons:update_beacon_formspecs_0_87_1", nodenames = { "mcl_beacons:beacon" }, action = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("formspec", form) + meta:set_string("formspec", formspec_string) end })