From 1c5ece8334d050379eb99fe2ead52f9f4db44249 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 15 Dec 2021 15:36:19 +0100 Subject: Fix eat sound not playing if eating last of stack --- builtin/game/item.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/game/item.lua b/builtin/game/item.lua index c9ccb8801..5a83eafd2 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -499,11 +499,12 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed return result end end + -- read definition before potentially emptying the stack + local def = itemstack:get_definition() if itemstack:take_item():is_empty() then return itemstack end - local def = itemstack:get_definition() if def and def.sound and def.sound.eat then core.sound_play(def.sound.eat, { pos = user:get_pos(), -- cgit v1.2.3