Fix delayed executor service
This commit is contained in:
parent
bc67d96382
commit
d94bb8e775
3 changed files with 9 additions and 23 deletions
|
@ -5,5 +5,5 @@ org.gradle.daemon=false
|
||||||
|
|
||||||
mc_version=1.18.2
|
mc_version=1.18.2
|
||||||
forge_version=40.2.1
|
forge_version=40.2.1
|
||||||
myversion=1.0.5.0228230000
|
myversion=1.0.5.0228230758
|
||||||
parchment_version=2022.11.06
|
parchment_version=2022.11.06
|
|
@ -5,40 +5,26 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
||||||
|
|
||||||
|
|
||||||
public class DelayedExecutorService {
|
public class DelayedExecutorService {
|
||||||
private static int COUNT = 0;
|
private static int COUNT = 0;
|
||||||
private static final DelayedExecutorService inst;
|
private static final DelayedExecutorService inst;
|
||||||
private static final Thread repeater;
|
private static final Timer repeater;
|
||||||
static{
|
static{
|
||||||
inst=new DelayedExecutorService();
|
inst=new DelayedExecutorService();
|
||||||
|
repeater=new Timer();
|
||||||
repeater = new Thread(new Runnable(){
|
repeater.schedule(new TimerTask(){
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
long lastExec = Instant.now().getEpochSecond();
|
DelayedExecutorService.getInstance().onTick();
|
||||||
lastExec++;
|
|
||||||
while(LibZontreck.ALIVE)
|
|
||||||
{
|
|
||||||
if(Instant.now().getEpochSecond()>lastExec)
|
|
||||||
{
|
|
||||||
lastExec = Instant.now().getEpochSecond()+2;
|
|
||||||
|
|
||||||
getInstance().onTick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}, 1000L, 1000L);
|
||||||
repeater.setName("DelayedExecutorService");
|
|
||||||
repeater.start();
|
|
||||||
}
|
}
|
||||||
private DelayedExecutorService(){}
|
private DelayedExecutorService(){}
|
||||||
|
|
||||||
|
|
|
@ -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
|
# 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
|
# ${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
|
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||||
version="1.0.5.0228230000" #mandatory
|
version="1.0.5.0228230758" #mandatory
|
||||||
# A display name for the mod
|
# A display name for the mod
|
||||||
displayName="LibZontreck" #mandatory
|
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/
|
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||||
|
|
Reference in a new issue