Use old dataconverter hooks (#6938)

This commit is contained in:
Jason Penilla 2021-11-27 01:10:23 -08:00
parent 53ce77d576
commit 11418ffcc1

View file

@ -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 {
}
+ // 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);
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<Entity> {
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
}
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<R> extends RegionFileStorage implements AutoCloseabl
int j = getVersion(dynamic);
int k = SharedConstants.getCurrentVersion().getWorldVersion();
boolean bl = j != k;
- Dynamic<T> dynamic2 = this.fixerUpper.update(this.type.getType(), dynamic, j, k);
+ // Paper start - route to new converter system
+ Dynamic<T> 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
+
public static DataFixer getDataFixer() {
return DataFixers.DATA_FIXER;
+ // Paper end - route to new converter system
OptionalDynamic<T> 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;