From 081146c56e45caa7b00bfeaac6b2ad89aaecccf2 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:48:48 +0200 Subject: [PATCH] Validate using_converts_to for food component (#10931) --- patches/server/0970-General-ItemMeta-fixes.patch | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/patches/server/0970-General-ItemMeta-fixes.patch b/patches/server/0970-General-ItemMeta-fixes.patch index ad2f78a179..1f0a2364a7 100644 --- a/patches/server/0970-General-ItemMeta-fixes.patch +++ b/patches/server/0970-General-ItemMeta-fixes.patch @@ -1499,7 +1499,7 @@ index 8b407a33b04af6ae396ada0b8aca7dc246d314ef..d204845cf0b9de00589593469755cb8e + // Paper end - General ItemMeta Fixes } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java -index 63fc9138dc3388ceb9acf672b3f75ba0976e8e54..cad52601583c1f304f94de954c4d18a6005906e3 100644 +index 63fc9138dc3388ceb9acf672b3f75ba0976e8e54..5986aa3588487c2caef4c895f8883e38a674b61c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java @@ -109,6 +109,7 @@ public final class CraftFoodComponent implements FoodComponent { @@ -1510,7 +1510,15 @@ index 63fc9138dc3388ceb9acf672b3f75ba0976e8e54..cad52601583c1f304f94de954c4d18a6 this.handle = new FoodProperties(this.handle.nutrition(), this.handle.saturation(), this.handle.canAlwaysEat(), eatSeconds, this.handle.usingConvertsTo(), this.handle.effects()); } -@@ -134,6 +135,7 @@ public final class CraftFoodComponent implements FoodComponent { +@@ -119,6 +120,7 @@ public final class CraftFoodComponent implements FoodComponent { + + @Override + public void setUsingConvertsTo(ItemStack item) { ++ Preconditions.checkArgument(item == null || !item.isEmpty(), "Item cannot be empty"); // Paper - validate using_converts_to + this.handle = new FoodProperties(this.handle.nutrition(), this.handle.saturation(), this.handle.canAlwaysEat(), this.handle.eatSeconds(), Optional.ofNullable(item).map(CraftItemStack::asNMSCopy), this.handle.effects()); + } + +@@ -134,6 +136,7 @@ public final class CraftFoodComponent implements FoodComponent { @Override public FoodEffect addEffect(PotionEffect effect, float probability) {