From bc67d9638285a18ec27a7af2827ece6b31b47f86 Mon Sep 17 00:00:00 2001 From: Aria Date: Tue, 28 Feb 2023 00:04:42 -0700 Subject: [PATCH] Publish a fix to DelayedExecutor --- gradle.properties | 2 +- .../dev/zontreck/libzontreck/LibZontreck.java | 1 - .../util/DelayedExecutorService.java | 26 ++++++++++++++++--- src/main/resources/META-INF/mods.toml | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index fa730f1..8c8a24e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,5 +5,5 @@ org.gradle.daemon=false mc_version=1.18.2 forge_version=40.2.1 -myversion=1.0.5.0227232305 +myversion=1.0.5.0228230000 parchment_version=2022.11.06 \ No newline at end of file diff --git a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java index b5c85b3..f408fb5 100644 --- a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java +++ b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java @@ -68,7 +68,6 @@ public class LibZontreck { MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(DelayedExecutorService.getInstance()); MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers()); } diff --git a/src/main/java/dev/zontreck/libzontreck/util/DelayedExecutorService.java b/src/main/java/dev/zontreck/libzontreck/util/DelayedExecutorService.java index b56898f..c982741 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/DelayedExecutorService.java +++ b/src/main/java/dev/zontreck/libzontreck/util/DelayedExecutorService.java @@ -4,6 +4,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Timer; import dev.zontreck.libzontreck.LibZontreck; import net.minecraftforge.event.TickEvent.ServerTickEvent; @@ -12,12 +13,32 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -@EventBusSubscriber(modid=LibZontreck.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class DelayedExecutorService { private static int COUNT = 0; private static final DelayedExecutorService inst; + private static final Thread repeater; static{ inst=new DelayedExecutorService(); + + repeater = new Thread(new Runnable(){ + @Override + public void run() + { + long lastExec = Instant.now().getEpochSecond(); + lastExec++; + while(LibZontreck.ALIVE) + { + if(Instant.now().getEpochSecond()>lastExec) + { + lastExec = Instant.now().getEpochSecond()+2; + + getInstance().onTick(); + } + } + } + }); + repeater.setName("DelayedExecutorService"); + repeater.start(); } private DelayedExecutorService(){} @@ -44,8 +65,7 @@ public class DelayedExecutorService { EXECUTORS.add(exe); } - @SubscribeEvent - public void onTick(ServerTickEvent ev) + public void onTick() { if(!LibZontreck.ALIVE) { diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f1d83ea..7a5333e 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ modId="libzontreck" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # see the associated build.gradle script for how to populate this completely automatically during a build -version="1.0.5.0227232305" #mandatory +version="1.0.5.0228230000" #mandatory # A display name for the mod displayName="LibZontreck" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/