Reduce the potential impact of checking everything on ticks

This commit is contained in:
Zontreck 2024-02-18 09:47:03 -07:00
parent 13b6ce170c
commit 135f0a3c10
2 changed files with 9 additions and 4 deletions

View file

@ -112,6 +112,7 @@ public class WatchMyDurability
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public static class ClientEvents
{
static int TICKS=0;
@SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){
@ -124,9 +125,13 @@ public class WatchMyDurability
@SubscribeEvent
public static void onTick(TickEvent.ClientTickEvent ev)
{
CheckInventory.getInstance().run();
CheckHealth.getInstance().run();
CheckHunger.getInstance().run();
if(ev.phase == TickEvent.Phase.END && TICKS >= 40)
{
TICKS=0;
CheckInventory.getInstance().run();
CheckHealth.getInstance().run();
CheckHunger.getInstance().run();
}else TICKS++;
}
@SubscribeEvent