From 33efd7ee123431e251d283ee7dc4542734795f69 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Sat, 14 Dec 2024 19:27:16 +0100 Subject: [PATCH] net.minecraft.util.worldupdate --- .../util/worldupdate/WorldUpgrader.java.patch | 22 +++++++++++++ .../util/worldupdate/WorldUpgrader.java.patch | 32 ------------------- 2 files changed, 22 insertions(+), 32 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/util/worldupdate/WorldUpgrader.java.patch diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch new file mode 100644 index 0000000000..5f0dc70ca1 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/util/worldupdate/WorldUpgrader.java ++++ b/net/minecraft/util/worldupdate/WorldUpgrader.java +@@ -79,7 +_,7 @@ + LevelStorageSource.LevelStorageAccess levelStorage, DataFixer dataFixer, RegistryAccess registryAccess, boolean eraseCache, boolean recreateRegionFiles + ) { + this.dimensions = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); +- this.levels = this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); ++ this.levels = java.util.stream.Stream.of(levelStorage.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit + this.eraseCache = eraseCache; + this.dataFixer = dataFixer; + this.levelStorage = levelStorage; +@@ -357,9 +_,7 @@ + if (compoundTag != null) { + int version = ChunkStorage.getVersion(compoundTag); + ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); +- CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( +- dimension, () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer() +- ); ++ CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag(Registries.levelToLevelStem(dimension), () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer(), chunkPos, null); // CraftBukkit + ChunkPos chunkPos1 = new ChunkPos(compoundTag1.getInt("xPos"), compoundTag1.getInt("zPos")); + if (!chunkPos1.equals(chunkPos)) { + WorldUpgrader.LOGGER.warn("Chunk {} has invalid position {}", chunkPos, chunkPos1); diff --git a/paper-server/patches/unapplied/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/unapplied/net/minecraft/util/worldupdate/WorldUpgrader.java.patch deleted file mode 100644 index de3432baee..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/util/worldupdate/WorldUpgrader.java -+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -80,7 +80,7 @@ - - public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) { - this.dimensions = dynamicRegistryManager.lookupOrThrow(Registries.LEVEL_STEM); -- this.levels = (Set) this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); -+ this.levels = (Set) java.util.stream.Stream.of(session.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit - this.eraseCache = eraseCache; - this.dataFixer = dataFixer; - this.levelStorage = session; -@@ -197,9 +197,9 @@ - if (nbttagcompound != null) { - int i = ChunkStorage.getVersion(nbttagcompound); - ChunkGenerator chunkgenerator = ((LevelStem) WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(worldKey))).generator(); -- CompoundTag nbttagcompound1 = storage.upgradeChunkTag(worldKey, () -> { -+ CompoundTag nbttagcompound1 = storage.upgradeChunkTag(Registries.levelToLevelStem(worldKey), () -> { // CraftBukkit - return WorldUpgrader.this.overworldDataStorage; -- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); -+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkPos, null); // CraftBukkit - ChunkPos chunkcoordintpair1 = new ChunkPos(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); - - if (!chunkcoordintpair1.equals(chunkPos)) { -@@ -321,7 +321,7 @@ - WorldUpgrader.DimensionToUpgrade worldupgrader_c = (WorldUpgrader.DimensionToUpgrade) iterator.next(); - ResourceKey resourcekey = worldupgrader_c.dimensionKey; - ListIterator listiterator = worldupgrader_c.files; -- T t0 = (AutoCloseable) worldupgrader_c.storage; -+ T t0 = (T) worldupgrader_c.storage; // CraftBukkit - decompile error - - if (listiterator.hasNext()) { - WorldUpgrader.FileToUpgrade worldupgrader_e = (WorldUpgrader.FileToUpgrade) listiterator.next();