From 176ddba1761fe0d9a7031dae7873033e7f089084 Mon Sep 17 00:00:00 2001 From: DS Date: Sun, 26 Jan 2020 18:59:44 +0100 Subject: [PATCH] Reset spawn position on bed destruction --- mods/beds/api.lua | 2 ++ mods/beds/spawns.lua | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/mods/beds/api.lua b/mods/beds/api.lua index c545a201..cab2def5 100644 --- a/mods/beds/api.lua +++ b/mods/beds/api.lua @@ -17,6 +17,8 @@ local function destruct_bed(pos, n) reverse = not reverse minetest.remove_node(other) minetest.check_for_falling(other) + beds.remove_spawns_at(pos) + beds.remove_spawns_at(other) else reverse = not reverse end diff --git a/mods/beds/spawns.lua b/mods/beds/spawns.lua index baee364d..1a2ce810 100644 --- a/mods/beds/spawns.lua +++ b/mods/beds/spawns.lua @@ -61,3 +61,12 @@ function beds.set_spawns() end beds.save_spawns() end + +function beds.remove_spawns_at(pos) + for name, p in pairs(beds.spawn) do + if vector.equals(vector.round(p), pos) then + beds.spawn[name] = nil + end + end + beds.save_spawns() +end -- 2.25.1