From 3787b95e0f28f8e21b1c2e6ac1b68772379336fe Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 6 Jan 2021 13:01:27 +0100 Subject: [PATCH] Fix #700 --- mods/ITEMS/mcl_portals/portal_end.lua | 8 ++++---- mods/PLAYER/mcl_spawn/init.lua | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) 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)