2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
|
|
|
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -48,7 +48,7 @@
|
2022-02-28 16:00:00 +01:00
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
2022-12-07 17:00:00 +01:00
|
|
|
private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build();
|
|
|
|
private final IRegistry<WorldDimension> dimensions;
|
|
|
|
- private final Set<ResourceKey<World>> levels;
|
|
|
|
+ private final Set<ResourceKey<WorldDimension>> levels; // CraftBukkit
|
|
|
|
private final boolean eraseCache;
|
|
|
|
private final Convertable.ConversionSession levelStorage;
|
|
|
|
private final Thread thread;
|
|
|
|
@@ -59,14 +59,14 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
private volatile int totalChunks;
|
|
|
|
private volatile int converted;
|
|
|
|
private volatile int skipped;
|
2021-11-21 23:00:00 +01:00
|
|
|
- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy()));
|
2021-11-23 07:13:52 +01:00
|
|
|
+ private final Object2FloatMap<ResourceKey<WorldDimension>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit
|
2022-06-07 18:00:00 +02:00
|
|
|
private volatile IChatBaseComponent status = IChatBaseComponent.translatable("optimizeWorld.stage.counting");
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
|
|
|
private final WorldPersistentData overworldDataStorage;
|
2022-12-07 17:00:00 +01:00
|
|
|
|
|
|
|
public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistry<WorldDimension> iregistry, boolean flag) {
|
|
|
|
this.dimensions = iregistry;
|
|
|
|
- this.levels = (Set) iregistry.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet());
|
|
|
|
+ this.levels = (Set) iregistry.registryKeySet().stream().collect(Collectors.toUnmodifiableSet()); // CraftBukkit
|
|
|
|
this.eraseCache = flag;
|
|
|
|
this.dataFixer = datafixer;
|
|
|
|
this.levelStorage = convertable_conversionsession;
|
|
|
|
@@ -93,12 +93,12 @@
|
2020-06-25 09:58:10 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
private void work() {
|
2021-06-11 07:00:00 +02:00
|
|
|
this.totalChunks = 0;
|
2020-06-25 09:58:10 +02:00
|
|
|
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
|
2021-11-23 07:13:52 +01:00
|
|
|
+ Builder<ResourceKey<WorldDimension>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
|
2020-06-25 09:58:10 +02:00
|
|
|
|
|
|
|
List list;
|
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
for (Iterator iterator = this.levels.iterator(); iterator.hasNext(); this.totalChunks += list.size()) {
|
|
|
|
- ResourceKey<World> resourcekey = (ResourceKey) iterator.next();
|
|
|
|
+ ResourceKey<WorldDimension> resourcekey = (ResourceKey) iterator.next(); // CraftBukkit
|
2020-06-25 09:58:10 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
list = this.getAllChunkPos(resourcekey);
|
2020-06-25 09:58:10 +02:00
|
|
|
builder.put(resourcekey, list.listIterator());
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -108,18 +108,18 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
this.finished = true;
|
2020-06-25 09:58:10 +02:00
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
float f = (float) this.totalChunks;
|
2020-06-25 09:58:10 +02:00
|
|
|
- ImmutableMap<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build();
|
|
|
|
- Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder();
|
2021-11-23 07:13:52 +01:00
|
|
|
+ ImmutableMap<ResourceKey<WorldDimension>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit
|
|
|
|
+ Builder<ResourceKey<WorldDimension>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit
|
2022-12-07 17:00:00 +01:00
|
|
|
Iterator iterator1 = this.levels.iterator();
|
2020-06-25 09:58:10 +02:00
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
while (iterator1.hasNext()) {
|
|
|
|
- ResourceKey<World> resourcekey1 = (ResourceKey) iterator1.next();
|
2021-11-21 23:00:00 +01:00
|
|
|
- Path path = this.levelStorage.getDimensionPath(resourcekey1);
|
2022-12-07 17:00:00 +01:00
|
|
|
+ ResourceKey<WorldDimension> resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit
|
2021-11-21 23:00:00 +01:00
|
|
|
+ Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
|
2020-06-25 09:58:10 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true));
|
2020-06-25 09:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
|
2021-11-23 07:13:52 +01:00
|
|
|
+ ImmutableMap<ResourceKey<WorldDimension>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
|
2021-11-21 23:00:00 +01:00
|
|
|
long i = SystemUtils.getMillis();
|
2020-06-25 09:58:10 +02:00
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
this.status = IChatBaseComponent.translatable("optimizeWorld.stage.upgrading");
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -131,7 +131,7 @@
|
2020-06-25 09:58:10 +02:00
|
|
|
float f2;
|
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
for (Iterator iterator2 = this.levels.iterator(); iterator2.hasNext(); f1 += f2) {
|
|
|
|
- ResourceKey<World> resourcekey2 = (ResourceKey) iterator2.next();
|
|
|
|
+ ResourceKey<WorldDimension> resourcekey2 = (ResourceKey) iterator2.next(); // CraftBukkit
|
2020-06-25 09:58:10 +02:00
|
|
|
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
|
|
|
|
IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2);
|
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -144,10 +144,10 @@
|
2021-11-23 07:13:52 +01:00
|
|
|
|
|
|
|
if (nbttagcompound != null) {
|
|
|
|
int j = IChunkLoader.getVersion(nbttagcompound);
|
2022-12-07 17:00:00 +01:00
|
|
|
- ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey2))).generator();
|
|
|
|
+ ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(resourcekey2)).generator(); // CraftBukkit
|
2021-11-21 23:00:00 +01:00
|
|
|
NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> {
|
2021-06-11 07:00:00 +02:00
|
|
|
return this.overworldDataStorage;
|
2021-11-21 23:00:00 +01:00
|
|
|
- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer());
|
|
|
|
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
|
|
|
|
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -227,8 +227,8 @@
|
2020-06-25 09:58:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
- private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<World> resourcekey) {
|
|
|
|
- File file = this.levelStorage.getDimensionPath(resourcekey).toFile();
|
2021-11-23 07:13:52 +01:00
|
|
|
+ private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<WorldDimension> resourcekey) { // CraftBukkit
|
2021-11-21 23:00:00 +01:00
|
|
|
+ File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit
|
2020-06-25 09:58:10 +02:00
|
|
|
File file1 = new File(file, "region");
|
|
|
|
File[] afile = file1.listFiles((file2, s) -> {
|
|
|
|
return s.endsWith(".mca");
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -288,7 +288,7 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
}
|
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
public Set<ResourceKey<World>> levels() {
|
|
|
|
- return this.levels;
|
2021-06-11 07:00:00 +02:00
|
|
|
+ throw new AssertionError("Unsupported"); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
public float dimensionProgress(ResourceKey<World> resourcekey) {
|