0
0
Fork 0

Effect loading fixes (#4425)

Reviewed-on: VoxeLibre/VoxeLibre#4425
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
This commit is contained in:
the-real-herowl 2024-06-13 13:21:36 +02:00 committed by the-real-herowl
parent 1f32b47208
commit 173f8a0bca
1 changed files with 12 additions and 0 deletions

View File

@ -456,6 +456,10 @@ mcl_potions.register_effect({
object:get_meta():set_int("night_vision", 1) object:get_meta():set_int("night_vision", 1)
mcl_weather.skycolor.update_sky_color({object}) mcl_weather.skycolor.update_sky_color({object})
end, end,
on_load = function(object, factor)
object:get_meta():set_int("night_vision", 1)
mcl_weather.skycolor.update_sky_color({object})
end,
on_step = function(dtime, object, factor, duration) on_step = function(dtime, object, factor, duration)
mcl_weather.skycolor.update_sky_color({object}) mcl_weather.skycolor.update_sky_color({object})
end, end,
@ -1525,6 +1529,11 @@ function mcl_potions._load_player_effects(player)
local loaded = minetest.deserialize(meta:get_string("mcl_potions:_EF_"..name)) local loaded = minetest.deserialize(meta:get_string("mcl_potions:_EF_"..name))
if loaded then if loaded then
EF[name][player] = loaded EF[name][player] = loaded
end
if EF[name][player] then -- this is needed because of legacy effects loaded separately
if effect.uses_factor and type(EF[name][player].factor) ~= "number" then
EF[name][player].factor = effect.level_to_factor(1)
end
if effect.on_load then if effect.on_load then
effect.on_load(player, EF[name][player].factor) effect.on_load(player, EF[name][player].factor)
end end
@ -1542,6 +1551,9 @@ function mcl_potions._load_entity_effects(entity)
local loaded = entity._mcl_potions["_EF_"..name] local loaded = entity._mcl_potions["_EF_"..name]
if loaded then if loaded then
EF[name][object] = loaded EF[name][object] = loaded
if effect.uses_factor and not loaded.factor then
EF[name][object].factor = effect.level_to_factor(1)
end
if effect.on_load then if effect.on_load then
effect.on_load(object, EF[name][object].factor) effect.on_load(object, EF[name][object].factor)
end end