From 335f485dd4ee6ce7f19dd8ee1492cf1f7e43ec1a Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 26 Apr 2024 10:45:00 +0200 Subject: [PATCH] Fix compile issues --- ...x-and-optimise-world-force-upgrading.patch | 46 +++++++++++-------- patches/server/Rewrite-chunk-system.patch | 20 +++++++- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/patches/server/Fix-and-optimise-world-force-upgrading.patch b/patches/server/Fix-and-optimise-world-force-upgrading.patch index c68d56ef5c..10b41f5308 100644 --- a/patches/server/Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/Fix-and-optimise-world-force-upgrading.patch @@ -40,8 +40,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.world; + +import com.mojang.datafixers.DataFixer; -+import com.mojang.serialization.Codec; ++import com.mojang.serialization.MapCodec; +import net.minecraft.SharedConstants; ++import net.minecraft.core.RegistryAccess; ++import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.worldupdate.WorldUpgrader; @@ -50,9 +52,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.chunk.storage.ChunkStorage; +import net.minecraft.world.level.chunk.storage.RegionFileStorage; -+import net.minecraft.world.level.dimension.DimensionType; ++import net.minecraft.world.level.chunk.storage.RegionStorageInfo; +import net.minecraft.world.level.dimension.LevelStem; -+import net.minecraft.world.level.levelgen.WorldGenSettings; +import net.minecraft.world.level.storage.DimensionDataStorage; +import net.minecraft.world.level.storage.LevelStorageSource; +import org.apache.logging.log4j.LogManager; @@ -77,12 +78,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final File worldDir; + private final ExecutorService threadPool; + private final DataFixer dataFixer; -+ private final Optional>> generatorKey; ++ private final RegistryAccess registryLookup; ++ private final Optional>> generatorKey; + private final boolean removeCaches; + private final boolean recreateRegionFiles; // TODO + + public ThreadedWorldUpgrader(final ResourceKey dimensionType, final String worldName, final File worldDir, final int threads, -+ final DataFixer dataFixer, final Optional>> generatorKey, ++ final DataFixer dataFixer, final RegistryAccess registryLookup, final Optional>> generatorKey, + final boolean removeCaches, final boolean recreateRegionFiles) { + this.dimensionType = dimensionType; + this.worldName = worldName; @@ -103,6 +105,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + }); + this.dataFixer = dataFixer; ++ this.registryLookup = registryLookup; + this.generatorKey = generatorKey; + this.removeCaches = removeCaches; + this.recreateRegionFiles = recreateRegionFiles; @@ -110,24 +113,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + public void convert() { + final File worldFolder = LevelStorageSource.getStorageFolder(this.worldDir.toPath(), this.dimensionType).toFile(); -+ final DimensionDataStorage worldPersistentData = new DimensionDataStorage(new File(worldFolder, "data"), this.dataFixer); ++ final DimensionDataStorage worldPersistentData = new DimensionDataStorage(new File(worldFolder, "data"), this.dataFixer, this.registryLookup); + + final File regionFolder = new File(worldFolder, "region"); + -+ LOGGER.info("Force upgrading " + this.worldName); -+ LOGGER.info("Counting regionfiles for " + this.worldName); ++ LOGGER.info("Force upgrading {}", this.worldName); ++ LOGGER.info("Counting regionfiles for {}", this.worldName); + final File[] regionFiles = regionFolder.listFiles((final File dir, final String name) -> { + return WorldUpgrader.REGEX.matcher(name).matches(); + }); + if (regionFiles == null) { -+ LOGGER.info("Found no regionfiles to convert for world " + this.worldName); ++ LOGGER.info("Found no regionfiles to convert for world {}", this.worldName); + return; + } -+ LOGGER.info("Found " + regionFiles.length + " regionfiles to convert"); -+ LOGGER.info("Starting conversion now for world " + this.worldName); ++ LOGGER.info("Found {} regionfiles to convert", regionFiles.length); ++ LOGGER.info("Starting conversion now for world {}", this.worldName); ++ ++ // Only used for profiling, let's fill it anyways just in case ++ final RegionStorageInfo storageInfo = new RegionStorageInfo( ++ this.worldName, ++ ResourceKey.create(Registries.DIMENSION, this.dimensionType.location()), ++ "region" ++ ); + + final WorldInfo info = new WorldInfo(() -> worldPersistentData, -+ new ChunkStorage(regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); ++ new ChunkStorage(storageInfo, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); + + long expectedChunks = (long)regionFiles.length * (32L * 32L); + @@ -173,12 +183,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public final ChunkStorage loader; + public final boolean removeCaches; + public final ResourceKey worldKey; -+ public final Optional>> generatorKey; ++ public final Optional>> generatorKey; + public final AtomicLong convertedChunks = new AtomicLong(); + public final AtomicLong modifiedChunks = new AtomicLong(); + + private WorldInfo(final Supplier persistentDataSupplier, final ChunkStorage loader, final boolean removeCaches, -+ final ResourceKey worldKey, Optional>> generatorKey) { ++ final ResourceKey worldKey, Optional>> generatorKey) { + this.persistentDataSupplier = persistentDataSupplier; + this.loader = loader; + this.removeCaches = removeCaches; @@ -259,9 +269,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - fix and optimise world upgrading + public static void convertWorldButItWorks(net.minecraft.resources.ResourceKey dimensionType, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession, -+ DataFixer dataFixer, Optional>> generatorKey, boolean removeCaches, boolean recreateRegionFiles) { ++ DataFixer dataFixer, RegistryAccess registryLookup, Optional>> generatorKey, boolean removeCaches, boolean recreateRegionFiles) { + int threads = Runtime.getRuntime().availableProcessors() * 3 / 8; -+ final io.papermc.paper.world.ThreadedWorldUpgrader worldUpgrader = new io.papermc.paper.world.ThreadedWorldUpgrader(dimensionType, worldSession.getLevelId(), worldSession.levelDirectory.path().toFile(), threads, dataFixer, generatorKey, removeCaches, recreateRegionFiles); ++ final io.papermc.paper.world.ThreadedWorldUpgrader worldUpgrader = new io.papermc.paper.world.ThreadedWorldUpgrader(dimensionType, worldSession.getLevelId(), worldSession.levelDirectory.path().toFile(), threads, dataFixer, registryLookup, generatorKey, removeCaches, recreateRegionFiles); + worldUpgrader.convert(); + } + // Paper end - fix and optimise world upgrading @@ -293,7 +303,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - fix and optimise world upgrading + if (options.has("forceUpgrade")) { + net.minecraft.server.Main.convertWorldButItWorks( -+ dimensionKey, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), options.has("eraseCache"), console.has("recreateRegionFiles") ++ dimensionKey, worldSession, DataFixers.getDataFixer(), iregistrycustom_dimension, worlddimension.generator().getTypeNameForDataFixer(), options.has("eraseCache"), options.has("recreateRegionFiles") + ); + } + // Paper end - fix and optimise world upgrading @@ -376,7 +386,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - fix and optimise world upgrading + if (this.console.options.has("forceUpgrade")) { + net.minecraft.server.Main.convertWorldButItWorks( -+ actualDimension, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), this.console.options.has("eraseCache"), this.console.options.has("recreateRegionFiles") ++ actualDimension, worldSession, DataFixers.getDataFixer(), iregistrycustom_dimension, worlddimension.generator().getTypeNameForDataFixer(), this.console.options.has("eraseCache"), this.console.options.has("recreateRegionFiles") + ); + } + // Paper end - fix and optimise world upgrading diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index 027aee7147..b7d0d19653 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -18733,7 +18733,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); - EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); -+ this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system // EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); ++ this.entityStorage = new EntityRegionFileStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system - this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage); + // this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system @@ -19475,6 +19475,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean remove(Object object) { int i = this.findIndex((T)object); +diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java ++++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java +@@ -0,0 +0,0 @@ public class WorldUpgrader { + this.previousWriteFuture.join(); + } + ++ // Paper start - async chunk io ++ try { + this.previousWriteFuture = storage.write(chunkPos, nbttagcompound1); ++ } catch (final IOException e) { ++ com.destroystokyo.paper.util.SneakyThrow.sneaky(e); ++ } ++ // Paper end - async chunk io + return true; + } + } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java