1
0
Fork 0

Teach observer to detect TNT in realtime mode, fix crash in mcl_spawn on restart server in less than 30s in new world

This commit is contained in:
kay27 2021-01-17 02:47:04 +04:00
parent 5400cdba35
commit 5b44eeb611
2 changed files with 39 additions and 5 deletions

View File

@ -284,6 +284,7 @@ if realtime then
mcl_observers.set_node = minetest.set_node
mcl_observers.swap_node = minetest.swap_node
mcl_observers.remove_node = minetest.remove_node
mcl_observers.bulk_set_node = minetest.bulk_set_node
minetest.add_node=function(pos,node)
mcl_observers.add_node(pos,node)
@ -393,6 +394,35 @@ if realtime then
mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z})
end
end
minetest.bulk_set_node=function(lst, node)
mcl_observers.bulk_set_node(lst, node)
for _, pos in pairs(lst) do
local n=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})
if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==-1 then
mcl_observers.observer_activate({x=pos.x+1,y=pos.y,z=pos.z})
end
n=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})
if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).x==1 then
mcl_observers.observer_activate({x=pos.x-1,y=pos.y,z=pos.z})
end
n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})
if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==-1 then
mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z+1})
end
n=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})
if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_o" and minetest.facedir_to_dir(n.param2).z==1 then
mcl_observers.observer_activate({x=pos.x,y=pos.y,z=pos.z-1})
end
n=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_u" then
mcl_observers.observer_activate({x=pos.x,y=pos.y-1,z=pos.z})
end
n=minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if n and n.name and string.sub(n.name,1,24)=="mcl_observers:observer_d" then
mcl_observers.observer_activate({x=pos.x,y=pos.y+1,z=pos.z})
end
end
end
else -- if realtime then ^^^ else:
minetest.register_abm({

View File

@ -372,11 +372,15 @@ function mcl_spawn.shadow_worker()
minetest.after(respawn_search_interval, mcl_spawn.shadow_worker)
end
minetest.after(respawn_search_initial_delay, mcl_spawn.shadow_worker)
minetest.after(respawn_search_initial_delay, function()
mcl_spawn.shadow_worker()
minetest.register_on_shutdown(function()
storage:set_int("mcl_spawn_success", success and 1 or 0)
if wsp and wsp.x then
storage:set_string("mcl_spawn_world_spawn_point", minetest.pos_to_string(wsp))
end
storage:set_int("mcl_spawn_searched", searched and 1 or 0)
storage:set_int("mcl_spawn_check", check)
storage:set_string("mcl_spawn_cp", minetest.pos_to_string(cp))
@ -384,5 +388,5 @@ minetest.register_on_shutdown(function()
storage:set_int("mcl_spawn_edge_dist", edge_dist)
storage:set_int("mcl_spawn_dir_step", dir_step)
storage:set_int("mcl_spawn_dir_ind", dir_ind)
end
)
end)
end)