1
0
Fork 0
kay27 2021-02-09 23:34:04 +00:00
parent cf95239fe5
commit ba9ad48114
1 changed files with 11 additions and 8 deletions

View File

@ -143,6 +143,7 @@ minetest.register_entity("mcl_paintings:painting", {
_xsize = 1, _xsize = 1,
_ysize = 1, _ysize = 1,
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.object:set_armor_groups({immortal = 1})
if staticdata and staticdata ~= "" then if staticdata and staticdata ~= "" then
local data = minetest.deserialize(staticdata) local data = minetest.deserialize(staticdata)
if data then if data then
@ -165,19 +166,21 @@ minetest.register_entity("mcl_paintings:painting", {
} }
return minetest.serialize(data) return minetest.serialize(data)
end, end,
on_death = function(self, killer) on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
-- Drop as item on death -- Drop as item on punch
local kname = "" if puncher and puncher:is_player() then
if killer and killer:is_player() then kname = puncher:get_player_name()
kname = killer:get_player_name()
end
if not minetest.is_creative_enabled(kname) then
local pos = self._pos local pos = self._pos
if not pos then if not pos then
pos = self.object:get_pos() pos = self.object:get_pos()
end 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") minetest.add_item(pos, "mcl_paintings:painting")
end end
end
end
end, end,
}) })