From 095a6e4d0bda574d828a7398d9f7e99bceea1726 Mon Sep 17 00:00:00 2001 From: Sotr Date: Mon, 11 Jun 2018 22:35:54 +0800 Subject: [PATCH] Fixes light calc --- .../server/mixin/lighting/MixinChunk.java | 22 ++++++------------- .../mixin/lighting/MixinWorldServer.java | 4 ++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/sources/src/main/java/io/akarin/server/mixin/lighting/MixinChunk.java b/sources/src/main/java/io/akarin/server/mixin/lighting/MixinChunk.java index 2a6b9f43c..59c848863 100644 --- a/sources/src/main/java/io/akarin/server/mixin/lighting/MixinChunk.java +++ b/sources/src/main/java/io/akarin/server/mixin/lighting/MixinChunk.java @@ -124,18 +124,14 @@ public abstract class MixinChunk implements IMixinChunk { private void onTickHead(boolean skipRecheckGaps, CallbackInfo ci) { final List neighbors = this.getSurroundingChunks(); if (this.isGapLightingUpdated && this.world.worldProvider.m() && !skipRecheckGaps && !neighbors.isEmpty()) { // PAIL: isGapLightingUpdated - hasSkyLight - this.lightExecutorService.execute(() -> { - this.recheckGapsAsync(neighbors); - }); + this.recheckGapsAsync(neighbors); this.isGapLightingUpdated = false; } this.ticked = true; if (!this.isLightPopulated && this.isTerrainPopulated && !neighbors.isEmpty()) { - this.lightExecutorService.execute(() -> { - this.checkLightAsync(neighbors); - }); + this.checkLightAsync(neighbors); // set to true to avoid requeuing the same task when not finished this.isLightPopulated = true; } @@ -203,7 +199,7 @@ public abstract class MixinChunk implements IMixinChunk { } } - this.isGapLightingUpdated = false; // TODO + // this.isGapLightingUpdated = false; } } @@ -232,7 +228,7 @@ public abstract class MixinChunk implements IMixinChunk { @Inject(method = "o()V", at = @At("HEAD"), cancellable = true) private void checkLightHead(CallbackInfo ci) { - if (this.world.getMinecraftServer().isStopped() || this.lightExecutorService.isShutdown()) { + if (this.world.getMinecraftServer().isStopped()) { return; } @@ -247,13 +243,11 @@ public abstract class MixinChunk implements IMixinChunk { if (Akari.isPrimaryThread()) { // Akarin try { - this.lightExecutorService.execute(() -> { - this.checkLightAsync(neighborChunks); - }); + this.checkLightAsync(neighborChunks); } catch (RejectedExecutionException ex) { // This could happen if ServerHangWatchdog kills the server // between the start of the method and the execute() call. - if (!this.world.getMinecraftServer().isStopped() && !this.lightExecutorService.isShutdown()) { + if (!this.world.getMinecraftServer().isStopped()) { throw ex; } } @@ -451,9 +445,7 @@ public abstract class MixinChunk implements IMixinChunk { @Inject(method = "c(III)V", at = @At("HEAD"), cancellable = true) private void onRelightBlock(int x, int y, int z, CallbackInfo ci) { - this.lightExecutorService.execute(() -> { - this.relightBlockAsync(x, y, z); - }); + this.relightBlockAsync(x, y, z); ci.cancel(); } diff --git a/sources/src/main/java/io/akarin/server/mixin/lighting/MixinWorldServer.java b/sources/src/main/java/io/akarin/server/mixin/lighting/MixinWorldServer.java index ecbca35cd..492297974 100644 --- a/sources/src/main/java/io/akarin/server/mixin/lighting/MixinWorldServer.java +++ b/sources/src/main/java/io/akarin/server/mixin/lighting/MixinWorldServer.java @@ -99,8 +99,8 @@ public abstract class MixinWorldServer extends MixinWorld implements IMixinWorld if (l2 > 0) { int j3 = MathHelper.a(i2 - i1); // TODO MathHelper - int k3 = Math.abs(j2 - j1); - int l3 = Math.abs(k2 - k1); + int k3 = MathHelper.a(j2 - j1); + int l3 = MathHelper.a(k2 - k1); if (j3 + k3 + l3 < 17) { PooledBlockPosition blockpos$pooledmutableblockpos = PooledBlockPosition.aquire();