From 69258a8c334a503cc60d227eede6b3a8c093362b Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 23 Jun 2024 14:04:58 +0100
Subject: [PATCH] Do not crash when an exp orb attempts to mend an unrepairable
 item

---
 patches/server/Expand-PlayerItemMendEvent.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/patches/server/Expand-PlayerItemMendEvent.patch b/patches/server/Expand-PlayerItemMendEvent.patch
index f3afab364d..ceb80423e7 100644
--- a/patches/server/Expand-PlayerItemMendEvent.patch
+++ b/patches/server/Expand-PlayerItemMendEvent.patch
@@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              // CraftBukkit start
 -            org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), k);
 +            // Paper start - mending event
-+            final int consumedExperience = k * amount / j;
++            final int consumedExperience = k > 0 ? k * amount / j : 0;
 +            org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), k, consumedExperience);
 +            // Paper end - mending event
              k = event.getRepairAmount();