2022-06-02 03:27:36 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Fri, 3 Dec 2021 16:55:50 -0500
2024-01-18 18:52:00 +01:00
Subject: [PATCH] Sanitize sent BlockEntity NBT
2022-06-02 03:27:36 +02:00
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
2024-04-25 23:21:18 +02:00
index 1970c0fa24764f6bbd0cc360b7d32d7906eaf808..db03254682b827d650160d6f2c1a18cf12c861d7 100644
2022-06-02 03:27:36 +02:00
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
2024-04-25 23:21:18 +02:00
@@ -23,7 +23,7 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket
2024-04-24 22:32:38 +02:00
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, BiFunction<BlockEntity, RegistryAccess, CompoundTag> nbtGetter) {
2024-04-25 23:21:18 +02:00
RegistryAccess iregistrycustom = blockEntity.getLevel().registryAccess();
- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), (CompoundTag) nbtGetter.apply(blockEntity, iregistrycustom));
+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), (CompoundTag) blockEntity.sanitizeSentNbt(nbtGetter.apply(blockEntity, iregistrycustom))); // Paper - Sanitize sent data
2022-06-02 03:27:36 +02:00
}
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) {
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
2024-04-24 22:32:38 +02:00
index ac900dfdc5c90e9e60d47efa734be8f0a5b20dca..ec1cb034d840633240f2b379b09f7d2f1c8971a5 100644
2022-06-02 03:27:36 +02:00
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
2024-04-24 22:32:38 +02:00
@@ -154,6 +154,7 @@ public class ClientboundLevelChunkPacketData {
CompoundTag compoundTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess());
2022-06-02 03:27:36 +02:00
BlockPos blockPos = blockEntity.getBlockPos();
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());
+ blockEntity.sanitizeSentNbt(compoundTag); // Paper - Sanitize sent data
return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), compoundTag.isEmpty() ? null : compoundTag);
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
2024-04-24 22:32:38 +02:00
index df945a152747bea0452ec18c09d59598903aa91f..a7dfad2696e7145af1355a5db132af14d09a6f30 100644
2022-06-02 03:27:36 +02:00
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
2024-04-24 22:32:38 +02:00
@@ -357,6 +357,14 @@ public abstract class BlockEntity {
2022-06-02 03:27:36 +02:00
}
// CraftBukkit end
2024-04-24 22:32:38 +02:00
2024-01-18 18:52:00 +01:00
+ // Paper start - Sanitize sent data
2022-06-02 03:27:36 +02:00
+ public CompoundTag sanitizeSentNbt(CompoundTag tag) {
+ tag.remove("PublicBukkitValues");
+
+ return tag;
+ }
2024-01-18 18:52:00 +01:00
+ // Paper end - Sanitize sent data
2024-04-24 22:32:38 +02:00
+
private static class ComponentHelper {
public static final Codec<DataComponentMap> COMPONENTS_CODEC = DataComponentMap.CODEC.optionalFieldOf("components", DataComponentMap.EMPTY).codec();