From a23eb53e1319c732f6b0412aa97b1bc876aa0cdb Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 25 Jun 2021 18:56:12 -0700 Subject: [PATCH] Fix use of universe flag and forceUpgrade --- ...x-and-optimise-world-force-upgrading.patch | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/patches/server/0688-Fix-and-optimise-world-force-upgrading.patch b/patches/server/0688-Fix-and-optimise-world-force-upgrading.patch index 376c4ddd3..300b7a4f8 100644 --- a/patches/server/0688-Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/0688-Fix-and-optimise-world-force-upgrading.patch @@ -30,10 +30,10 @@ easy to add threading, so I did. diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java new file mode 100644 -index 0000000000000000000000000000000000000000..452934a7a037c8b1c5f9906c7af75ed8c449ebc0 +index 0000000000000000000000000000000000000000..389faf099ff64bb2845222600552c8fc2c83485f --- /dev/null +++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java -@@ -0,0 +1,200 @@ +@@ -0,0 +1,202 @@ +package io.papermc.paper.world; + +import com.mojang.datafixers.DataFixer; @@ -67,15 +67,17 @@ index 0000000000000000000000000000000000000000..452934a7a037c8b1c5f9906c7af75ed8 + private final ResourceKey dimensionType; + private final ResourceKey worldKey; + private final String worldName; ++ private final File worldDir; + private final ExecutorService threadPool; + private final DataFixer dataFixer; + private final boolean removeCaches; + -+ public ThreadedWorldUpgrader(final ResourceKey dimensionType, final ResourceKey worldKey, final String worldName, final int threads, ++ public ThreadedWorldUpgrader(final ResourceKey dimensionType, final ResourceKey worldKey, final String worldName, final File worldDir, final int threads, + final DataFixer dataFixer, final boolean removeCaches) { + this.dimensionType = dimensionType; + this.worldKey = worldKey; + this.worldName = worldName; ++ this.worldDir = worldDir; + this.threadPool = Executors.newFixedThreadPool(Math.max(1, threads), new ThreadFactory() { + private final AtomicInteger threadCounter = new AtomicInteger(); + @@ -96,7 +98,7 @@ index 0000000000000000000000000000000000000000..452934a7a037c8b1c5f9906c7af75ed8 + } + + public void convert() { -+ final File worldFolder = LevelStorageSource.getFolder(new File(this.worldName), this.dimensionType); ++ final File worldFolder = LevelStorageSource.getFolder(this.worldDir, this.dimensionType); + final DimensionDataStorage worldPersistentData = new DimensionDataStorage(new File(worldFolder, "data"), this.dataFixer); + + final File regionFolder = new File(worldFolder, "region"); @@ -235,7 +237,7 @@ index 0000000000000000000000000000000000000000..452934a7a037c8b1c5f9906c7af75ed8 + } +} diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index cf0a74b8a1c31d4bc493eb09a69ee2bd94cb6485..6fa1a7da70896d0ff34d38698769195a98c06195 100644 +index cf0a74b8a1c31d4bc493eb09a69ee2bd94cb6485..cfd43069ee2b6f79afb12e10d223f6bf75100034 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -15,6 +15,7 @@ import java.nio.file.Paths; @@ -251,10 +253,10 @@ index cf0a74b8a1c31d4bc493eb09a69ee2bd94cb6485..6fa1a7da70896d0ff34d38698769195a // Paper end + // Paper start - fix and optimise world upgrading -+ public static void convertWorldButItWorks(ResourceKey dimensionType, ResourceKey worldKey, String worldName, ++ public static void convertWorldButItWorks(ResourceKey dimensionType, ResourceKey worldKey, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession, + DataFixer dataFixer, boolean removeCaches) { + int threads = Runtime.getRuntime().availableProcessors() * 3 / 8; -+ final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldKey, worldName, threads, dataFixer, removeCaches); ++ final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldKey, worldSession.getLevelId(), worldSession.levelPath.toFile(), threads, dataFixer, removeCaches); + worldUpgrader.convert(); + } + // Paper end - fix and optimise world upgrading @@ -263,7 +265,7 @@ index cf0a74b8a1c31d4bc493eb09a69ee2bd94cb6485..6fa1a7da70896d0ff34d38698769195a Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, worlds, eraseCache); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 4ad480092a87b7bede679cf5e86000702ab8ee6a..2b7b63ea08c8e4f43c9678671fb8d08628b48b36 100644 +index a741d644be29b4ec4b5afa0625c6a784ae0cdbbc..d8c2263a7fa89719dc653ba12635488fc36420a7 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -563,13 +563,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop