Copy itemstack when sanitizing for datawatcher items

Since the packet is broadcasted for players, it means that
the packet will be sent to multiple players. In this case,
modifying the data results in a possible race condition
where a CME may occur as the packet will be serialized on
many different netty IO threads.
This commit is contained in:
Spottedleaf 2023-06-16 10:27:59 -07:00
parent cffc14631b
commit c0d376e242

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public void write(FriendlyByteBuf buf, ItemStack value) {
- buf.writeItem(value);
+ buf.writeItem(net.minecraft.world.entity.LivingEntity.sanitizeItemStack(value, false)); // Paper - prevent oversized data
+ buf.writeItem(net.minecraft.world.entity.LivingEntity.sanitizeItemStack(value, true)); // Paper - prevent oversized data
}
@Override