From 135f0a3c10e71ca47e8027da133718a8b85f555e Mon Sep 17 00:00:00 2001 From: Zontreck Date: Sun, 18 Feb 2024 09:47:03 -0700 Subject: [PATCH] Reduce the potential impact of checking everything on ticks --- gradle.properties | 2 +- src/main/java/dev/zontreck/wmd/WatchMyDurability.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 600850c..1d6bd2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,7 +48,7 @@ mod_name=WatchMyDurability # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPLv3 # The mod version. See https://semver.org/ -mod_version=1201.2.021824.0932 +mod_version=1201.2.021824.0945 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/dev/zontreck/wmd/WatchMyDurability.java b/src/main/java/dev/zontreck/wmd/WatchMyDurability.java index 4c9a209..ebca486 100644 --- a/src/main/java/dev/zontreck/wmd/WatchMyDurability.java +++ b/src/main/java/dev/zontreck/wmd/WatchMyDurability.java @@ -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