From 58268601aceebcf203c9a47440cba681534156b6 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/General-ItemMeta-fixes.patch | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/patches/server/General-ItemMeta-fixes.patch b/patches/server/General-ItemMeta-fixes.patch
index 5112f7a7e0..9a236fa5db 100644
--- a/patches/server/General-ItemMeta-fixes.patch
+++ b/patches/server/General-ItemMeta-fixes.patch
@@ -1510,6 +1510,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          this.handle = new FoodProperties(this.handle.nutrition(), this.handle.saturation(), this.handle.canAlwaysEat(), eatSeconds, this.handle.usingConvertsTo(), this.handle.effects());
      }
  
+@@ -0,0 +0,0 @@ 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());
+     }
+ 
 @@ -0,0 +0,0 @@ public final class CraftFoodComponent implements FoodComponent {
  
      @Override