Paper/nms-patches/IChunkLoader.patch

54 lines
2.3 KiB
Diff
Raw Normal View History

2019-04-23 04:00:00 +02:00
--- a/net/minecraft/server/IChunkLoader.java
+++ b/net/minecraft/server/IChunkLoader.java
2020-06-25 02:00:00 +02:00
@@ -18,10 +18,49 @@
this.a = new IOWorker(file, flag, "chunk");
2019-04-23 04:00:00 +02:00
}
2020-06-25 02:00:00 +02:00
- public NBTTagCompound getChunkData(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound) {
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
+ private boolean check(ChunkProviderServer cps, int x, int z) throws IOException {
+ ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z);
+ if (cps != null) {
+ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread");
+ if (cps.isLoaded(x, z)) {
+ return true;
+ }
+ }
+
2019-12-10 23:00:00 +01:00
+ NBTTagCompound nbt = read(pos);
+ if (nbt != null) {
+ NBTTagCompound level = nbt.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated")) {
+ return true;
+ }
2019-04-23 04:00:00 +02:00
+
2019-12-10 23:00:00 +01:00
+ ChunkStatus status = ChunkStatus.a(level.getString("Status"));
+ if (status != null && status.b(ChunkStatus.FEATURES)) {
+ return true;
2019-04-23 04:00:00 +02:00
+ }
+ }
+
+ return false;
+ }
+
2020-06-25 09:58:10 +02:00
+ public NBTTagCompound getChunkData(ResourceKey<DimensionManager> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
int i = a(nbttagcompound);
boolean flag = true;
+ // CraftBukkit start
+ if (i < 1466) {
+ NBTTagCompound level = nbttagcompound.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) {
+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkProvider();
+ if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) {
+ level.setBoolean("LightPopulated", true);
+ }
+ }
+ }
+ // CraftBukkit end
+
if (i < 1493) {
nbttagcompound = GameProfileSerializer.a(this.b, DataFixTypes.CHUNK, nbttagcompound, i, 1493);
if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {