Skip to content

Commit

Permalink
Fix eat sound not playing if eating last of stack
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Dec 15, 2021
1 parent 3781754 commit 1c5ece8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin/game/item.lua
Expand Up @@ -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(),
Expand Down

0 comments on commit 1c5ece8

Please sign in to comment.