1
0
Fork 0

Fix enderman griefing in protected areas.

This commit is contained in:
Booglejr 2020-06-12 01:22:01 -05:00
parent 046bca1080
commit a7b9107d31
No known key found for this signature in database
GPG Key ID: 9298653061C12F5B
1 changed files with 43 additions and 39 deletions

View File

@ -342,44 +342,47 @@ mobs:register_mob("mobs_mc:enderman", {
local r = pr:next(1, #takable_nodes) local r = pr:next(1, #takable_nodes)
local take_pos = takable_nodes[r] local take_pos = takable_nodes[r]
local node = minetest.get_node(take_pos) local node = minetest.get_node(take_pos)
local dug = minetest.dig_node(take_pos) -- Don't destroy protected stuff.
if dug then if not minetest.is_protected(take_pos, "") then
if mobs_mc.enderman_replace_on_take[node.name] then local dug = minetest.dig_node(take_pos)
self._taken_node = mobs_mc.enderman_replace_on_take[node.name] if dug then
else if mobs_mc.enderman_replace_on_take[node.name] then
self._taken_node = node.name self._taken_node = mobs_mc.enderman_replace_on_take[node.name]
end else
local def = minetest.registered_nodes[self._taken_node] self._taken_node = node.name
-- Update animation and texture accordingly (adds visibly carried block) end
local block_type local def = minetest.registered_nodes[self._taken_node]
-- Cube-shaped -- Update animation and texture accordingly (adds visibly carried block)
if def.drawtype == "normal" or local block_type
def.drawtype == "nodebox" or -- Cube-shaped
def.drawtype == "liquid" or if def.drawtype == "normal" or
def.drawtype == "flowingliquid" or def.drawtype == "nodebox" or
def.drawtype == "glasslike" or def.drawtype == "liquid" or
def.drawtype == "glasslike_framed" or def.drawtype == "flowingliquid" or
def.drawtype == "glasslike_framed_optional" or def.drawtype == "glasslike" or
def.drawtype == "allfaces" or def.drawtype == "glasslike_framed" or
def.drawtype == "allfaces_optional" or def.drawtype == "glasslike_framed_optional" or
def.drawtype == nil then def.drawtype == "allfaces" or
block_type = "cube" def.drawtype == "allfaces_optional" or
elseif def.drawtype == "plantlike" then def.drawtype == nil then
-- Flowers and stuff block_type = "cube"
block_type = "plantlike45" elseif def.drawtype == "plantlike" then
elseif def.drawtype == "airlike" then -- Flowers and stuff
-- Just air block_type = "plantlike45"
block_type = nil elseif def.drawtype == "airlike" then
else -- Just air
-- Fallback for complex drawtypes block_type = nil
block_type = "unknown" else
end -- Fallback for complex drawtypes
self.base_texture = create_enderman_textures(block_type, self._taken_node) block_type = "unknown"
self.object:set_properties({ textures = self.base_texture }) end
self.animation = select_enderman_animation("block") self.base_texture = create_enderman_textures(block_type, self._taken_node)
mobs:set_animation(self, self.animation.current) self.object:set_properties({ textures = self.base_texture })
if def.sounds and def.sounds.dug then self.animation = select_enderman_animation("block")
minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true) mobs:set_animation(self, self.animation.current)
if def.sounds and def.sounds.dug then
minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true)
end
end end
end end
end end
@ -391,7 +394,8 @@ mobs:register_mob("mobs_mc:enderman", {
local yaw = self.object:get_yaw() local yaw = self.object:get_yaw()
-- Place node at looking direction -- Place node at looking direction
local place_pos = vector.subtract(pos, minetest.facedir_to_dir(minetest.dir_to_facedir(minetest.yaw_to_dir(yaw)))) 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 -- ... but only if there's a free space
local success = minetest.place_node(place_pos, {name = self._taken_node}) local success = minetest.place_node(place_pos, {name = self._taken_node})
if success then if success then