Behavior tweaks when eating "empty" food (#46)

- Allow eating food which doesn't restore saturation when the player is full
- Don't apply poison effect when eating food that isn't actually poisonous
This commit is contained in:
fluxionary 2023-05-18 05:14:36 -07:00 committed by GitHub
parent b5df973174
commit 9f1acb4eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -480,8 +480,8 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p
end
local level = stamina.get_saturation(player) or 0
if level >= settings.visual_max then
-- don't eat if player is full
if level >= settings.visual_max and hp_change > 0 then
-- don't eat if player is full and item provides saturation
return itemstack
end
@ -498,8 +498,7 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p
if hp_change > 0 then
stamina.change_saturation(player, hp_change)
stamina.set_exhaustion(player, 0)
else
-- assume hp_change < 0.
elseif hp_change < 0 then
stamina.poison(player, -hp_change, settings.poison_tick)
end