--- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java @@ -38,6 +38,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.dimension.WorldDimension; +// CraftBukkit end + public class WorldUpgrader { private static final Logger LOGGER = LogManager.getLogger(); @@ -53,7 +57,7 @@ private volatile int totalChunks; private volatile int converted; private volatile int skipped; - private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); + private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // 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; @@ -86,13 +90,13 @@ private void work() { this.totalChunks = 0; - Builder, ListIterator> builder = ImmutableMap.builder(); - ImmutableSet> immutableset = this.worldGenSettings.levels(); + Builder, ListIterator> builder = ImmutableMap.builder(); // CraftBukkit + ImmutableSet> immutableset = ImmutableSet.of(levelStorage.dimensionType); // CraftBukkit List list; for (UnmodifiableIterator unmodifiableiterator = immutableset.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) { - ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); + ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit list = this.getAllChunkPos(resourcekey); builder.put(resourcekey, list.listIterator()); @@ -102,18 +106,18 @@ this.finished = true; } else { float f = (float) this.totalChunks; - ImmutableMap, ListIterator> immutablemap = builder.build(); - Builder, IChunkLoader> builder1 = ImmutableMap.builder(); + ImmutableMap, ListIterator> immutablemap = builder.build(); // CraftBukkit + Builder, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit UnmodifiableIterator unmodifiableiterator1 = immutableset.iterator(); while (unmodifiableiterator1.hasNext()) { - ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); - Path path = this.levelStorage.getDimensionPath(resourcekey1); + ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit + Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true)); } - ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); + ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit long i = SystemUtils.getMillis(); this.status = new ChatMessage("optimizeWorld.stage.upgrading"); @@ -125,7 +129,7 @@ float f2; for (UnmodifiableIterator unmodifiableiterator2 = immutableset.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { - ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); + ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit ListIterator listiterator = (ListIterator) immutablemap.get(resourcekey2); IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2); @@ -138,10 +142,10 @@ if (nbttagcompound != null) { int j = IChunkLoader.getVersion(nbttagcompound); - ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator(); + ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(resourcekey2)).generator(); // CraftBukkit NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> { return this.overworldDataStorage; - }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); + }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); if (!chunkcoordintpair1.equals(chunkcoordintpair)) { @@ -213,8 +217,8 @@ } } - private List getAllChunkPos(ResourceKey resourcekey) { - File file = this.levelStorage.getDimensionPath(resourcekey).toFile(); + private List getAllChunkPos(ResourceKey resourcekey) { // CraftBukkit + File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit File file1 = new File(file, "region"); File[] afile = file1.listFiles((file2, s) -> { return s.endsWith(".mca"); @@ -274,7 +278,7 @@ } public ImmutableSet> levels() { - return this.worldGenSettings.levels(); + throw new AssertionError("Unsupported"); // CraftBukkit } public float dimensionProgress(ResourceKey resourcekey) {