Paper/patches/server/0107-Filter-bad-data-from-ArmorStand-and-SpawnEgg-items.patch
Nassim Jahnke 1358d1e914
Updated Upstream (CraftBukkit/Spigot) (#7580)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
881e06e5 PR-725: Add Item Unlimited Lifetime APIs

CraftBukkit Changes:
74c08312 SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall
64db5126 SPIGOT-6959: Make /loot command ignore empty items for spawn
2d760831 Increase outdated build delay
9ed7e4fb SPIGOT-6138, SPIGOT-6415: Don't call CreatureSpawnEvent after cross-dimensional travel
fc4ad813 SPIGOT-6895: Trees grown with applyBoneMeal() don't fire the StructureGrowthEvent
59733a2e SPIGOT-6961: Actually return a copy of the ItemMeta

Spigot Changes:
ffceeae3 SPIGOT-6956: Drop unload queue patch as attempt at fixing stop issue
e19ddabd PR-1011: Add Item Unlimited Lifetime APIs
34d40b0e SPIGOT-2942: give command fires PlayerDropItemEvent, cancelling it causes Item Duplication
2022-03-13 08:47:54 +01:00

47 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sat, 12 Nov 2016 23:25:22 -0600
Subject: [PATCH] Filter bad data from ArmorStand and SpawnEgg items
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d7734fbc6b684b14bc32c94e65947fb41aae126a..7320f07beffee60fe3c49016daf7a98658879a27 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -347,4 +347,12 @@ public class PaperWorldConfig {
preventTntFromMovingInWater = getBoolean("prevent-tnt-from-moving-in-water", false);
log("Prevent TNT from moving in water: " + preventTntFromMovingInWater);
}
+
+ public boolean filterNBTFromSpawnEgg = true;
+ private void fitlerNBTFromSpawnEgg() {
+ filterNBTFromSpawnEgg = getBoolean("filter-nbt-data-from-spawn-eggs-and-related", true);
+ if (!filterNBTFromSpawnEgg) {
+ Bukkit.getLogger().warning("Spawn Egg and Armor Stand NBT filtering disabled, this is a potential security risk");
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index b8155fb12ab7bb83290502e8313cbfa773ac15a7..f12eafb49c2536f91f4716188c931ad97264c113 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -310,6 +310,18 @@ public class FallingBlockEntity extends Entity {
@Override
protected void readAdditionalSaveData(CompoundTag nbt) {
this.blockState = NbtUtils.readBlockState(nbt.getCompound("BlockState"));
+ // Paper start - Block FallingBlocks with Command Blocks
+ final Block b = this.blockState.getBlock();
+ if (this.level.paperConfig.filterNBTFromSpawnEgg
+ && (b == Blocks.COMMAND_BLOCK
+ || b == Blocks.REPEATING_COMMAND_BLOCK
+ || b == Blocks.CHAIN_COMMAND_BLOCK
+ || b == Blocks.JIGSAW
+ || b == Blocks.STRUCTURE_BLOCK
+ || b instanceof net.minecraft.world.level.block.GameMasterBlock)) {
+ this.blockState = Blocks.STONE.defaultBlockState();
+ }
+ // Paper end
this.time = nbt.getInt("Time");
if (nbt.contains("HurtEntities", 99)) {
this.hurtEntities = nbt.getBoolean("HurtEntities");