]> git.lizzy.rs Git - minetest.git/commitdiff
Fix item eat sound not played if last item (#9239)
authorWuzzy <wuzzy2@mail.ru>
Tue, 24 Dec 2019 18:12:46 +0000 (18:12 +0000)
committerrubenwardy <rw@rubenwardy.com>
Tue, 31 Dec 2019 21:31:53 +0000 (21:31 +0000)
builtin/game/item.lua

index 8041d557e4b7492b35b8c5da2b911afac02a6cf7..4054949f17e66710389233bb2077d72987ad353a 100644 (file)
@@ -460,10 +460,10 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
                        return result
                end
        end
+       local def = itemstack:get_definition()
        if itemstack:take_item() ~= nil then
                user:set_hp(user:get_hp() + hp_change)
 
-               local def = itemstack:get_definition()
                if def and def.sound and def.sound.eat then
                        minetest.sound_play(def.sound.eat, { pos = user:get_pos(), max_hear_distance = 16 })
                end