craftbukkit/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch

112 lines
6.2 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- 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 {
2020-06-25 17:58:10 +10:00
private static final Logger LOGGER = LogManager.getLogger();
2021-06-11 15:00:00 +10:00
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;
2021-03-16 09:00:00 +11:00
@@ -49,12 +53,12 @@
2021-06-11 15:00:00 +10:00
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;
2020-06-25 17:58:10 +10:00
- 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
2021-06-11 15:00:00 +10:00
this.levels = immutableset;
this.eraseCache = flag;
this.dataFixer = datafixer;
2021-03-16 09:00:00 +11:00
@@ -82,12 +86,12 @@
2020-06-25 17:58:10 +10:00
private void i() {
2021-06-11 15:00:00 +10:00
this.totalChunks = 0;
2020-06-25 17:58:10 +10:00
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
+ Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
List list;
2021-06-11 15:00:00 +10:00
for (UnmodifiableIterator unmodifiableiterator = this.levels.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) {
2020-06-25 17:58:10 +10:00
- ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next();
+ ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit
list = this.b(resourcekey);
builder.put(resourcekey, list.listIterator());
2021-03-16 09:00:00 +11:00
@@ -97,18 +101,18 @@
2021-06-11 15:00:00 +10:00
this.finished = true;
2020-06-25 17:58:10 +10:00
} else {
2021-06-11 15:00:00 +10:00
float f = (float) this.totalChunks;
2020-06-25 17:58:10 +10:00
- 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
2021-06-11 15:00:00 +10:00
UnmodifiableIterator unmodifiableiterator1 = this.levels.iterator();
2020-06-25 17:58:10 +10:00
while (unmodifiableiterator1.hasNext()) {
- ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next();
2021-06-11 15:00:00 +10:00
- File file = this.levelStorage.a(resourcekey1);
2020-06-25 17:58:10 +10:00
+ ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit
2021-06-11 15:00:00 +10:00
+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
2020-06-25 17:58:10 +10:00
2021-06-11 15:00:00 +10:00
builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.dataFixer, true));
2020-06-25 17:58:10 +10:00
}
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
+ ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
long i = SystemUtils.getMonotonicMillis();
2021-06-11 15:00:00 +10:00
this.status = new ChatMessage("optimizeWorld.stage.upgrading");
2021-03-16 09:00:00 +11:00
@@ -120,7 +124,7 @@
2020-06-25 17:58:10 +10:00
float f2;
2021-06-11 15:00:00 +10:00
for (UnmodifiableIterator unmodifiableiterator2 = this.levels.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
2020-06-25 17:58:10 +10:00
- 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);
2021-03-16 09:00:00 +11:00
@@ -135,7 +139,7 @@
2019-04-23 12:00:00 +10:00
int j = IChunkLoader.a(nbttagcompound);
2020-06-25 10:00:00 +10:00
NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> {
2021-06-11 15:00:00 +10:00
return this.overworldDataStorage;
2019-04-23 12:00:00 +10:00
- }, nbttagcompound);
+ }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit
2019-12-11 09:00:00 +11:00
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level");
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound2.getInt("xPos"), nbttagcompound2.getInt("zPos"));
2019-04-23 12:00:00 +10:00
2021-03-16 09:00:00 +11:00
@@ -208,8 +212,8 @@
2020-06-25 17:58:10 +10:00
}
}
- private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) {
2021-06-11 15:00:00 +10:00
- File file = this.levelStorage.a(resourcekey);
2020-06-25 17:58:10 +10:00
+ private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
2021-06-11 15:00:00 +10:00
+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
2020-06-25 17:58:10 +10:00
File file1 = new File(file, "region");
File[] afile = file1.listFiles((file2, s) -> {
return s.endsWith(".mca");
2021-06-11 15:00:00 +10:00
@@ -269,7 +273,7 @@
}
public ImmutableSet<ResourceKey<World>> c() {
- return this.levels;
+ throw new AssertionError("Unsupported"); // CraftBukkit
}
public float a(ResourceKey<World> resourcekey) {