13
0
geforkt von Mirrors/Paper

Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7359)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-01-22 16:59:56 -08:00
Ursprung ab498329b2
Commit 9c9ae4d774
4 geänderte Dateien mit 10 neuen und 28 gelöschten Zeilen

Datei anzeigen

@ -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);

@ -1 +1 @@
Subproject commit d924635c65e88fc042274cec6d3b47c6751b4b76
Subproject commit 2af60c806780969df782dec9263094ed3ecab39b

@ -1 +1 @@
Subproject commit 3470450418ee048d489c8b5d1c079013527c8f30
Subproject commit 30b4043e2a5385518a72e6ca4b9efa664bad4a55

@ -1 +1 @@
Subproject commit f4ff00ffa451bd116cfbab3bd9d83b42e93904dd
Subproject commit 862678eabf78c1fc309e4b9cd1c38515712e7ada