mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-26 21:03:45 +01:00
Defensive checks (#4328)
Fixes rare crashes related to some effects Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4328 Co-authored-by: the-real-herowl <wiktor_t-i@proton.me> Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
parent
8feecf2492
commit
cae554bc2b
@ -372,7 +372,9 @@ mcl_potions.register_effect({
|
|||||||
playerphysics.add_physics_factor(object, "gravity", "mcl_potions:slow_falling", 0.5)
|
playerphysics.add_physics_factor(object, "gravity", "mcl_potions:slow_falling", 0.5)
|
||||||
end,
|
end,
|
||||||
on_step = function(dtime, object, factor, duration)
|
on_step = function(dtime, object, factor, duration)
|
||||||
local vel = object:get_velocity().y
|
local vel = object:get_velocity()
|
||||||
|
if not vel then return end
|
||||||
|
vel = vel.y
|
||||||
if vel < -3 then object:add_velocity(vector.new(0,-3-vel,0)) end
|
if vel < -3 then object:add_velocity(vector.new(0,-3-vel,0)) end
|
||||||
end,
|
end,
|
||||||
on_end = function(object)
|
on_end = function(object)
|
||||||
@ -430,7 +432,9 @@ mcl_potions.register_effect({
|
|||||||
return S("moves body upwards at @1 nodes/s", factor)
|
return S("moves body upwards at @1 nodes/s", factor)
|
||||||
end,
|
end,
|
||||||
on_step = function(dtime, object, factor, duration)
|
on_step = function(dtime, object, factor, duration)
|
||||||
local vel = object:get_velocity().y
|
local vel = object:get_velocity()
|
||||||
|
if not vel then return end
|
||||||
|
vel = vel.y
|
||||||
if vel<factor then object:add_velocity(vector.new(0,factor,0)) end
|
if vel<factor then object:add_velocity(vector.new(0,factor,0)) end
|
||||||
end,
|
end,
|
||||||
particle_color = "#420E7E",
|
particle_color = "#420E7E",
|
||||||
@ -457,6 +461,7 @@ mcl_potions.register_effect({
|
|||||||
end,
|
end,
|
||||||
on_end = function(object)
|
on_end = function(object)
|
||||||
local meta = object:get_meta()
|
local meta = object:get_meta()
|
||||||
|
if not meta then return end
|
||||||
meta:set_int("night_vision", 0)
|
meta:set_int("night_vision", 0)
|
||||||
mcl_weather.skycolor.update_sky_color({object})
|
mcl_weather.skycolor.update_sky_color({object})
|
||||||
end,
|
end,
|
||||||
@ -499,7 +504,9 @@ mcl_potions.register_effect({
|
|||||||
mcl_weather.skycolor.update_sky_color({object})
|
mcl_weather.skycolor.update_sky_color({object})
|
||||||
end,
|
end,
|
||||||
on_end = function(object)
|
on_end = function(object)
|
||||||
object:get_meta():set_int("darkness", 0)
|
local meta = object:get_meta()
|
||||||
|
if not meta then return end
|
||||||
|
meta:set_int("darkness", 0)
|
||||||
mcl_weather.skycolor.update_sky_color({object})
|
mcl_weather.skycolor.update_sky_color({object})
|
||||||
object:set_sky({fog = {
|
object:set_sky({fog = {
|
||||||
fog_distance = -1,
|
fog_distance = -1,
|
||||||
|
Loading…
Reference in New Issue
Block a user