From 568435b5fa27f67e0ba6617ddec3e344f1adffce Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 25 Feb 2022 08:46:35 -0800 Subject: [PATCH] Add DataConverter to StructureCheck, for structure lookups Mojang added a partial conversion here to quickly check for structures, which bypasses the chunk system. So we need a hook here. --- ...l-LevelStem-in-StructureCheck-from-C.patch | 42 +++++++++++++++++++ .../server/Rewrite-dataconverter-system.patch | 13 ++++++ 2 files changed, 55 insertions(+) create mode 100644 patches/server/Fix-missing-Level-LevelStem-in-StructureCheck-from-C.patch diff --git a/patches/server/Fix-missing-Level-LevelStem-in-StructureCheck-from-C.patch b/patches/server/Fix-missing-Level-LevelStem-in-StructureCheck-from-C.patch new file mode 100644 index 0000000000..3c33567a83 --- /dev/null +++ b/patches/server/Fix-missing-Level-LevelStem-in-StructureCheck-from-C.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Fri, 25 Feb 2022 07:14:48 -0800 +Subject: [PATCH] Fix missing Level -> LevelStem in StructureCheck from CB + +Need to use the right for injectDatafixingContext + +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { + + long l = minecraftserver.getWorldData().worldGenSettings().seed(); + +- this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer); ++ this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), this.getTypeKey(), chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer); // Paper - Fix missing CB diff + this.structureFeatureManager = new StructureFeatureManager(this, this.serverLevelData.worldGenSettings(), this.structureCheck); // CraftBukkit + if (this.dimensionType().createDragonFight()) { + this.dragonFight = new EndDragonFight(this, this.serverLevelData.worldGenSettings().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit +diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +@@ -0,0 +0,0 @@ public class StructureCheck { + private final RegistryAccess registryAccess; + private final Registry biomes; + private final StructureManager structureManager; +- private final ResourceKey dimension; ++ private final ResourceKey dimension; // Paper - fix missing CB diff + private final ChunkGenerator chunkGenerator; + private final LevelHeightAccessor heightAccessor; + private final BiomeSource biomeSource; +@@ -0,0 +0,0 @@ public class StructureCheck { + private final Long2ObjectMap>> loadedChunks = new Long2ObjectOpenHashMap<>(); + private final Map, Long2BooleanMap> featureChecks = new HashMap<>(); + +- public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureManager structureManager, ResourceKey worldKey, ChunkGenerator chunkGenerator, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) { ++ public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureManager structureManager, ResourceKey worldKey, ChunkGenerator chunkGenerator, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) { // Paper - fix missing CB diff + this.storageAccess = chunkIoWorker; + this.registryAccess = registryManager; + this.structureManager = structureManager; diff --git a/patches/server/Rewrite-dataconverter-system.patch b/patches/server/Rewrite-dataconverter-system.patch index f8f6dba74f..76ac940437 100644 --- a/patches/server/Rewrite-dataconverter-system.patch +++ b/patches/server/Rewrite-dataconverter-system.patch @@ -21672,6 +21672,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 OptionalDynamic optionalDynamic = dynamic2.get("Sections"); for(int l = this.levelHeightAccessor.getMinSection(); l < this.levelHeightAccessor.getMaxSection(); ++l) { +diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +@@ -0,0 +0,0 @@ public class StructureCheck { + + CompoundTag compoundTag2; + try { +- compoundTag2 = NbtUtils.update(this.fixerUpper, DataFixTypes.CHUNK, compoundTag, i); ++ compoundTag2 = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.CHUNK, compoundTag, i, net.minecraft.SharedConstants.getCurrentVersion().getWorldVersion()); // Paper - replace chunk converter + } catch (Exception var12) { + LOGGER.warn("Failed to partially datafix chunk {}", pos, var12); + return StructureCheckResult.CHUNK_LOAD_NEEDED; diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java