From ba9ad4811442a5c85ddf1dedd5ef9aba0e9cad02 Mon Sep 17 00:00:00 2001 From: kay27 Date: Tue, 9 Feb 2021 23:34:04 +0000 Subject: [PATCH] Protect paintings, fix https://git.minetest.land/MineClone2/MineClone2/issues/1080 --- mods/ENTITIES/mcl_paintings/init.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index 25811d87d..6a3ccab4d 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -143,6 +143,7 @@ minetest.register_entity("mcl_paintings:painting", { _xsize = 1, _ysize = 1, on_activate = function(self, staticdata) + self.object:set_armor_groups({immortal = 1}) if staticdata and staticdata ~= "" then local data = minetest.deserialize(staticdata) if data then @@ -165,18 +166,20 @@ minetest.register_entity("mcl_paintings:painting", { } return minetest.serialize(data) end, - on_death = function(self, killer) - -- Drop as item on death - local kname = "" - if killer and killer:is_player() then - kname = killer:get_player_name() - end - if not minetest.is_creative_enabled(kname) then + on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) + -- Drop as item on punch + if puncher and puncher:is_player() then + kname = puncher:get_player_name() local pos = self._pos if not pos then pos = self.object:get_pos() end - minetest.add_item(pos, "mcl_paintings:painting") + if not minetest.is_protected(pos, kname) then + self.object:remove() + if not minetest.is_creative_enabled(kname) then + minetest.add_item(pos, "mcl_paintings:painting") + end + end end end, })