mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Protect paintings, fix https://git.minetest.land/MineClone2/MineClone2/issues/1080
This commit is contained in:
parent
cf95239fe5
commit
ba9ad48114
@ -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,18 +166,20 @@ 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
|
||||||
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
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user