From 9c9ae4d774b9c5cea20fee1c8b43bf74bd79cac9 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Sat, 22 Jan 2022 16:59:56 -0800 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7359) --- .../Ability-to-apply-mending-to-XP-API.patch | 32 ++++--------------- work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/patches/server/Ability-to-apply-mending-to-XP-API.patch b/patches/server/Ability-to-apply-mending-to-XP-API.patch index 4afd01d088..1f719680fd 100644 --- a/patches/server/Ability-to-apply-mending-to-XP-API.patch +++ b/patches/server/Ability-to-apply-mending-to-XP-API.patch @@ -9,39 +9,22 @@ of giving the player experience points. Both an API To standalone mend, and apply mending logic to .giveExp has been added. -diff --git a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java -+++ b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java -@@ -0,0 +0,0 @@ public class EnchantmentHelper { - return getItemEnchantmentLevel(Enchantments.CHANNELING, stack) > 0; - } - -- @Nullable -- public static Entry<EquipmentSlot, ItemStack> getRandomItemWith(Enchantment enchantment, LivingEntity entity) { -+ @Deprecated public static @javax.annotation.Nonnull ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, LivingEntity entityliving) { -+ Entry<EquipmentSlot, ItemStack> entry = getRandomItemWith(enchantment, entityliving); -+ return entry != null ? entry.getValue() : ItemStack.EMPTY; -+ } // Paper - OBFHELPER -+ @Nullable public static Entry<EquipmentSlot, ItemStack> getRandomItemWith(Enchantment enchantment, LivingEntity entity) { - return getRandomItemWith(enchantment, entity, (stack) -> { - return true; - }); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return GameMode.getByValue(this.getHandle().gameMode.getGameModeForPlayer().getId()); } + @Override +- public void giveExp(int exp) { + // Paper start -+ @Override + public int applyMending(int amount) { -+ ServerPlayer handle = getHandle(); ++ ServerPlayer handle = this.getHandle(); + // Logic copied from EntityExperienceOrb and remapped to unobfuscated methods/properties -+ net.minecraft.world.item.ItemStack itemstack = net.minecraft.world.item.enchantment.EnchantmentHelper -+ .getRandomEquippedItemWithEnchant(net.minecraft.world.item.enchantment.Enchantments.MENDING, handle); ++ final var stackEntry = net.minecraft.world.item.enchantment.EnchantmentHelper ++ .getRandomItemWith(net.minecraft.world.item.enchantment.Enchantments.MENDING, handle); ++ final net.minecraft.world.item.ItemStack itemstack = stackEntry != null ? stackEntry.getValue() : net.minecraft.world.item.ItemStack.EMPTY; + if (!itemstack.isEmpty() && itemstack.getItem().canBeDepleted()) { + net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level); + orb.value = amount; @@ -60,8 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return amount; + } + - @Override -- public void giveExp(int exp) { ++ @Override + public void giveExp(int exp, boolean applyMending) { + if (applyMending) { + exp = this.applyMending(exp); diff --git a/work/Bukkit b/work/Bukkit index d924635c65..2af60c8067 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit d924635c65e88fc042274cec6d3b47c6751b4b76 +Subproject commit 2af60c806780969df782dec9263094ed3ecab39b diff --git a/work/CraftBukkit b/work/CraftBukkit index 3470450418..30b4043e2a 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 3470450418ee048d489c8b5d1c079013527c8f30 +Subproject commit 30b4043e2a5385518a72e6ca4b9efa664bad4a55 diff --git a/work/Spigot b/work/Spigot index f4ff00ffa4..862678eabf 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit f4ff00ffa451bd116cfbab3bd9d83b42e93904dd +Subproject commit 862678eabf78c1fc309e4b9cd1c38515712e7ada