From 4e2e3a02b431c1f79c0fb32c3b8ee6ae8f289878 Mon Sep 17 00:00:00 2001 From: gpcf Date: Sat, 5 Sep 2020 23:54:15 +0200 Subject: [PATCH] Fix maple drawers (#51) Prevent the visible entity from being deleted on the maple drawers. --- lua/helpers.lua | 1 + lua/visual.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/helpers.lua b/lua/helpers.lua index 61078bd..de039ce 100755 --- a/lua/helpers.lua +++ b/lua/helpers.lua @@ -100,6 +100,7 @@ function drawers.spawn_visuals(pos) local pos2 = vector.add(pos, vector.multiply(fdir, 0.45)) local obj = core.add_entity(pos2, "drawers:visual") + if not obj then return end if bdir.x < 0 then obj:set_yaw(0.5 * math.pi) end if bdir.z < 0 then obj:set_yaw(math.pi) end diff --git a/lua/visual.lua b/lua/visual.lua index 3510723..130c1fa 100755 --- a/lua/visual.lua +++ b/lua/visual.lua @@ -78,7 +78,7 @@ core.register_entity("drawers:visual", { end local node = minetest.get_node(self.object:get_pos()) - if not node.name:match("^drawers:") then + if core.get_item_group(node.name, "drawer") == 0 then self.object:remove() return end @@ -210,7 +210,8 @@ core.register_entity("drawers:visual", { on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir) local node = minetest.get_node(self.object:get_pos()) - if not node.name:match("^drawers:") then + + if core.get_item_group(node.name, "drawer") == 0 then self.object:remove() return end