1
0
Fork 0

Merge pull request 'Fix beacon crash' (#4342) from teknomunk/MineClone2:fix-beacon-crash into master

Reviewed-on: VoxeLibre/VoxeLibre#4342
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
This commit is contained in:
the-real-herowl 2024-05-30 11:19:19 +00:00
commit f53bedc131
3 changed files with 38 additions and 18 deletions

View File

@ -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
@ -212,24 +215,30 @@ 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
local new_effect_string = EFFECT_CONVERSIONS[effect_string]
if new_effect_string then
effect_string = new_effect_string
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
@ -244,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)
@ -363,7 +371,6 @@ minetest.register_node("mcl_beacons:beacon", {
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)
end
@ -426,6 +433,15 @@ minetest.register_abm{
apply_effects_to_all_players(pos)
end,
}
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", formspec_string)
end
})
minetest.register_craft({
output = "mcl_beacons:beacon",

View File

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

View File

@ -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 "..tostring(name))
return false
end
if not registered_effects[name].uses_factor then
return mcl_potions.give_effect(name, object, 0, duration, no_particles)
end