Commits

Phoenix616 authored and md_5 committed 6719d1f1e7d
SPIGOT-6708: Fix Experience Orb value not being updated in mend event
No tags

nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch

Modified
47 47
48 48 @@ -225,7 +247,7 @@
49 49 int i = this.a(entityhuman, this.value);
50 50
51 51 if (i > 0) {
52 52 - entityhuman.giveExp(i);
53 53 + entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount()
54 54 }
55 55
56 56 --this.count;
57 -@@ -243,6 +265,13 @@
57 +@@ -243,9 +265,17 @@
58 58 if (entry != null) {
59 59 ItemStack itemstack = (ItemStack) entry.getValue();
60 60 int j = Math.min(this.c(this.value), itemstack.getDamage());
61 61 + // CraftBukkit start
62 62 + org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, j);
63 63 + j = event.getRepairAmount();
64 64 + if (event.isCancelled()) {
65 65 + return i;
66 66 + }
67 67 + // CraftBukkit end
68 68
69 69 itemstack.setDamage(itemstack.getDamage() - j);
70 70 int k = i - this.b(j);
71 -@@ -270,6 +299,24 @@
71 ++ this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls
72 +
73 + return k > 0 ? this.a(entityhuman, k) : 0;
74 + } else {
75 +@@ -270,6 +300,24 @@
72 76 }
73 77
74 78 public static int getOrbValue(int i) {
75 79 + // CraftBukkit start
76 80 + if (i > 162670129) return i - 100000;
77 81 + if (i > 81335063) return 81335063;
78 82 + if (i > 40667527) return 40667527;
79 83 + if (i > 20333759) return 20333759;
80 84 + if (i > 10166857) return 10166857;
81 85 + if (i > 5083423) return 5083423;

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut