3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

Updated Upstream (CraftBukkit/Spigot)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
7033f180 Hoist out synchronisation from ChunkRegionLoader

Spigot Changes:
500ff5d4 Rebuild patches

Additional Paper changes:
Fixed Versioned World Folders to not synchronize on ChunkRegionLoader
Optimized Save Queue even more to use a Long2ObjectOpenHashmap for save map
Add World#getXIfLoaded to IWorldReader to expose it to more places
Dieser Commit ist enthalten in:
Aikar 2018-09-10 22:38:42 -04:00
Ursprung cf1fe85b04
Commit 2dd8623548
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE
11 geänderte Dateien mit 147 neuen und 105 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From ba0e316b276f0e35be5368b7e7f3bf0346916678 Mon Sep 17 00:00:00 2001
From c29cf352780a2e4924f2b9c11804efa58ac0c0e2 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2
@ -348,7 +348,7 @@ index e3d1761b49..fbebd4591c 100644
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 9e805c5d22..0034956af9 100644
index 3045d6d063..68212aa26e 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -90,7 +90,7 @@ public class ChunkProviderServer implements IChunkProvider {
@ -389,7 +389,7 @@ index 9e805c5d22..0034956af9 100644
this.chunkLoader.saveChunk(this.world, ichunkaccess, unloaded); // Spigot
} catch (IOException ioexception) {
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 664b167bb2..2e9bd0949a 100644
index df07b2b889..f969c036f3 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -1,5 +1,6 @@
@ -399,7 +399,7 @@ index 664b167bb2..2e9bd0949a 100644
import com.google.common.collect.Maps;
import com.mojang.datafixers.DataFixTypes;
import com.mojang.datafixers.DataFixer;
@@ -680,7 +681,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -678,7 +679,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
public void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
World world = chunk.getWorld();
@ -408,7 +408,7 @@ index 664b167bb2..2e9bd0949a 100644
for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
@@ -689,8 +690,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -687,8 +688,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
chunk.f(true);
}
@ -417,7 +417,7 @@ index 664b167bb2..2e9bd0949a 100644
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
for (int j = 0; j < nbttaglist1.size(); ++j) {
@@ -707,8 +706,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -705,8 +704,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
}
}
@ -426,7 +426,7 @@ index 664b167bb2..2e9bd0949a 100644
if (nbttagcompound.hasKeyOfType("TileTicks", 9) && world.J() instanceof TickListServer) {
((TickListServer) world.J()).a(nbttagcompound.getList("TileTicks", 10));
@@ -717,7 +714,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -715,7 +712,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
if (nbttagcompound.hasKeyOfType("LiquidTicks", 9) && world.I() instanceof TickListServer) {
((TickListServer) world.I()).a(nbttagcompound.getList("LiquidTicks", 10));
}

Datei anzeigen

@ -1,4 +1,4 @@
From c7b9d824fc6f8304e7d1e82fccaf1b0fc2a0233d Mon Sep 17 00:00:00 2001
From 1f1de0e88a43b88331553bbd92b9dfedb6991c5a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 4 Mar 2016 18:18:37 -0600
Subject: [PATCH] Chunk save queue improvements
@ -40,8 +40,20 @@ index 0d68ffd75a..fd00c320ce 100644
+ if (enableFileIOThreadSleep) Bukkit.getLogger().info("Enabled sleeping between chunk saves, beware of memory issues");
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
index d9608121b6..d7a6700936 100644
--- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
+++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
@@ -19,6 +19,7 @@ public class ChunkCoordIntPair {
this.z = (int)(i >> 32);
}
+ public long asLong() { return a(); } // Paper
public long a() {
return a(this.x, this.z);
}
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 2e9bd0949a..1dbcedbf94 100644
index f969c036f3..e831ea1429 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -22,6 +22,7 @@ import java.util.function.Consumer;
@ -52,7 +64,7 @@ index 2e9bd0949a..1dbcedbf94 100644
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// Spigot start
@@ -31,6 +32,26 @@ import org.spigotmc.SupplierUtils;
@@ -31,8 +32,28 @@ import org.spigotmc.SupplierUtils;
public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@ -77,36 +89,43 @@ index 2e9bd0949a..1dbcedbf94 100644
+ // Paper end
+
private static final Logger a = LogManager.getLogger();
private final Map<ChunkCoordIntPair, Supplier<NBTTagCompound>> b = java.util.Collections.synchronizedMap(Maps.newHashMap()); // CraftBukkit // Spigot
- private final Map<ChunkCoordIntPair, Supplier<NBTTagCompound>> b = Maps.newHashMap();
+ private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<Supplier<NBTTagCompound>> saveMap = it.unimi.dsi.fastutil.longs.Long2ObjectMaps.synchronize(new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>()); // Paper
private final File c;
@@ -305,8 +326,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
private final DataFixer d;
private PersistentStructureLegacy e;
@@ -78,7 +99,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@Nullable
private NBTTagCompound a(DimensionManager dimensionmanager, @Nullable PersistentCollection persistentcollection, int i, int j, @Nullable GeneratorAccess generatoraccess) throws IOException {
- NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.b.get(new ChunkCoordIntPair(i, j))); // Spigot
+ NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.saveMap.get(ChunkCoordIntPair.asLong(i, j))); // Spigot // Paper
if (nbttagcompound != null) {
return nbttagcompound;
@@ -306,7 +327,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
};
}
-
- this.a(chunkcoordintpair, SupplierUtils.createUnivaluedSupplier(completion, unloaded && this.b.size() < SAVE_QUEUE_TARGET_SIZE));
+ this.a(chunkcoordintpair, SupplierUtils.createUnivaluedSupplier(completion, unloaded)); // Paper - Remove save queue target size
+ // Paper end
// Spigot end
} catch (Exception exception) {
ChunkRegionLoader.a.error("Failed to save chunk", exception);
@@ -315,7 +336,10 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -315,7 +336,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier<NBTTagCompound> nbttagcompound) { // Spigot
- this.b.put(chunkcoordintpair, nbttagcompound);
+ synchronized (this.b) { // Paper - synchronize while modifying the map
+ this.saveMap.put(chunkcoordintpair.asLong(), nbttagcompound); // Paper
+ queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
+ this.b.put(chunkcoordintpair, nbttagcompound);
+ }
FileIOThread.a().a(this);
}
@@ -325,20 +349,24 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -325,19 +347,24 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
private boolean processSaveQueueEntry(boolean logCompletion) {
- synchronized (this.b) { // CraftBukkit
- Iterator iterator = this.b.entrySet().iterator();
- if (!iterator.hasNext()) {
+ // Paper start - Chunk queue improvements
@ -135,30 +154,22 @@ index 2e9bd0949a..1dbcedbf94 100644
if (nbttagcompound == null) {
return true;
@@ -347,6 +375,14 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -346,6 +373,15 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
// CraftBukkit start
RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z, SupplierUtils.getIfExists(nbttagcompound)); // Spigot
+ // Paper start remove from map only if this was the latest version of the chunk
+ synchronized (this.b) {
+ synchronized (this.saveMap) {
+ long k = chunkcoordintpair.asLong();
+ // This will not equal if a newer version is still pending - wait until newest is saved to remove
+ if (this.b.get(chunkcoordintpair) == chunk.compoundSupplier) {
+ this.b.remove(chunkcoordintpair);
+ if (this.saveMap.get(k) == chunk.compoundSupplier) {
+ this.saveMap.remove(k);
+ }
+ }
+ // Paper end
/*
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
dataoutputstream.close();
@@ -362,7 +398,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
return true;
}
}
- } // CraftBukkit
+ // } // CraftBukkit // Paper
}
private ChunkStatus.Type a(@Nullable NBTTagCompound nbttagcompound) {
diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java
index a3aba244af..97917551a4 100644
--- a/src/main/java/net/minecraft/server/FileIOThread.java

Datei anzeigen

@ -1,4 +1,4 @@
From 7199d360b2976d395fa21c26781e12591a4e5b61 Mon Sep 17 00:00:00 2001
From da7880ca6732b6f859467ba9a7097ae3562c8b34 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 18 Mar 2016 20:16:03 -0400
Subject: [PATCH] Add World Util Methods
@ -6,7 +6,7 @@ Subject: [PATCH] Add World Util Methods
Methods that can be used for other patches to help improve logic.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 68f845986..dcd122d8b 100644
index 68f8459861..dcd122d8b5 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -639,6 +639,7 @@ public class Chunk implements IChunkAccess {
@ -17,8 +17,44 @@ index 68f845986..dcd122d8b 100644
public int a(BlockPosition blockposition, int i) {
return this.a(blockposition, i, this.world.o().g());
}
diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java
index ac85986a1a..06c5a54254 100644
--- a/src/main/java/net/minecraft/server/IWorldReader.java
+++ b/src/main/java/net/minecraft/server/IWorldReader.java
@@ -35,6 +35,22 @@ public interface IWorldReader extends IBlockAccess {
}
int getLightLevel(BlockPosition var1, int var2);
+ // Paper start
+ default @Nullable
+ IBlockData getTypeIfLoaded(BlockPosition var1) {
+ return isLoaded(var1) ? getType(var1) : null;
+ }
+
+ default @Nullable
+ Block getBlockIfLoaded(BlockPosition var1) {
+ return isLoaded(var1) ? getType(var1).getBlock() : null;
+ }
+
+ default @Nullable
+ Material getMaterialIfLoaded(BlockPosition var1) {
+ return isLoaded(var1) ? getType(var1).getMaterial() : null;
+ }
+ // Paper end
boolean isChunkLoaded(int var1, int var2, boolean var3);
@@ -100,7 +116,7 @@ public interface IWorldReader extends IBlockAccess {
WorldBorder worldborder = this.getWorldBorder();
boolean flag1 = worldborder.b() < (double)i && (double)j < worldborder.d() && worldborder.c() < (double)i1 && (double)j1 < worldborder.e();
VoxelShapeBitSet voxelshapebitset = new VoxelShapeBitSet(j - i, l - k, j1 - i1);
- Predicate predicate = (voxelshape3) -> {
+ Predicate<VoxelShape> predicate = (voxelshape3) -> { // Paper - decompile fix
return !voxelshape3.b() && VoxelShapes.c(voxelshape, voxelshape3, OperatorBoolean.AND);
};
Stream stream = StreamSupport.stream(BlockPosition.MutableBlockPosition.b(i, k, i1, j - 1, l - 1, j1 - 1).spliterator(), false).map((blockposition$mutableblockposition) -> {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 561bcd07b..94872593b 100644
index 561bcd07b3..94872593b1 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -84,7 +84,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc

Datei anzeigen

@ -1,4 +1,4 @@
From e732d1184f1686864d9d9bd11bb409fa18c64709 Mon Sep 17 00:00:00 2001
From 886011f86b3e4c7e60676ac8d08977677187cafe Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 27 Aug 2015 01:15:02 -0400
Subject: [PATCH] Optimize Chunk Access
@ -44,7 +44,7 @@ index fbebd4591c..b941676829 100644
public Chunk a(Object object) {
return this.a(((Long) object).longValue());
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 6b041f06e4..1a1daf36b7 100644
index d73034f329..b1e6901090 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -78,15 +78,16 @@ public class ChunkProviderServer implements IChunkProvider {
@ -76,15 +76,15 @@ index 6b041f06e4..1a1daf36b7 100644
}
this.asyncTaskHandler.postToMainThread(chunk::addEntities);
@@ -342,7 +343,7 @@ public class ChunkProviderServer implements IChunkProvider {
@@ -343,7 +344,7 @@ public class ChunkProviderServer implements IChunkProvider {
this.saveChunk(chunk, true); // Spigot
}
this.chunks.remove(chunk.chunkKey);
- this.lastChunk = null;
+ // this.lastChunk = null; // Paper
}
return true;
}
// CraftBukkit end
--
2.18.0

Datei anzeigen

@ -1,4 +1,4 @@
From 9f6e2aa26857b197da5b8790ace6a8ffbe49c21e Mon Sep 17 00:00:00 2001
From 29fec89fc0e4511fd774cba43f5314a66a2f419e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 21 Jun 2016 22:54:34 -0400
Subject: [PATCH] Fix Double World Add issues
@ -8,10 +8,10 @@ Vanilla will double add Spider Jockeys to the world, so ignore already added.
Also add debug if something else tries to, and abort before world gets bad state
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 1dbcedbf94..8e14f8c56c 100644
index e831ea1429..d40d9d1173 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -1050,7 +1050,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -1048,7 +1048,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
public static void a(Entity entity, GeneratorAccess generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {

Datei anzeigen

@ -1,4 +1,4 @@
From 2d9b0defd0f78c56f370a94e16e02ea6b6ee6bdc Mon Sep 17 00:00:00 2001
From 71c127a8ceda8537198adecb9db62402cb66b25d Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 4 Nov 2016 02:12:10 -0400
Subject: [PATCH] Chunk Save Stats Debug Option
@ -8,7 +8,7 @@ Adds a command line flag to enable stats on how chunk saves are processing.
Stats on current queue, how many was processed and how many were queued.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 87744dcbfc..355186c111 100644
index 8acbd7bbff..edb4f2bb65 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -30,6 +30,11 @@ public class ChunkProviderServer implements IChunkProvider {
@ -54,7 +54,7 @@ index 87744dcbfc..355186c111 100644
return false;
}
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 2415404d69..f099b91f7a 100644
index fc8f7574cf..94ed728c0e 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -148,7 +148,13 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@ -72,15 +72,15 @@ index 2415404d69..f099b91f7a 100644
// CraftBukkit start - Add async variant, provide compatibility
@Nullable
@@ -338,6 +344,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -340,6 +346,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier<NBTTagCompound> nbttagcompound) { // Spigot
this.saveMap.put(chunkcoordintpair.asLong(), nbttagcompound); // Paper
queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
+ queuedSaves++; // Paper
FileIOThread.a().a(this);
}
protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier<NBTTagCompound> nbttagcompound) { // Spigot
+ queuedSaves++; // Paper
synchronized (this.b) { // Paper - synchronize while modifying the map
queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
this.b.put(chunkcoordintpair, nbttagcompound);
@@ -369,6 +376,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -367,6 +374,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
// Paper end
ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements
Supplier<NBTTagCompound> nbttagcompound = chunk.compoundSupplier; // Spigot // Paper

Datei anzeigen

@ -1,4 +1,4 @@
From 3a78019334a467c5c52b1fe79c8ba47a82b4293c Mon Sep 17 00:00:00 2001
From d1635cbba84d8963e9930db2a967df7e311c9be2 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 08:25:40 -0400
Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
@ -6,7 +6,7 @@ Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
Add -Ddebug.entities=true to your JVM flags to gain more information
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 58f7489ebd..d974cb5c61 100644
index 064bd4133a..7d8f723968 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -73,6 +73,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke

Datei anzeigen

@ -1,4 +1,4 @@
From c107796d25c4e33e47ab6c832793f350c9ebbad0 Mon Sep 17 00:00:00 2001
From 2ce2482dd23320d7c859438ade4fe2346ae1290c Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 26 Jul 2018 00:11:12 -0400
Subject: [PATCH] Prevent Saving Bad entities to chunks
@ -18,10 +18,10 @@ an invalid entity.
This should reduce log occurrences of dupe uuid messages.
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index ec94b9fe57..e6ede2cc25 100644
index 4f9be4b86d..f22532f071 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -561,11 +561,22 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -559,11 +559,22 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
Iterator iterator;
@ -44,7 +44,7 @@ index ec94b9fe57..e6ede2cc25 100644
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
if (entity.d(nbttagcompound1)) {
@@ -574,6 +585,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -572,6 +583,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
}
}

Datei anzeigen

@ -1,4 +1,4 @@
From 132c87e612eeb913dc0a57cde399bf0519c66a04 Mon Sep 17 00:00:00 2001
From bcd7f6ca976d597f8e3b96d581608a071ca24440 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 15:48:50 -0400
Subject: [PATCH] Provide option to use a versioned world folder for testing
@ -59,10 +59,10 @@ index bcdf4f91d8..c457d07110 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index e6ede2cc25..93bc613958 100644
index f22532f071..7db075b731 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -59,8 +59,52 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -59,8 +59,63 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
private PersistentStructureLegacy e;
// private boolean f; // CraftBukkit
private static final double SAVE_QUEUE_TARGET_SIZE = 625; // Spigot
@ -71,10 +71,11 @@ index e6ede2cc25..93bc613958 100644
+ private final File actualWorld;
+ private final boolean useAltWorld;
+
+ private synchronized void copyIfNeeded(int x, int z) {
+ private void copyIfNeeded(int x, int z) {
+ if (!useAltWorld) {
+ return;
+ }
+ synchronized (RegionFileCache.class) {
+ if (RegionFileCache.hasRegionFile(this.actualWorld, x, z)) {
+ return;
+ }
@ -90,10 +91,20 @@ index e6ede2cc25..93bc613958 100644
+ org.spigotmc.SneakyThrow.sneaky(e1);
+ }
+ }
+ }
+ }
+
+ public boolean chunkExists(int x, int z) {
+ if (this.saveMap.containsKey(ChunkCoordIntPair.asLong(x, z))) {
+ return true;
+ }
+ copyIfNeeded(x, z);
+ return RegionFileCache.chunkExists(this.actualWorld, x, z);
+ }
+ // Paper end
public ChunkRegionLoader(File file, DataFixer datafixer) {
+ // Paper
+ // Paper start
+ this.actualWorld = file;
+ if (com.destroystokyo.paper.PaperConfig.useVersionedWorld) {
+ this.useAltWorld = true;
@ -115,7 +126,7 @@ index e6ede2cc25..93bc613958 100644
this.c = file;
this.d = datafixer;
}
@@ -79,7 +123,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -79,7 +134,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
}
@ -124,30 +135,14 @@ index e6ede2cc25..93bc613958 100644
NBTTagCompound nbt = RegionFileCache.read(this.c, x, z);
if (nbt != null) {
NBTTagCompound level = nbt.getCompound("Level");
@@ -99,6 +143,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -99,6 +154,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@Nullable
private NBTTagCompound a(DimensionManager dimensionmanager, @Nullable PersistentCollection persistentcollection, int i, int j, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ copyIfNeeded(i, j); // Paper
NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.b.get(new ChunkCoordIntPair(i, j))); // Spigot
NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.saveMap.get(ChunkCoordIntPair.asLong(i, j))); // Spigot // Paper
if (nbttagcompound != null) {
@@ -222,6 +267,15 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
}
+ public boolean chunkExists(int x, int z) {
+ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
+ if (this.b.containsKey(chunkcoordintpair)) {
+ return true;
+ }
+ copyIfNeeded(x, z);
+ return RegionFileCache.chunkExists(this.actualWorld, x, z);
+ }
+
@Nullable
protected Object[] a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index 15666325ea..3501b87f75 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java

@ -1 +1 @@
Subproject commit 022b8c350a223f092e4fdbdce8ffb682f412fb29
Subproject commit 7033f180e0f1f300f6e85beda70cb396200a219a

@ -1 +1 @@
Subproject commit 145a37ae8c1032ac0dd0ea0a9f93c235ab2a6423
Subproject commit 500ff5d408d9ce45b6a0819777fc7ad4779f32e4