diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 9dadc3a0d4..736bd01be2 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -248,12 +248,11 @@ minetest.register_abm({ if dim == "end" then -- End portal in the End: -- Teleport back to the player's spawn or world spawn in the Overworld. - if obj:is_player() then - target = mcl_spawn.get_spawn_pos(obj) - else - target = mcl_spawn.get_world_spawn_pos(obj) + _, target = mcl_spawn.spawn(obj) end + + target = target or mcl_spawn.get_world_spawn_pos(obj) else -- End portal in any other dimension: -- Teleport to the End at a fixed position and generate a @@ -287,6 +286,7 @@ minetest.register_abm({ -- Teleport obj:set_pos(target) + if obj:is_player() then -- Look towards the main End island if dim ~= "end" then diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index ae23e122f9..8000e7aef7 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -122,8 +122,7 @@ local function good_for_respawn(pos) (def1.damage_per_second == nil or def2.damage_per_second <= 0) end --- Respawn player at specified respawn position -minetest.register_on_respawnplayer(function(player) +mcl_spawn.spawn = function(player) local pos, custom_spawn = mcl_spawn.get_spawn_pos(player) if pos and custom_spawn then -- Check if bed is still there @@ -155,12 +154,14 @@ minetest.register_on_respawnplayer(function(player) local spawn_pos = vector.add(pos, offset) if good_for_respawn(spawn_pos) then player:set_pos(spawn_pos) - return true + return true, spawn_pos end end -- We here if we didn't find suitable place for respawn: return false end -end) +end +-- Respawn player at specified respawn position +minetest.register_on_respawnplayer(mcl_spawn.spawn)