From 6497916adec46519df18230acaca52b196980ed0 Mon Sep 17 00:00:00 2001 From: nickolas360 Date: Thu, 28 Feb 2019 15:35:18 +0100 Subject: [PATCH] Fix spawning at bed when chunk is unloaded --- mods/PLAYER/mcl_spawn/init.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index 5c8a797eb..bf8c1344d 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -60,15 +60,24 @@ mcl_spawn.set_spawn_pos = function(player, pos, message) return spawn_changed end +local function get_far_node(pos) + local node = minetest.get_node(pos) + if node.name ~= "ignore" then + return node + end + minetest.get_voxel_manip():read_from_map(pos, pos) + return minetest.get_node(pos) +end + -- Respawn player at specified respawn position minetest.register_on_respawnplayer(function(player) local pos, custom_spawn = mcl_spawn.get_spawn_pos(player) if pos and custom_spawn then -- Check if bed is still there -- and the spawning position is free of solid or damaging blocks. - local node_bed = minetest.get_node(pos) - local node_up1 = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) - local node_up2 = minetest.get_node({x=pos.x,y=pos.y+2,z=pos.z}) + local node_bed = get_far_node(pos) + local node_up1 = get_far_node({x=pos.x,y=pos.y+1,z=pos.z}) + local node_up2 = get_far_node({x=pos.x,y=pos.y+2,z=pos.z}) local bgroup = minetest.get_item_group(node_bed.name, "bed") local def1 = minetest.registered_nodes[node_up1.name] local def2 = minetest.registered_nodes[node_up2.name]