Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
e035fd7034
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities f23325b6 Add API for per-world simulation distances 26e1774e Add API for per-world view distances 0b541e60 Add PlayerLoginEvent#getRealAddress 5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types CraftBukkit Changes: bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs 7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst 752aac669 Implement APIs for per world view and simulation distances 57d7ef433 Preserve empty enchantment tags for glow effect 465ec3fb4 Remove connected check on setScoreboard f90ce621e Use one PermissibleBase for all command blocks 5876cca44 SPIGOT-7550: Fix creation of Arrow instances f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition 9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item Spigot Changes: ed9ba9a4 Drop no longer required patch ignoring -o option 86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message aa7cde7a Remove obsolete APIs for per world view and simulation distances 6dff577e Remove obsolete patch preserving empty `ench` tags a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress 1b02f5d6 Remove obsolete connected check on setScoreboard patch acf717eb Remove obsolete command block PermissibleBase patch 053fa2a9 Remove redundant patch dealing with null tile entities
70 Zeilen
4.9 KiB
Diff
70 Zeilen
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Thu, 20 Jan 2022 18:11:20 -0800
|
|
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
|
|
index cab5636fe6be9ee7f23ffbd5a399d2aeea1cd538..fb74f13ab2a977224e843a468ea8c72d923a75eb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
|
|
@@ -337,7 +337,7 @@ public class ExperienceOrb extends Entity {
|
|
ItemStack itemstack = (ItemStack) entry.getValue();
|
|
int j = Math.min(this.xpToDurability(amount), itemstack.getDamageValue());
|
|
// CraftBukkit start
|
|
- org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j);
|
|
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j, this::durabilityToXp); // Paper
|
|
j = event.getRepairAmount();
|
|
if (event.isCancelled()) {
|
|
return amount;
|
|
@@ -345,8 +345,13 @@ public class ExperienceOrb extends Entity {
|
|
// CraftBukkit end
|
|
|
|
itemstack.setDamageValue(itemstack.getDamageValue() - j);
|
|
- int k = amount - this.durabilityToXp(j);
|
|
+ int k = amount - event.getDurabilityToXpOperation().applyAsInt(j); // Paper
|
|
this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls
|
|
+ // Paper start
|
|
+ if (j == 0 && amount == k) { // if repair amount is 0 and no xp was removed, don't do recursion; treat as cancelled
|
|
+ return k;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
return k > 0 ? this.repairPlayerItems(player, k) : 0;
|
|
} else {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 3271d5e34df30f4d04c0cae8cfecb2391b5a8cd6..1f0b9b2c96efa68ba071e412fe1b3995e9637fb2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1748,11 +1748,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
orb.setPosRaw(handle.getX(), handle.getY(), handle.getZ());
|
|
|
|
int i = Math.min(orb.xpToDurability(amount), itemstack.getDamageValue());
|
|
- org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i);
|
|
+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i, orb::durabilityToXp); // Paper
|
|
i = event.getRepairAmount();
|
|
orb.discard();
|
|
if (!event.isCancelled()) {
|
|
- amount -= orb.durabilityToXp(i);
|
|
+ amount -= event.getDurabilityToXpOperation().applyAsInt(i); // Paper
|
|
itemstack.setDamageValue(itemstack.getDamageValue() - i);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 8d423a7ace9c140119dd49866c3a4c42017cfb60..864ff2d3c8e2e2bef744e8048ba0cdbb42787268 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1321,10 +1321,10 @@ public class CraftEventFactory {
|
|
return event;
|
|
}
|
|
|
|
- public static PlayerItemMendEvent callPlayerItemMendEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, net.minecraft.world.entity.EquipmentSlot slot, int repairAmount) {
|
|
+ public static PlayerItemMendEvent callPlayerItemMendEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, net.minecraft.world.entity.EquipmentSlot slot, int repairAmount, java.util.function.IntUnaryOperator durabilityToXpOp) { // Paper
|
|
Player player = (Player) entity.getBukkitEntity();
|
|
org.bukkit.inventory.ItemStack bukkitStack = CraftItemStack.asCraftMirror(nmsMendedItem);
|
|
- PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, CraftEquipmentSlot.getSlot(slot), (ExperienceOrb) orb.getBukkitEntity(), repairAmount);
|
|
+ PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, CraftEquipmentSlot.getSlot(slot), (ExperienceOrb) orb.getBukkitEntity(), repairAmount, durabilityToXpOp); // Paper
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
return event;
|
|
}
|