mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-10 01:21:46 +01:00
SPIGOT-7447: Rewrite --forceUpgrade to minimise diff and properly handle CraftBukkit world layout
By: md_5 <git@md-5.net>
This commit is contained in:
parent
8847a42387
commit
0379c2cfee
@ -269,7 +269,7 @@
|
|||||||
+ if (options.has("forceUpgrade")) {
|
+ if (options.has("forceUpgrade")) {
|
||||||
+ net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> {
|
+ net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> {
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }, iregistry);
|
+ }, dimensions);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ WorldDataServer iworlddataserver = worlddata;
|
+ WorldDataServer iworlddataserver = worlddata;
|
||||||
|
@ -1,109 +1,23 @@
|
|||||||
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
@@ -48,7 +48,7 @@
|
@@ -66,7 +66,7 @@
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
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 @@
|
|
||||||
private volatile int totalChunks;
|
|
||||||
private volatile int converted;
|
|
||||||
private volatile int skipped;
|
|
||||||
- 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
|
|
||||||
private volatile IChatBaseComponent status = IChatBaseComponent.translatable("optimizeWorld.stage.counting");
|
|
||||||
private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
|
||||||
private final WorldPersistentData overworldDataStorage;
|
|
||||||
|
|
||||||
public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistry<WorldDimension> iregistry, boolean flag) {
|
public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistry<WorldDimension> iregistry, boolean flag) {
|
||||||
this.dimensions = iregistry;
|
this.dimensions = iregistry;
|
||||||
- this.levels = (Set) iregistry.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet());
|
- this.levels = (Set) iregistry.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet());
|
||||||
+ this.levels = (Set) iregistry.registryKeySet().stream().collect(Collectors.toUnmodifiableSet()); // CraftBukkit
|
+ this.levels = (Set) java.util.stream.Stream.of(convertable_conversionsession.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit
|
||||||
this.eraseCache = flag;
|
this.eraseCache = flag;
|
||||||
this.dataFixer = datafixer;
|
this.dataFixer = datafixer;
|
||||||
this.levelStorage = convertable_conversionsession;
|
this.levelStorage = convertable_conversionsession;
|
||||||
@@ -93,12 +93,12 @@
|
@@ -145,9 +145,9 @@
|
||||||
|
|
||||||
private void work() {
|
|
||||||
this.totalChunks = 0;
|
|
||||||
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
|
|
||||||
+ Builder<ResourceKey<WorldDimension>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
|
|
||||||
|
|
||||||
List list;
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
list = this.getAllChunkPos(resourcekey);
|
|
||||||
builder.put(resourcekey, list.listIterator());
|
|
||||||
@@ -108,18 +108,18 @@
|
|
||||||
this.finished = true;
|
|
||||||
} else {
|
|
||||||
float f = (float) this.totalChunks;
|
|
||||||
- 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
|
|
||||||
Iterator iterator1 = this.levels.iterator();
|
|
||||||
|
|
||||||
while (iterator1.hasNext()) {
|
|
||||||
- ResourceKey<World> resourcekey1 = (ResourceKey) iterator1.next();
|
|
||||||
- Path path = this.levelStorage.getDimensionPath(resourcekey1);
|
|
||||||
+ ResourceKey<WorldDimension> resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit
|
|
||||||
+ Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
|
|
||||||
|
|
||||||
builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
|
|
||||||
+ ImmutableMap<ResourceKey<WorldDimension>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
|
|
||||||
long i = SystemUtils.getMillis();
|
|
||||||
|
|
||||||
this.status = IChatBaseComponent.translatable("optimizeWorld.stage.upgrading");
|
|
||||||
@@ -131,7 +131,7 @@
|
|
||||||
float f2;
|
|
||||||
|
|
||||||
for (Iterator iterator2 = this.levels.iterator(); iterator2.hasNext(); f1 += f2) {
|
|
||||||
- ResourceKey<World> resourcekey2 = (ResourceKey) iterator2.next();
|
|
||||||
+ ResourceKey<WorldDimension> resourcekey2 = (ResourceKey) iterator2.next(); // CraftBukkit
|
|
||||||
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
|
|
||||||
IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2);
|
|
||||||
|
|
||||||
@@ -144,10 +144,10 @@
|
|
||||||
|
|
||||||
if (nbttagcompound != null) {
|
if (nbttagcompound != null) {
|
||||||
int j = IChunkLoader.getVersion(nbttagcompound);
|
int j = IChunkLoader.getVersion(nbttagcompound);
|
||||||
- ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey2))).generator();
|
ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey2))).generator();
|
||||||
+ ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(resourcekey2)).generator(); // CraftBukkit
|
- NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> {
|
||||||
NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> {
|
+ NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(Registries.levelToLevelStem(resourcekey2), () -> { // CraftBukkit
|
||||||
return this.overworldDataStorage;
|
return this.overworldDataStorage;
|
||||||
- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer());
|
- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer());
|
||||||
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
|
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
|
||||||
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
|
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
|
||||||
|
|
||||||
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
|
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
|
||||||
@@ -227,8 +227,8 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<World> resourcekey) {
|
|
||||||
- File file = this.levelStorage.getDimensionPath(resourcekey).toFile();
|
|
||||||
+ private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<WorldDimension> 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");
|
|
||||||
@@ -288,7 +288,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<ResourceKey<World>> levels() {
|
|
||||||
- return this.levels;
|
|
||||||
+ throw new AssertionError("Unsupported"); // CraftBukkit
|
|
||||||
}
|
|
||||||
|
|
||||||
public float dimensionProgress(ResourceKey<World> resourcekey) {
|
|
||||||
|
Loading…
Reference in New Issue
Block a user