Fix Anti-Xray using wrong data in chunk deserialize

This commit is contained in:
Spottedleaf 2024-10-25 12:57:20 -07:00
parent 97d6e76ee5
commit 0fc6c032fb
2 changed files with 8 additions and 10 deletions

View file

@ -1540,6 +1540,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return null;
} else {
@@ -0,0 +0,0 @@ public record SerializableChunkData(Registry<Biome> biomeRegistry, ChunkPos chun
Codec<PalettedContainer<Holder<Biome>>> 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<PalettedContainer<BlockState>> 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 {

View file

@ -33298,15 +33298,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
DataResult dataresult;
Logger logger;
BlendingData.Packed blendingdata_d;
@@ -0,0 +0,0 @@ public record SerializableChunkData(Registry<Biome> biomeRegistry, ChunkPos chun
Codec<PalettedContainer<Holder<Biome>>> 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<Biome> 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;