From 79fcb6baf44891b1558823ad05f0568ee3d68a71 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Thu, 9 May 2024 23:47:13 -0700
Subject: [PATCH] Fix chunk data version check not running in chunk system

The old read() method should just redirect to the new
chunk system method, however due to an error in moving
the chunk system patch around the data version check was
left in the old (UNUSED) read() method.
---
 patches/server/Rewrite-chunk-system.patch | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch
index d27f366447..dbf002cad3 100644
--- a/patches/server/Rewrite-chunk-system.patch
+++ b/patches/server/Rewrite-chunk-system.patch
@@ -20453,21 +20453,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        }
 +    }
      public static ProtoChunk read(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) {
-         // Paper start - Do not let the server load chunks from newer versions
-         if (nbt.contains("DataVersion", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) {
-@@ -0,0 +0,0 @@ public class ChunkSerializer {
-             }
-         }
-         // Paper end - Do not let the server load chunks from newer versions
++        // Paper start - rewrite chunk system
 +        InProgressChunkHolder holder = readInProgressChunkHolder(world, poiStorage, chunkPos, nbt);
 +        return holder.protoChunk;
 +    }
 +
 +    public static InProgressChunkHolder readInProgressChunkHolder(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) {
 +        // Paper end - rewrite chunk system
-         ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate
- 
-         if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
+         // Paper start - Do not let the server load chunks from newer versions
+         if (nbt.contains("DataVersion", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) {
+             final int dataVersion = nbt.getInt("DataVersion");
 @@ -0,0 +0,0 @@ public class ChunkSerializer {
                  achunksection[k] = chunksection;
                  SectionPos sectionposition = SectionPos.of(chunkPos, b0);