Add compatibility for other forks which do not have mcl_hunger.is_eating API

This commit is contained in:
Eliy21 2024-01-28 14:54:41 +00:00 committed by ryvnf
parent 7c1c2c488f
commit cc07c3f7c8

View File

@ -299,7 +299,11 @@ local function handle_blocking(player)
if not_blocking then
minetest.after(0.25, function()
rmb = player:get_player_control().RMB
if (not_blocking or not shield_in_offhand) and shield_in_hand and rmb and not mcl_hunger.is_eating(player) and mcl_shields.players[player].cooldown == 0 then
local is_eating = false
if mcl_hunger.is_eating then
is_eating = mcl_hunger.is_eating(player)
end
if (not_blocking or not shield_in_offhand) and shield_in_hand and rmb and not is_eating and mcl_shields.players[player].cooldown == 0 then
player_shield.blocking = 2
set_shield(player, true, 2)
else
@ -331,7 +335,11 @@ local function handle_blocking(player)
if not_blocking then
minetest.after(0.25, function()
rmb = player:get_player_control().RMB
if (not_blocking or not shield_in_hand) and shield_in_offhand and rmb and offhand_can_block and not mcl_hunger.is_eating(player) and mcl_shields.players[player].cooldown == 0 then
local is_eating = false
if mcl_hunger.is_eating then
is_eating = mcl_hunger.is_eating(player)
end
if (not_blocking or not shield_in_hand) and shield_in_offhand and rmb and offhand_can_block and not is_eating and mcl_shields.players[player].cooldown == 0 then
player_shield.blocking = 1
set_shield(player, true, 1)
else