3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-14 18:40:10 +01:00

Do not crash when an exp orb attempts to mend an unrepairable item

Dieser Commit ist enthalten in:
Shane Freeder 2024-06-23 14:04:58 +01:00
Ursprung 76c2f16f57
Commit 812701d901
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Expand PlayerItemMendEvent
diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
index a758b2456acac23095fe4619ae10300a034cb460..15844971ce2cca8c679ad3aaa2dfe160e6d0b564 100644 index a758b2456acac23095fe4619ae10300a034cb460..a58ff67052fb5f33782f8b5c83465ec03ef1d073 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java --- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java +++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -354,7 +354,10 @@ public class ExperienceOrb extends Entity { @@ -354,7 +354,10 @@ public class ExperienceOrb extends Entity {
@ -14,7 +14,7 @@ index a758b2456acac23095fe4619ae10300a034cb460..15844971ce2cca8c679ad3aaa2dfe160
// CraftBukkit start // CraftBukkit start
- org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), k); - org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), k);
+ // Paper start - mending event + // 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); + org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), k, consumedExperience);
+ // Paper end - mending event + // Paper end - mending event
k = event.getRepairAmount(); k = event.getRepairAmount();