From 0fc6c032fb164f9535f5961e07ee1335a011068e Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 25 Oct 2024 12:57:20 -0700 Subject: [PATCH] Fix Anti-Xray using wrong data in chunk deserialize --- patches/server/Anti-Xray.patch | 9 ++++++++- patches/server/Moonrise-optimisation-patches.patch | 9 --------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/patches/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch index ba57630adf..95551bd4ba 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -1540,6 +1540,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return null; } else { @@ -0,0 +0,0 @@ public record SerializableChunkData(Registry biomeRegistry, ChunkPos chun + Codec>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write + + for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) { +- CompoundTag nbttagcompound3 = nbttaglist2.getCompound(i1); ++ CompoundTag nbttagcompound3 = nbttaglist2.getCompound(i1); final CompoundTag sectionData = nbttagcompound3; // Paper - Anti-Xray - OBFHELPER + byte b0 = nbttagcompound3.getByte("Y"); + LevelChunkSection chunksection; if (b0 >= world.getMinSectionY() && b0 <= world.getMaxSectionY()) { PalettedContainer datapaletteblock; @@ -1550,7 +1557,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (nbttagcompound3.contains("block_states", 10)) { - datapaletteblock = (PalettedContainer) SerializableChunkData.BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, nbttagcompound3.getCompound("block_states")).promotePartial((s1) -> { + Codec> blockStateCodec = presetBlockStates == null ? BLOCK_STATE_CODEC : PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), presetBlockStates); // Paper - Anti-Xray -+ datapaletteblock = blockStateCodec.parse(NbtOps.INSTANCE, nbttagcompound1.getCompound("block_states")).promotePartial((s1) -> { // Paper - Anti-Xray ++ datapaletteblock = blockStateCodec.parse(NbtOps.INSTANCE, sectionData.getCompound("block_states")).promotePartial((s1) -> { // Paper - Anti-Xray logErrors(chunkcoordintpair, b0, s1); }).getOrThrow(SerializableChunkData.ChunkReadException::new); } else { diff --git a/patches/server/Moonrise-optimisation-patches.patch b/patches/server/Moonrise-optimisation-patches.patch index 87f4d5aabd..f437c2333e 100644 --- a/patches/server/Moonrise-optimisation-patches.patch +++ b/patches/server/Moonrise-optimisation-patches.patch @@ -33298,15 +33298,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 DataResult dataresult; Logger logger; BlendingData.Packed blendingdata_d; -@@ -0,0 +0,0 @@ public record SerializableChunkData(Registry biomeRegistry, ChunkPos chun - Codec>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write - - for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) { -- CompoundTag nbttagcompound3 = nbttaglist2.getCompound(i1); -+ CompoundTag nbttagcompound3 = nbttaglist2.getCompound(i1); final CompoundTag sectionData = nbttagcompound3; // Paper - starlight - OBFHELPER - byte b0 = nbttagcompound3.getByte("Y"); - LevelChunkSection chunksection; - @@ -0,0 +0,0 @@ public record SerializableChunkData(Registry biomeRegistry, ChunkPos chun DataLayer nibblearray = nbttagcompound3.contains("BlockLight", 7) ? new DataLayer(nbttagcompound3.getByteArray("BlockLight")) : null; DataLayer nibblearray1 = nbttagcompound3.contains("SkyLight", 7) ? new DataLayer(nbttagcompound3.getByteArray("SkyLight")) : null;