This commit is contained in:
Elias Fleckenstein 2021-01-06 13:01:27 +01:00
parent 034174390d
commit 3787b95e0f
2 changed files with 9 additions and 8 deletions

View File

@ -248,12 +248,11 @@ minetest.register_abm({
if dim == "end" then if dim == "end" then
-- End portal in the End: -- End portal in the End:
-- Teleport back to the player's spawn or world spawn in the Overworld. -- Teleport back to the player's spawn or world spawn in the Overworld.
if obj:is_player() then if obj:is_player() then
target = mcl_spawn.get_spawn_pos(obj) _, target = mcl_spawn.spawn(obj)
else
target = mcl_spawn.get_world_spawn_pos(obj)
end end
target = target or mcl_spawn.get_world_spawn_pos(obj)
else else
-- End portal in any other dimension: -- End portal in any other dimension:
-- Teleport to the End at a fixed position and generate a -- Teleport to the End at a fixed position and generate a
@ -287,6 +286,7 @@ minetest.register_abm({
-- Teleport -- Teleport
obj:set_pos(target) obj:set_pos(target)
if obj:is_player() then if obj:is_player() then
-- Look towards the main End island -- Look towards the main End island
if dim ~= "end" then if dim ~= "end" then

View File

@ -122,8 +122,7 @@ local function good_for_respawn(pos)
(def1.damage_per_second == nil or def2.damage_per_second <= 0) (def1.damage_per_second == nil or def2.damage_per_second <= 0)
end end
-- Respawn player at specified respawn position mcl_spawn.spawn = function(player)
minetest.register_on_respawnplayer(function(player)
local pos, custom_spawn = mcl_spawn.get_spawn_pos(player) local pos, custom_spawn = mcl_spawn.get_spawn_pos(player)
if pos and custom_spawn then if pos and custom_spawn then
-- Check if bed is still there -- Check if bed is still there
@ -155,12 +154,14 @@ minetest.register_on_respawnplayer(function(player)
local spawn_pos = vector.add(pos, offset) local spawn_pos = vector.add(pos, offset)
if good_for_respawn(spawn_pos) then if good_for_respawn(spawn_pos) then
player:set_pos(spawn_pos) player:set_pos(spawn_pos)
return true return true, spawn_pos
end end
end end
-- We here if we didn't find suitable place for respawn: -- We here if we didn't find suitable place for respawn:
return false return false
end end
end) end
-- Respawn player at specified respawn position
minetest.register_on_respawnplayer(mcl_spawn.spawn)