mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
enderdragon egg: check for protection on punch
This commit is contained in:
parent
231b658c3f
commit
8396dfe7e3
1 changed files with 11 additions and 9 deletions
|
@ -166,18 +166,20 @@ minetest.register_node("mcl_end:dragon_egg", {
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "regular",
|
type = "regular",
|
||||||
},
|
},
|
||||||
groups = {handy=1, falling_node = 1, deco_block = 1, not_in_creative_inventory = 1, dig_by_piston = 1 },
|
groups = {handy = 1, falling_node = 1, deco_block = 1, not_in_creative_inventory = 1, dig_by_piston = 1 },
|
||||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
sounds = mcl_sounds.node_sound_stone_defaults(),
|
||||||
_mcl_blast_resistance = 9,
|
_mcl_blast_resistance = 9,
|
||||||
_mcl_hardness = 3,
|
_mcl_hardness = 3,
|
||||||
on_punch = function(pos, node)
|
on_punch = function(pos, node, puncher)
|
||||||
local max_dist = vector.new(15, 7, 15)
|
if not minetest.is_protected(pos, puncher:get_player_name()) then
|
||||||
local positions = minetest.find_nodes_in_area(vector.subtract(pos, max_dist), vector.add(pos, max_dist), "air", false)
|
local max_dist = vector.new(15, 7, 15)
|
||||||
if #positions > 0 then
|
local positions = minetest.find_nodes_in_area(vector.subtract(pos, max_dist), vector.add(pos, max_dist), "air", false)
|
||||||
local tpos = positions[math.random(#positions)]
|
if #positions > 0 then
|
||||||
minetest.remove_node(pos)
|
local tpos = positions[math.random(#positions)]
|
||||||
minetest.set_node(tpos, node)
|
minetest.remove_node(pos)
|
||||||
minetest.check_for_falling(tpos)
|
minetest.set_node(tpos, node)
|
||||||
|
minetest.check_for_falling(tpos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue