This commit is contained in:
kay27 2021-02-09 23:34:04 +00:00
parent cf95239fe5
commit ba9ad48114

@ -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,19 +166,21 @@ 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
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,
})