From 0591b0ad76858eca90dc1e127b1f0d423c0529ae Mon Sep 17 00:00:00 2001 From: kilbith Date: Sat, 2 Apr 2016 17:53:28 +0200 Subject: [PATCH] Enchant Table / Item Frame : don't spawn entities if node get destructed shortly after joining --- enchanting.lua | 10 +++++++++- itemframe.lua | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/enchanting.lua b/enchanting.lua index 416a6f5..b26cbf3 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -180,7 +180,15 @@ minetest.register_entity("xdecor:book_open", { visual_size = {x=0.75, y=0.75}, collisionbox = {0}, physical = false, - textures = {"xdecor_book_open.png"} + textures = {"xdecor_book_open.png"}, + on_activate = function(self) + local pos = self.object:getpos() + local pos_under = {x=pos.x, y=pos.y-1, z=pos.z} + + if minetest.get_node(pos_under).name ~= "xdecor:enchantment_table" then + self.object:remove() + end + end }) local function cap(S) return S:gsub("^%l", string.upper) end diff --git a/itemframe.lua b/itemframe.lua index f17f1b9..1cbbf24 100644 --- a/itemframe.lua +++ b/itemframe.lua @@ -125,6 +125,11 @@ minetest.register_entity("xdecor:f_item", { physical = false, textures = {"air"}, on_activate = function(self, staticdata) + local pos = self.object:getpos() + if minetest.get_node(pos).name ~= "xdecor:itemframe" then + self.object:remove() + end + if tmp.nodename and tmp.texture then self.nodename = tmp.nodename tmp.nodename = nil