From 13b6ce170ce50fc9e0d95bc26f59a69b43d4819b Mon Sep 17 00:00:00 2001 From: Zontreck Date: Sun, 18 Feb 2024 09:33:06 -0700 Subject: [PATCH] Switch away from using DelayedExecutor --- gradle.properties | 4 ++-- .../java/dev/zontreck/wmd/WatchMyDurability.java | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index a85b60a..600850c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -libzontreck=1201.11.021624.1504 +libzontreck=1201.11.021824.0918 ## Environment 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.021624.1514 +mod_version=1201.2.021824.0932 # 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 1707751..4c9a209 100644 --- a/src/main/java/dev/zontreck/wmd/WatchMyDurability.java +++ b/src/main/java/dev/zontreck/wmd/WatchMyDurability.java @@ -17,6 +17,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.User; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; @@ -55,6 +56,7 @@ public class WatchMyDurability { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + DelayedExecutorService.setup(); // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); @@ -95,7 +97,6 @@ public class WatchMyDurability //LOGGER.info("HELLO FROM CLIENT SETUP"); //LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); WatchMyDurability.CurrentUser = Minecraft.getInstance().getUser(); - DelayedExecutorService.setup(); //time.schedule(new CheckInventory(), @@ -118,11 +119,14 @@ public class WatchMyDurability //LOGGER.info("PLAYER LOGGED IN"); LOGGER.info(": : : PLAYER LOGGED IN : : :"); WatchMyDurability.isInGame=true; - DelayedExecutorService.start(); + } - DelayedExecutorService.getInstance().scheduleRepeating(CheckInventory.getInstance(), WMDClientConfig.TimerVal.get()); - DelayedExecutorService.getInstance().scheduleRepeating(CheckHealth.getInstance(), WMDClientConfig.TimerVal.get()); - DelayedExecutorService.getInstance().scheduleRepeating(CheckHunger.getInstance(), WMDClientConfig.TimerVal.get()); + @SubscribeEvent + public static void onTick(TickEvent.ClientTickEvent ev) + { + CheckInventory.getInstance().run(); + CheckHealth.getInstance().run(); + CheckHunger.getInstance().run(); } @SubscribeEvent @@ -131,7 +135,6 @@ public class WatchMyDurability LOGGER.info(": : : PLAYER LOGGED OUT : : :"); WatchMyDurability.isInGame=false; WatchMyDurability.WMD_SERVER_AVAILABLE=false; - DelayedExecutorService.stop(); } @SubscribeEvent