1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -64,13 +64,13 @@
private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
private final DimensionDataStorage overworldDataStorage;
- public WorldUpgrader(LevelStorageSource.LevelStorageAccess levelstoragesource_levelstorageaccess, DataFixer datafixer, Registry<LevelStem> registry, boolean flag) {
- this.dimensions = registry;
- this.levels = (Set) registry.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet());
- this.eraseCache = flag;
- this.dataFixer = datafixer;
- this.levelStorage = levelstoragesource_levelstorageaccess;
- this.overworldDataStorage = new DimensionDataStorage(this.levelStorage.getDimensionPath(Level.OVERWORLD).resolve("data").toFile(), datafixer);
+ public WorldUpgrader(LevelStorageSource.LevelStorageAccess levelStoarge, DataFixer dataFixer, Registry<LevelStem> dimensions, boolean eraseCache) {
+ this.dimensions = dimensions;
+ this.levels = (Set) java.util.stream.Stream.of(levelStoarge.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit
+ this.eraseCache = eraseCache;
+ this.dataFixer = dataFixer;
+ this.levelStorage = levelStoarge;
+ this.overworldDataStorage = new DimensionDataStorage(this.levelStorage.getDimensionPath(Level.OVERWORLD).resolve("data").toFile(), dataFixer);
this.thread = WorldUpgrader.THREAD_FACTORY.newThread(this::work);
this.thread.setUncaughtExceptionHandler((thread, throwable) -> {
WorldUpgrader.LOGGER.error("Error upgrading world", throwable);
@@ -133,48 +133,48 @@
for (Iterator iterator2 = this.levels.iterator(); iterator2.hasNext(); f1 += f2) {
ResourceKey<Level> resourcekey2 = (ResourceKey) iterator2.next();
ListIterator<ChunkPos> listiterator = (ListIterator) immutablemap.get(resourcekey2);
- ChunkStorage chunkstorage = (ChunkStorage) immutablemap1.get(resourcekey2);
+ ChunkStorage ichunkloader = (ChunkStorage) immutablemap1.get(resourcekey2);
if (listiterator.hasNext()) {
- ChunkPos chunkpos = (ChunkPos) listiterator.next();
+ ChunkPos chunkcoordintpair = (ChunkPos) listiterator.next();
boolean flag1 = false;
try {
- CompoundTag compoundtag = (CompoundTag) ((Optional) chunkstorage.read(chunkpos).join()).orElse((Object) null);
+ CompoundTag nbttagcompound = (CompoundTag) ((Optional) ichunkloader.read(chunkcoordintpair).join()).orElse((Object) null);
- if (compoundtag != null) {
- int j = ChunkStorage.getVersion(compoundtag);
+ if (nbttagcompound != null) {
+ int j = ChunkStorage.getVersion(nbttagcompound);
ChunkGenerator chunkgenerator = ((LevelStem) this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey2))).generator();
- CompoundTag compoundtag1 = chunkstorage.upgradeChunkTag(resourcekey2, () -> {
+ CompoundTag nbttagcompound1 = ichunkloader.upgradeChunkTag(Registries.levelToLevelStem(resourcekey2), () -> { // CraftBukkit
return this.overworldDataStorage;
- }, compoundtag, chunkgenerator.getTypeNameForDataFixer());
- ChunkPos chunkpos1 = new ChunkPos(compoundtag1.getInt("xPos"), compoundtag1.getInt("zPos"));
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
- if (!chunkpos1.equals(chunkpos)) {
- WorldUpgrader.LOGGER.warn("Chunk {} has invalid position {}", chunkpos, chunkpos1);
+ if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
+ WorldUpgrader.LOGGER.warn("Chunk {} has invalid position {}", chunkcoordintpair, chunkcoordintpair1);
}
boolean flag2 = j < SharedConstants.getCurrentVersion().getDataVersion().getVersion();
if (this.eraseCache) {
- flag2 = flag2 || compoundtag1.contains("Heightmaps");
- compoundtag1.remove("Heightmaps");
- flag2 = flag2 || compoundtag1.contains("isLightOn");
- compoundtag1.remove("isLightOn");
- ListTag listtag = compoundtag1.getList("sections", 10);
+ flag2 = flag2 || nbttagcompound1.contains("Heightmaps");
+ nbttagcompound1.remove("Heightmaps");
+ flag2 = flag2 || nbttagcompound1.contains("isLightOn");
+ nbttagcompound1.remove("isLightOn");
+ ListTag nbttaglist = nbttagcompound1.getList("sections", 10);
- for (int k = 0; k < listtag.size(); ++k) {
- CompoundTag compoundtag2 = listtag.getCompound(k);
+ for (int k = 0; k < nbttaglist.size(); ++k) {
+ CompoundTag nbttagcompound2 = nbttaglist.getCompound(k);
- flag2 = flag2 || compoundtag2.contains("BlockLight");
- compoundtag2.remove("BlockLight");
- flag2 = flag2 || compoundtag2.contains("SkyLight");
- compoundtag2.remove("SkyLight");
+ flag2 = flag2 || nbttagcompound2.contains("BlockLight");
+ nbttagcompound2.remove("BlockLight");
+ flag2 = flag2 || nbttagcompound2.contains("SkyLight");
+ nbttagcompound2.remove("SkyLight");
}
}
if (flag2) {
- chunkstorage.write(chunkpos, compoundtag1);
+ ichunkloader.write(chunkcoordintpair, nbttagcompound1);
flag1 = true;
}
}
@@ -185,7 +185,7 @@
throw reportedexception;
}
- WorldUpgrader.LOGGER.error("Error upgrading chunk {}", chunkpos, throwable);
+ WorldUpgrader.LOGGER.error("Error upgrading chunk {}", chunkcoordintpair, throwable);
}
if (flag1) {
@@ -211,10 +211,10 @@
UnmodifiableIterator unmodifiableiterator = immutablemap1.values().iterator();
while (unmodifiableiterator.hasNext()) {
- ChunkStorage chunkstorage1 = (ChunkStorage) unmodifiableiterator.next();
+ ChunkStorage ichunkloader1 = (ChunkStorage) unmodifiableiterator.next();
try {
- chunkstorage1.close();
+ ichunkloader1.close();
} catch (IOException ioexception) {
WorldUpgrader.LOGGER.error("Error upgrading chunk", ioexception);
}
@@ -227,8 +227,8 @@
}
}
- private List<ChunkPos> getAllChunkPos(ResourceKey<Level> resourcekey) {
- File file = this.levelStorage.getDimensionPath(resourcekey).toFile();
+ private List<ChunkPos> getAllChunkPos(ResourceKey<Level> level) {
+ File file = this.levelStorage.getDimensionPath(level).toFile();
File file1 = new File(file, "region");
File[] afile = file1.listFiles((file2, s) -> {
return s.endsWith(".mca");
@@ -255,10 +255,10 @@
try {
for (int i1 = 0; i1 < 32; ++i1) {
for (int j1 = 0; j1 < 32; ++j1) {
- ChunkPos chunkpos = new ChunkPos(i1 + k, j1 + l);
+ ChunkPos chunkcoordintpair = new ChunkPos(i1 + k, j1 + l);
- if (regionfile.doesChunkExist(chunkpos)) {
- list.add(chunkpos);
+ if (regionfile.doesChunkExist(chunkcoordintpair)) {
+ list.add(chunkcoordintpair);
}
}
}
@@ -291,8 +291,8 @@
return this.levels;
}
- public float dimensionProgress(ResourceKey<Level> resourcekey) {
- return this.progressMap.getFloat(resourcekey);
+ public float dimensionProgress(ResourceKey<Level> level) {
+ return this.progressMap.getFloat(level);
}
public float getProgress() {
|