use of io.xol.chunkstories.api.events.world.WorldTickEvent in project chunkstories by Hugobros3.
the class WorldLogicThread method run.
public void run() {
// TODO
// Installs a custom SecurityManager
logger.info("Security manager: " + System.getSecurityManager());
while (!die.get()) {
// Dirty performance metric :]
// perfMetric();
// nanoCheckStep(20, "Loop was more than 20ms");
// Timings
fps = 1f / ((System.nanoTime() - lastTimeNs) / 1000f / 1000f / 1000f);
lastTimeNs = System.nanoTime();
this.getPluginsManager().fireEvent(new WorldTickEvent(world));
try {
world.tick();
} catch (Exception e) {
world.logger().error("Exception occured while ticking the world : ", e);
}
// Every second, unloads unused stuff
if (world.getTicksElapsed() % 60 == 0) {
// System.gc();
// Compresses pending chunk summaries
Iterator<RegionImplementation> loadedChunksHolders = world.getRegionsHolder().getLoadedRegions();
while (loadedChunksHolders.hasNext()) {
RegionImplementation region = loadedChunksHolders.next();
region.compressChangedChunks();
}
// Delete unused world data
world.unloadUselessData();
}
// nanoCheckStep(1, "unload");
gameLogicScheduler.runScheduledTasks();
// nanoCheckStep(1, "schedule");
// Game logic is 60 ticks/s
sync(getTargetFps());
}
waitForLogicFinish.signal();
}
Aggregations