mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-08-19 21:44:12 +02:00
Endermen: Check if block was actually placed
This commit is contained in:
parent
e2b57327fe
commit
b902738ed0
@ -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))))
|
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
|
if minetest.get_node(place_pos).name == "air" then
|
||||||
-- ... but only if there's a free space
|
-- ... but only if there's a free space
|
||||||
minetest.place_node(place_pos, {name = self._taken_node})
|
local success = minetest.place_node(place_pos, {name = self._taken_node})
|
||||||
local def = minetest.registered_nodes[self._taken_node]
|
if success then
|
||||||
-- Update animation accordingly (removes visible block)
|
local def = minetest.registered_nodes[self._taken_node]
|
||||||
self.animation = select_enderman_animation("normal")
|
-- Update animation accordingly (removes visible block)
|
||||||
mobs:set_animation(self, self.animation.current)
|
self.animation = select_enderman_animation("normal")
|
||||||
if def.sounds and def.sounds.place then
|
mobs:set_animation(self, self.animation.current)
|
||||||
minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16})
|
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
|
end
|
||||||
self._taken_node = ""
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user