Fix lighting exception in pre 1.13.2 Spigot/Paper

This commit is contained in:
Mike Primm 2022-01-31 09:23:40 -06:00
parent 592ad5028e
commit 3c76c3f875
2 changed files with 10 additions and 10 deletions

View File

@ -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;
}

View File

@ -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) {