use of net.minecraft.network.play.server.SPacketTimeUpdate in project SpongeVanilla by SpongePowered.
the class MixinMinecraftServer method updateTimeLightAndEntities.
/**
* @author Zidane
* @reason Handles ticking the additional worlds loaded by Sponge.
*/
@Overwrite
public void updateTimeLightAndEntities() {
this.profiler.startSection("jobs");
synchronized (this.futureTaskQueue) {
while (!this.futureTaskQueue.isEmpty()) {
Util.runTask(this.futureTaskQueue.poll(), LOGGER);
}
}
this.profiler.endStartSection("levels");
// Sponge: Tick chunk loader
tickChunkLoader();
// Sponge start - Iterate over all our dimensions
for (final ObjectIterator<Int2ObjectMap.Entry<WorldServer>> it = WorldManager.worldsIterator(); it.hasNext(); ) {
Int2ObjectMap.Entry<WorldServer> entry = it.next();
final WorldServer worldServer = entry.getValue();
// Sponge end
long i = System.nanoTime();
if (entry.getIntKey() == 0 || this.getAllowNether()) {
// Sponge start - copy from SpongeCommon MixinMinecraftServer
IMixinWorldServer spongeWorld = (IMixinWorldServer) worldServer;
if (spongeWorld.getChunkGCTickInterval() > 0) {
spongeWorld.doChunkGC();
}
// Sponge end
this.profiler.startSection(worldServer.getWorldInfo().getWorldName());
if (this.tickCounter % 20 == 0) {
this.profiler.startSection("timeSync");
this.playerList.sendPacketToAllPlayersInDimension(new SPacketTimeUpdate(worldServer.getTotalWorldTime(), worldServer.getWorldTime(), worldServer.getGameRules().getBoolean("doDaylightCycle")), ((IMixinWorldServer) worldServer).getDimensionId());
this.profiler.endSection();
}
this.profiler.startSection("tick");
try {
worldServer.tick();
} catch (Throwable throwable1) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world");
worldServer.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
try {
worldServer.updateEntities();
} catch (Throwable throwable) {
CrashReport crashreport1 = CrashReport.makeCrashReport(throwable, "Exception ticking world entities");
worldServer.addWorldInfoToCrashReport(crashreport1);
throw new ReportedException(crashreport1);
}
this.profiler.endSection();
this.profiler.startSection("tracker");
// Sponge start - copy from SpongeCommon MixinMinecraftServer
if (spongeWorld.getChunkGCTickInterval() > 0) {
worldServer.getChunkProvider().tick();
}
// Sponge end
worldServer.getEntityTracker().tick();
this.profiler.endSection();
this.profiler.endSection();
}
// Sponge start - Write tick times to our custom map
this.worldTickTimes.get(entry.getIntKey())[this.tickCounter % 100] = System.nanoTime() - i;
// Sponge end
}
// Sponge start - Unload requested worlds
this.profiler.endStartSection("dim_unloading");
WorldManager.unloadQueuedWorlds();
// Sponge end
this.profiler.endStartSection("connection");
this.getNetworkSystem().networkTick();
this.profiler.endStartSection("players");
this.playerList.onTick();
this.profiler.endStartSection("tickables");
for (int k = 0; k < this.tickables.size(); ++k) {
this.tickables.get(k).update();
}
this.profiler.endSection();
}
Aggregations