From f95838d6311eca0b675eb0140e5c8c4743b6b6dc Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 29 Nov 2020 02:50:17 -0400 Subject: [PATCH] optimizations --- ...ightStorage_scarpetChunkCreationMixin.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java index e3c5788c..cf4d0543 100644 --- a/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java @@ -88,19 +88,26 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto final int dx = Math.abs(dir.getOffsetZ()); final int dz = Math.abs(dir.getOffsetX()); + int emptyLightLevel = (neighborCeilingLightArray == null) + ? (this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15) + : 0; + int neighbourY = (neighborLightArray == null) + ? ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)) + : 0; + for (int t = 0; t < 16; ++t) for (int dy = 0; dy < 16; ++dy) { final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz); long src = BlockPos.offset(dst, dir); - // fixed due to https://bugs.mojang.com/browse/MC-196542 so keeping the direction - //if (neighborLightArray == null) - // src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src)); + long adj_src = (neighborLightArray != null) + ? src + : BlockPos.asLong(BlockPos.unpackLongX(src), neighbourY, BlockPos.unpackLongZ(src)); - final int srcLevel = neighborCeilingLightArray != null ? - ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src) - : this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15; + final int srcLevel = neighborCeilingLightArray != null + ? ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, adj_src) + : emptyLightLevel; levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true); }