Publish a fix to DelayedExecutor

This commit is contained in:
Aria 2023-02-28 00:04:42 -07:00
parent a46ec5ec73
commit bc67d96382
4 changed files with 25 additions and 6 deletions

View file

@ -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)
{