From 3c76c3f875c234cca6ad567b3b2674ce43c97246 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 31 Jan 2022 09:23:40 -0600 Subject: [PATCH] Fix lighting exception in pre 1.13.2 Spigot/Paper --- .../dynmap/bukkit/helper/AbstractMapChunkCache.java | 12 ++++++------ .../dynmap/bukkit/helper/MapChunkCacheClassic.java | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/AbstractMapChunkCache.java b/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/AbstractMapChunkCache.java index 809063e1..78f3add7 100644 --- a/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/AbstractMapChunkCache.java +++ b/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/AbstractMapChunkCache.java @@ -164,16 +164,16 @@ public abstract class AbstractMapChunkCache extends MapChunkCache { int emit = 0, sky = 15; if (step.yoff != 0) { // Y coord - snap is valid already int ny = y + step.yoff; - emit = snap.getBlockEmittedLight(x, ny, z); - sky = snap.getBlockSkyLight(x, ny, z); + emit = snap.getBlockEmittedLight(bx, ny, bz); + sky = snap.getBlockSkyLight(bx, ny, bz); } else { int nx = x + step.xoff; int nz = z + step.zoff; int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim); if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) { - emit = snaparray[nchunkindex].getBlockEmittedLight(nx, y, nz); - sky = snaparray[nchunkindex].getBlockSkyLight(nx, y, nz); + emit = snaparray[nchunkindex].getBlockEmittedLight(nx & 0xF, y, nz & 0xF); + sky = snaparray[nchunkindex].getBlockSkyLight(nx & 0xF, y, nz & 0xF); } } return (emit << 8) + sky; @@ -190,8 +190,8 @@ public abstract class AbstractMapChunkCache extends MapChunkCache { int nz = z + zoff; int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim); if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) { - emit = snaparray[nchunkindex].getBlockEmittedLight(nx, ny, nz); - sky = snaparray[nchunkindex].getBlockSkyLight(nx, ny, nz); + emit = snaparray[nchunkindex].getBlockEmittedLight(nx & 0xF, ny, nz & 0xF); + sky = snaparray[nchunkindex].getBlockSkyLight(nx & 0xF, ny, nz & 0xF); } return (emit << 8) + sky; } diff --git a/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/MapChunkCacheClassic.java b/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/MapChunkCacheClassic.java index 3fb0e4fc..dfcdfc09 100644 --- a/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/MapChunkCacheClassic.java +++ b/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/MapChunkCacheClassic.java @@ -46,15 +46,15 @@ public class MapChunkCacheClassic extends AbstractMapChunkCache { public final DynmapBlockState getBlockType(int x, int y, int z) { if ((sectionmask & (1 << (y >> 4))) != 0) return DynmapBlockState.AIR; - return BukkitVersionHelper.stateByID[(ss.getBlockTypeId(x, y, z) << 4) | ss.getBlockData(x, y, z)]; + return BukkitVersionHelper.stateByID[(ss.getBlockTypeId(x & 0xF, y, z & 0xF) << 4) | ss.getBlockData(x & 0xF, y, z & 0xF)]; } @Override public final int getBlockSkyLight(int x, int y, int z) { - return ss.getBlockSkyLight(x, y, z); + return ss.getBlockSkyLight(x & 0xF, y, z & 0xF); } @Override public final int getBlockEmittedLight(int x, int y, int z) { - return ss.getBlockEmittedLight(x, y, z); + return ss.getBlockEmittedLight(x & 0xF, y, z & 0xF); } @Override public final int getHighestBlockYAt(int x, int z) { @@ -62,7 +62,7 @@ public class MapChunkCacheClassic extends AbstractMapChunkCache { } @Override public final Biome getBiome(int x, int z) { - return ss.getBiome(x, z); + return ss.getBiome(x & 0xF, z & 0xF); } @Override public final boolean isSectionEmpty(int sy) {