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

102 lines
6 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
2021-11-22 09:00:00 +11:00
@@ -38,6 +38,10 @@
2021-03-16 09:00:00 +11:00
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-11-22 09:00:00 +11:00
@@ -53,7 +57,7 @@
2021-06-11 15:00:00 +10:00
private volatile int totalChunks;
private volatile int converted;
private volatile int skipped;
2021-11-22 09:00:00 +11:00
- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy()));
+ private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit
2021-06-11 15:00:00 +10:00
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;
2021-11-22 09:00:00 +11:00
@@ -86,13 +90,13 @@
2020-06-25 17:58:10 +10:00
2021-11-22 09:00:00 +11:00
private void work() {
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();
2021-11-22 09:00:00 +11:00
- ImmutableSet<ResourceKey<World>> immutableset = this.worldGenSettings.levels();
2020-06-25 17:58:10 +10:00
+ Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
2021-11-22 09:00:00 +11:00
+ ImmutableSet<ResourceKey<DimensionManager>> immutableset = this.worldGenSettings.levels(); // CraftBukkit
2020-06-25 17:58:10 +10:00
List list;
2021-11-22 09:00:00 +11:00
for (UnmodifiableIterator unmodifiableiterator = immutableset.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
2021-11-22 09:00:00 +11:00
list = this.getAllChunkPos(resourcekey);
2020-06-25 17:58:10 +10:00
builder.put(resourcekey, list.listIterator());
2021-11-22 09:00:00 +11:00
@@ -102,18 +106,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-11-22 09:00:00 +11:00
UnmodifiableIterator unmodifiableiterator1 = immutableset.iterator();
2020-06-25 17:58:10 +10:00
while (unmodifiableiterator1.hasNext()) {
- ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next();
2021-11-22 09:00:00 +11:00
- Path path = this.levelStorage.getDimensionPath(resourcekey1);
2020-06-25 17:58:10 +10:00
+ ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit
2021-11-22 09:00:00 +11:00
+ Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
2020-06-25 17:58:10 +10:00
2021-11-22 09:00:00 +11:00
builder1.put(resourcekey1, new IChunkLoader(path.resolve("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
2021-11-22 09:00:00 +11:00
long i = SystemUtils.getMillis();
2020-06-25 17:58:10 +10:00
2021-06-11 15:00:00 +10:00
this.status = new ChatMessage("optimizeWorld.stage.upgrading");
2021-11-22 09:00:00 +11:00
@@ -125,7 +129,7 @@
2020-06-25 17:58:10 +10:00
float f2;
2021-11-22 09:00:00 +11:00
for (UnmodifiableIterator unmodifiableiterator2 = immutableset.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-11-22 09:00:00 +11:00
@@ -141,7 +145,7 @@
ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator();
NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> {
2021-06-11 15:00:00 +10:00
return this.overworldDataStorage;
2021-11-22 09:00:00 +11:00
- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer());
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
2019-04-23 12:00:00 +10:00
2021-11-22 09:00:00 +11:00
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
@@ -213,8 +217,8 @@
2020-06-25 17:58:10 +10:00
}
}
2021-11-22 09:00:00 +11:00
- private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<World> resourcekey) {
- File file = this.levelStorage.getDimensionPath(resourcekey).toFile();
+ private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
+ File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // 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-11-22 09:00:00 +11:00
@@ -274,7 +278,7 @@
2021-06-11 15:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
public ImmutableSet<ResourceKey<World>> levels() {
- return this.worldGenSettings.levels();
2021-06-11 15:00:00 +10:00
+ throw new AssertionError("Unsupported"); // CraftBukkit
}
2021-11-22 09:00:00 +11:00
public float dimensionProgress(ResourceKey<World> resourcekey) {