mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
b3a8254758
By: md_5 <git@md-5.net>
111 lines
6.2 KiB
Diff
111 lines
6.2 KiB
Diff
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
|
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
|
@@ -34,11 +34,15 @@
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.world.level.dimension.DimensionManager;
|
|
+// CraftBukkit end
|
|
+
|
|
public class WorldUpgrader {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build();
|
|
- private final ImmutableSet<ResourceKey<World>> levels;
|
|
+ private final ImmutableSet<ResourceKey<DimensionManager>> levels; // CraftBukkit
|
|
private final boolean eraseCache;
|
|
private final Convertable.ConversionSession levelStorage;
|
|
private final Thread thread;
|
|
@@ -49,12 +53,12 @@
|
|
private volatile int totalChunks;
|
|
private volatile int converted;
|
|
private volatile int skipped;
|
|
- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k()));
|
|
+ private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit
|
|
private volatile IChatBaseComponent status = new ChatMessage("optimizeWorld.stage.counting");
|
|
private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
|
private final WorldPersistentData overworldDataStorage;
|
|
|
|
- public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<World>> immutableset, boolean flag) {
|
|
+ public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<DimensionManager>> immutableset, boolean flag) { // CraftBukkit
|
|
this.levels = immutableset;
|
|
this.eraseCache = flag;
|
|
this.dataFixer = datafixer;
|
|
@@ -82,12 +86,12 @@
|
|
|
|
private void i() {
|
|
this.totalChunks = 0;
|
|
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
|
|
+ Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
|
|
|
|
List list;
|
|
|
|
for (UnmodifiableIterator unmodifiableiterator = this.levels.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) {
|
|
- ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next();
|
|
+ ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit
|
|
|
|
list = this.b(resourcekey);
|
|
builder.put(resourcekey, list.listIterator());
|
|
@@ -97,18 +101,18 @@
|
|
this.finished = true;
|
|
} else {
|
|
float f = (float) this.totalChunks;
|
|
- ImmutableMap<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build();
|
|
- Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder();
|
|
+ ImmutableMap<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit
|
|
+ Builder<ResourceKey<DimensionManager>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit
|
|
UnmodifiableIterator unmodifiableiterator1 = this.levels.iterator();
|
|
|
|
while (unmodifiableiterator1.hasNext()) {
|
|
- ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next();
|
|
- File file = this.levelStorage.a(resourcekey1);
|
|
+ ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit
|
|
+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
|
|
|
|
builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.dataFixer, true));
|
|
}
|
|
|
|
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
|
|
+ ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
|
|
long i = SystemUtils.getMonotonicMillis();
|
|
|
|
this.status = new ChatMessage("optimizeWorld.stage.upgrading");
|
|
@@ -120,7 +124,7 @@
|
|
float f2;
|
|
|
|
for (UnmodifiableIterator unmodifiableiterator2 = this.levels.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
|
|
- ResourceKey<World> resourcekey2 = (ResourceKey) unmodifiableiterator2.next();
|
|
+ ResourceKey<DimensionManager> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit
|
|
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
|
|
IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2);
|
|
|
|
@@ -135,7 +139,7 @@
|
|
int j = IChunkLoader.a(nbttagcompound);
|
|
NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> {
|
|
return this.overworldDataStorage;
|
|
- }, nbttagcompound);
|
|
+ }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit
|
|
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level");
|
|
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound2.getInt("xPos"), nbttagcompound2.getInt("zPos"));
|
|
|
|
@@ -208,8 +212,8 @@
|
|
}
|
|
}
|
|
|
|
- private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) {
|
|
- File file = this.levelStorage.a(resourcekey);
|
|
+ private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
|
|
+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
|
|
File file1 = new File(file, "region");
|
|
File[] afile = file1.listFiles((file2, s) -> {
|
|
return s.endsWith(".mca");
|
|
@@ -269,7 +273,7 @@
|
|
}
|
|
|
|
public ImmutableSet<ResourceKey<World>> c() {
|
|
- return this.levels;
|
|
+ throw new AssertionError("Unsupported"); // CraftBukkit
|
|
}
|
|
|
|
public float a(ResourceKey<World> resourcekey) {
|