diff --git a/patches/server/Rewrite-dataconverter-system.patch b/patches/server/Rewrite-dataconverter-system.patch index 71edaad42e..e786133d2c 100644 --- a/patches/server/Rewrite-dataconverter-system.patch +++ b/patches/server/Rewrite-dataconverter-system.patch @@ -21612,25 +21612,80 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return correct.equals(value) ? null : correct; + } +} -diff --git a/src/main/java/net/minecraft/util/datafix/DataFixers.java b/src/main/java/net/minecraft/util/datafix/DataFixers.java +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/util/datafix/DataFixers.java -+++ b/src/main/java/net/minecraft/util/datafix/DataFixers.java -@@ -0,0 +0,0 @@ public class DataFixers { - DataFixerBuilder datafixerbuilder = new DataFixerBuilder(SharedConstants.getCurrentVersion().getWorldVersion()); +--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { + int i = ChunkStorage.getVersion(nbttagcompound); - DataFixers.addFixers(datafixerbuilder); -- return datafixerbuilder.build(Util.bootstrapExecutor()); -+ return redirectToDataconverter(datafixerbuilder, Util.bootstrapExecutor()); // Paper + // CraftBukkit start +- if (i < 1466) { ++ if (false && i < 1466) { // Paper - no longer needed, data converter system handles it now + CompoundTag level = nbttagcompound.getCompound("Level"); + if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { + ServerChunkCache cps = (generatoraccess == null) ? null : ((ServerLevel) generatoraccess).getChunkSource(); +@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { + // CraftBukkit end + + if (i < 1493) { +- nbttagcompound = NbtUtils.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493); ++ ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.CHUNK, nbttagcompound, i, 1493); // Paper - replace chunk converter + if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { + synchronized (this.persistentDataLock) { // Paper - Async chunk loading + if (this.legacyStructureHandler == null) { +@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { + } + + ChunkStorage.injectDatafixingContext(nbttagcompound, resourcekey, optional); +- nbttagcompound = NbtUtils.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, Math.max(1493, i)); ++ nbttagcompound = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.CHUNK, nbttagcompound, Math.max(1493, i), SharedConstants.getCurrentVersion().getWorldVersion()); // Paper - replace chunk converter + if (i < SharedConstants.getCurrentVersion().getWorldVersion()) { + nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); + } +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java +@@ -0,0 +0,0 @@ public class EntityStorage implements EntityPersistentStorage { + + private CompoundTag upgradeChunkTag(CompoundTag chunkTag) { + int i = getVersion(chunkTag); +- return NbtUtils.update(this.fixerUpper, DataFixTypes.ENTITY_CHUNK, chunkTag, i); ++ return ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ENTITY_CHUNK, chunkTag, i, SharedConstants.getCurrentVersion().getWorldVersion()); // Paper - route to new converter system } -+ // Paper start -+ private static DataFixer redirectToDataconverter(final DataFixerBuilder instance, final java.util.concurrent.Executor executor) { -+ final DataFixer wrap = instance.build(executor); -+ return new ca.spottedleaf.dataconverter.minecraft.ReplacedDataFixerUpper(wrap); -+ } -+ // Paper end -+ - public static DataFixer getDataFixer() { - return DataFixers.DATA_FIXER; - } + public static int getVersion(CompoundTag chunkTag) { +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java +@@ -0,0 +0,0 @@ public class SectionStorage extends RegionFileStorage implements AutoCloseabl + int j = getVersion(dynamic); + int k = SharedConstants.getCurrentVersion().getWorldVersion(); + boolean bl = j != k; +- Dynamic dynamic2 = this.fixerUpper.update(this.type.getType(), dynamic, j, k); ++ // Paper start - route to new converter system ++ Dynamic dynamic2; ++ if (this.type.getType() == net.minecraft.util.datafix.fixes.References.POI_CHUNK) { ++ dynamic2 = new Dynamic<>(dynamic.getOps(), (T)ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.POI_CHUNK, (CompoundTag)dynamic.getValue(), j, k)); ++ } else { ++ dynamic2 = this.fixerUpper.update(this.type.getType(), dynamic, j, k); ++ } ++ // Paper end - route to new converter system + 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/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 ++++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +@@ -0,0 +0,0 @@ public class PlayerDataStorage { + // CraftBukkit end + int i = nbttagcompound.contains("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; + +- player.load(NbtUtils.update(this.fixerUpper, DataFixTypes.PLAYER, nbttagcompound, i)); ++ player.load(ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.PLAYER, nbttagcompound, i, net.minecraft.SharedConstants.getCurrentVersion().getWorldVersion())); // Paper - replace player converter + } + + return nbttagcompound;