1
0
Fork 0

Merge pull request 'Fix globalstep in mcl_hunger taking a long time' (#2491) from fix-hunger-gs into master

Reviewed-on: MineClone2/MineClone2#2491
Reviewed-by: MysticTempest <mystictempest@noreply.git.minetest.land>
This commit is contained in:
cora 2022-07-25 22:33:27 +00:00
commit e6d1f603ff
1 changed files with 6 additions and 3 deletions

View File

@ -85,6 +85,9 @@ function mcl_hunger.update_saturation_hud(player, saturation, hunger)
end end
function mcl_hunger.update_exhaustion_hud(player, exhaustion) function mcl_hunger.update_exhaustion_hud(player, exhaustion)
if mcl_hunger.debug then if mcl_hunger.debug then
if not exhaustion then
exhaustion = mcl_hunger.get_exhaustion(player)
end
hb.change_hudbar(player, "exhaustion", exhaustion) hb.change_hudbar(player, "exhaustion", exhaustion)
end end
end end
@ -151,14 +154,14 @@ minetest.register_globalstep(function(dtime)
-- let hunger work always -- let hunger work always
if player_health > 0 and player_health <= 20 then if player_health > 0 and player_health <= 20 then
--mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_HUNGER) -- later for hunger status effect --mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_HUNGER) -- later for hunger status effect
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) mcl_hunger.update_exhaustion_hud(player)
end end
if food_level >= 18 then -- slow regeneration if food_level >= 18 then -- slow regeneration
if player_health > 0 and player_health < 20 then if player_health > 0 and player_health < 20 then
player:set_hp(player_health+1) player:set_hp(player_health+1)
mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN) mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN)
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) mcl_hunger.update_exhaustion_hud(player)
end end
elseif food_level == 0 then -- starvation elseif food_level == 0 then -- starvation
@ -176,7 +179,7 @@ minetest.register_globalstep(function(dtime)
food_tick_timer = 0 food_tick_timer = 0
player:set_hp(player_health+1) player:set_hp(player_health+1)
mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN) mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN)
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) mcl_hunger.update_exhaustion_hud(player)
end end
end end