Fix issues converting certain chunks

This commit is contained in:
md_5 2018-07-19 14:19:12 +10:00
parent 80fefcf5ef
commit 6c944b2163

View File

@ -9,8 +9,37 @@
public ChunkRegionLoader(File file, DataFixer datafixer) {
this.c = file;
@@ -50,12 +50,13 @@
@@ -48,15 +48,54 @@
return nbttagcompound != null ? nbttagcompound : this.b(generatoraccess, i, j);
}
+ // CraftBukkit start
+ private boolean check(ChunkProviderServer cps, int x, int z) throws IOException {
+ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread");
+
+ if (cps.isLoaded(x, z)) {
+ return true;
+ }
+
+ if (RegionFileCache.chunkExists(this.c, x, z)) {
+ NBTTagCompound nbt = RegionFileCache.d(this.c, x, z);
+ if (nbt != null) {
+ NBTTagCompound level = nbt.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated")) {
+ return true;
+ }
+
+ ChunkStatus status = ChunkStatus.a(level.getString("Status"));
+ if (status != null && status.a(ChunkStatus.DECORATED)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ // CraftBukkit end
+
@Nullable
private NBTTagCompound b(GeneratorAccess generatoraccess, int i, int j) throws IOException {
- DataInputStream datainputstream = RegionFileCache.d(this.c, i, j);
@ -24,9 +53,21 @@
- NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(datainputstream);
+ // CraftBukkit end
int k = nbttagcompound.hasKeyOfType("DataVersion", 99) ? nbttagcompound.getInt("DataVersion") : -1;
+ // CraftBukkit start
+ if (k < 1466) {
+ NBTTagCompound level = nbttagcompound.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) {
+ ChunkProviderServer cps = ((WorldServer) generatoraccess).getChunkProviderServer();
+ if (check(cps, i - 1, j) && check(cps, i - 1, j - 1) && check(cps, i, j - 1)) {
+ level.setBoolean("LightPopulated", true);
+ }
+ }
+ }
+ // CraftBukkit end
if (k < 1493) {
@@ -78,13 +79,29 @@
nbttagcompound = GameProfileSerializer.a(this.d, DataFixTypes.CHUNK, nbttagcompound, k, 1493);
@@ -78,13 +117,29 @@
}
}
@ -56,7 +97,7 @@
Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound);
if (chunk != null) {
@@ -93,6 +110,9 @@
@@ -93,6 +148,9 @@
}
return chunk;
@ -66,7 +107,7 @@
}
}
@@ -121,7 +141,7 @@
@@ -121,7 +179,7 @@
}
@Nullable
@ -75,7 +116,7 @@
if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
@@ -140,10 +160,28 @@
@@ -140,10 +198,28 @@
ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ));
nbttagcompound1.setInt("xPos", i);
nbttagcompound1.setInt("zPos", j);
@ -105,7 +146,7 @@
}
}
} else {
@@ -158,7 +196,7 @@
@@ -158,7 +234,7 @@
ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) {
@ -114,7 +155,7 @@
} else {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
@@ -204,19 +242,30 @@
@@ -204,19 +280,30 @@
}
public synchronized boolean a() {
@ -149,7 +190,7 @@
if (nbttagcompound != null) {
try {
@@ -228,7 +277,7 @@
@@ -228,7 +315,7 @@
flag = true;
} finally {
@ -158,7 +199,7 @@
}
return flag;
@@ -248,10 +297,14 @@
@@ -248,10 +335,14 @@
}
private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
@ -174,7 +215,7 @@
if (this.e != null) {
this.e.a(chunkcoordintpair.a());
}
@@ -264,15 +317,16 @@
@@ -264,15 +355,16 @@
public void c() {
try {
@ -194,7 +235,7 @@
}
}
@@ -301,7 +355,7 @@
@@ -301,7 +393,7 @@
if (abiomebase != null) {
for (int k = 0; k < abiomebase.length; ++k) {
@ -203,7 +244,7 @@
}
}
@@ -383,7 +437,7 @@
@@ -383,7 +475,7 @@
int[] aint = new int[abiomebase.length];
for (int i = 0; i < abiomebase.length; ++i) {
@ -212,7 +253,7 @@
}
nbttagcompound.setIntArray("Biomes", aint);
@@ -485,7 +539,7 @@
@@ -485,7 +577,7 @@
}
ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a;
@ -221,7 +262,7 @@
return block.getBlockData().isAir();
};
RegistryBlocks registryblocks = Block.REGISTRY;
@@ -497,7 +551,7 @@
@@ -497,7 +589,7 @@
Block.REGISTRY.getClass();
ProtoChunkTickList protochunkticklist = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j));
@ -230,7 +271,7 @@
return fluidtype == FluidTypes.a;
};
registryblocks = FluidType.c;
@@ -505,7 +559,7 @@
@@ -505,7 +597,7 @@
function = registryblocks::b;
registryblocks1 = FluidType.c;
FluidType.c.getClass();
@ -239,7 +280,7 @@
long i1 = nbttagcompound.getLong("InhabitedTime");
Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
@@ -852,17 +906,29 @@
@@ -852,17 +944,29 @@
}
@Nullable
@ -271,7 +312,7 @@
});
}
@@ -876,8 +942,14 @@
@@ -876,8 +980,14 @@
}
}