Fix lighting handling while still working around PaperMC issue

This commit is contained in:
Mike Primm 2020-05-19 22:26:08 -05:00
parent 45ce494e41
commit 314bfced8c

View File

@ -60,6 +60,15 @@ public class MapChunkCache115 extends AbstractMapChunkCache {
Arrays.fill(fullData, (byte)0xFF); Arrays.fill(fullData, (byte)0xFF);
} }
private static byte[] dataCopy(byte[] v) {
if (Arrays.equals(v, emptyData))
return emptyData;
else if (Arrays.equals(v, fullData))
return fullData;
else
return v.clone();
}
private static class EmptySection implements Section { private static class EmptySection implements Section {
@Override @Override
public DynmapBlockState getBlockType(int x, int y, int z) { public DynmapBlockState getBlockType(int x, int y, int z) {
@ -89,7 +98,7 @@ public class MapChunkCache115 extends AbstractMapChunkCache {
public StdSection() { public StdSection() {
states = new DynmapBlockState[BLOCKS_PER_SECTION]; states = new DynmapBlockState[BLOCKS_PER_SECTION];
Arrays.fill(states, DynmapBlockState.AIR); Arrays.fill(states, DynmapBlockState.AIR);
skylight = fullData; skylight = emptyData;
emitlight = emptyData; emitlight = emptyData;
} }
@Override @Override
@ -213,10 +222,12 @@ public class MapChunkCache115 extends AbstractMapChunkCache {
} }
} }
} }
byte[] emitlight = sec.getByteArray("BlockLight"); if (sec.hasKey("BlockLight")) {
cursect.emitlight = (emitlight == null) ? emptyData : emitlight.clone(); cursect.emitlight = dataCopy(sec.getByteArray("BlockLight"));
byte[] skylight = sec.getByteArray("SkyLight"); }
cursect.skylight = (skylight == null) ? fullData : skylight.clone(); if (sec.hasKey("SkyLight")) {
cursect.skylight = dataCopy(sec.getByteArray("SkyLight"));
}
} }
/* Get biome data */ /* Get biome data */
this.biome = new int[COLUMNS_PER_CHUNK]; this.biome = new int[COLUMNS_PER_CHUNK];