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

106 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
2021-11-22 09:00:00 +11:00
@@ -38,6 +38,10 @@
2022-03-01 02:00:00 +11:00
import net.minecraft.world.level.storage.WorldPersistentData;
import org.slf4j.Logger;
2021-03-16 09:00:00 +11:00
+// CraftBukkit start
+import net.minecraft.world.level.dimension.WorldDimension;
2021-03-16 09:00:00 +11:00
+// CraftBukkit end
+
public class WorldUpgrader {
2020-06-25 17:58:10 +10:00
2022-03-01 02:00:00 +11:00
private static final Logger LOGGER = LogUtils.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<WorldDimension>> 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();
+ Builder<ResourceKey<WorldDimension>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
+ ImmutableSet<ResourceKey<WorldDimension>> immutableset = ImmutableSet.of(levelStorage.dimensionType); // 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<WorldDimension> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit
2020-06-25 17:58:10 +10:00
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<WorldDimension>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit
+ Builder<ResourceKey<WorldDimension>, 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);
+ ResourceKey<WorldDimension> 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<WorldDimension>, 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<WorldDimension> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit
2020-06-25 17:58:10 +10:00
ListIterator<ChunkCoordIntPair> 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
2021-11-22 09:00:00 +11:00
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<WorldDimension> resourcekey) { // CraftBukkit
2021-11-22 09:00:00 +11:00
+ 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) {