forked from Mineclonia/Mineclonia
Fix enderman griefing in protected areas.
This commit is contained in:
parent
046bca1080
commit
a7b9107d31
|
@ -342,6 +342,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||
local r = pr:next(1, #takable_nodes)
|
||||
local take_pos = takable_nodes[r]
|
||||
local node = minetest.get_node(take_pos)
|
||||
-- Don't destroy protected stuff.
|
||||
if not minetest.is_protected(take_pos, "") then
|
||||
local dug = minetest.dig_node(take_pos)
|
||||
if dug then
|
||||
if mobs_mc.enderman_replace_on_take[node.name] then
|
||||
|
@ -383,6 +385,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif self._taken_node ~= nil and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then
|
||||
-- Place taken node
|
||||
self._take_place_timer = 0
|
||||
|
@ -391,7 +394,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||
local yaw = self.object:get_yaw()
|
||||
-- Place node at looking direction
|
||||
local place_pos = vector.subtract(pos, minetest.facedir_to_dir(minetest.dir_to_facedir(minetest.yaw_to_dir(yaw))))
|
||||
if minetest.get_node(place_pos).name == "air" then
|
||||
-- Also check to see if protected.
|
||||
if minetest.get_node(place_pos).name == "air" and not minetest.is_protected(place_pos, "") then
|
||||
-- ... but only if there's a free space
|
||||
local success = minetest.place_node(place_pos, {name = self._taken_node})
|
||||
if success then
|
||||
|
|
Loading…
Reference in New Issue