From b902738ed076cd3820b71267194efc8a6784c642 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 23 Aug 2017 04:53:36 +0200 Subject: [PATCH] Endermen: Check if block was actually placed --- mods/ENTITIES/mobs_mc/enderman.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index ac49df97f8..cae9ffd967 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -250,15 +250,17 @@ mobs:register_mob("mobs_mc:enderman", { 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 -- ... but only if there's a free space - minetest.place_node(place_pos, {name = self._taken_node}) - local def = minetest.registered_nodes[self._taken_node] - -- Update animation accordingly (removes visible block) - self.animation = select_enderman_animation("normal") - mobs:set_animation(self, self.animation.current) - if def.sounds and def.sounds.place then - minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}) + local success = minetest.place_node(place_pos, {name = self._taken_node}) + if success then + local def = minetest.registered_nodes[self._taken_node] + -- Update animation accordingly (removes visible block) + self.animation = select_enderman_animation("normal") + mobs:set_animation(self, self.animation.current) + if def.sounds and def.sounds.place then + minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}) + end + self._taken_node = "" end - self._taken_node = "" end end end,