Expand PlayerItemMendEvent
This commit is contained in:
@@ -215,12 +215,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,12 +359,20 @@
|
||||
@@ -266,12 +359,23 @@
|
||||
ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack();
|
||||
int j = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), itemstack, amount);
|
||||
int k = Math.min(j, itemstack.getDamageValue());
|
||||
+ // 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 > 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();
|
||||
+ if (event.isCancelled()) {
|
||||
+ return amount;
|
||||
@@ -229,14 +232,15 @@
|
||||
|
||||
itemstack.setDamageValue(itemstack.getDamageValue() - k);
|
||||
if (k > 0) {
|
||||
int l = amount - k * amount / j;
|
||||
- int l = amount - k * amount / j;
|
||||
+ int l = amount - k * amount / j; // Paper - diff on change - expand PlayerMendEvents
|
||||
|
||||
if (l > 0) {
|
||||
+ // this.value = l; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls // Paper - the value field should not be mutated here because it doesn't take "count" into account
|
||||
return this.repairPlayerItems(player, l);
|
||||
}
|
||||
}
|
||||
@@ -291,6 +392,24 @@
|
||||
@@ -291,6 +395,24 @@
|
||||
}
|
||||
|
||||
public static int getExperienceValue(int value) {
|
||||
|
||||
Reference in New Issue
Block a user