hunger.lua 734 B

123456789101112131415161718
  1. if physio_stress.attributes.saturation or physio_stress.attributes.thirst then
  2. -- only use new eating mechanism, if thirst or saturation is enabled
  3. -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
  4. local org_eat = core.do_item_eat
  5. core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
  6. local old_itemstack = itemstack
  7. itemstack = physio_stress.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
  8. for _, callback in pairs(core.registered_on_item_eats) do
  9. local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack)
  10. if result then
  11. return result
  12. end
  13. end
  14. return itemstack
  15. end
  16. end