Paper/Spigot-Server-Patches/0337-MC-136865-Use-valid-item-for-enchantment-checks-on-b.patch
Zach Brown 70ce6ce831
Move version command update checking to the implementation
This makes it easier for downstream projects (forks) to replace the
version fetching system with their own. It is as simple as implementing
an interface and overriding the default implementation of
org.bukkit.UnsafeValues#getVersionFetcher()

It also makes it easier for us to organize things like the version
history feature.

Lastly I have updated the paper implementation to check against the site
API rather than against jenkins.
2019-05-27 04:13:41 -05:00

35 lines
1.9 KiB
Diff

From 78cc77a1b623ffb5f63d6495d5490313e5689200 Mon Sep 17 00:00:00 2001
From: MisterVector <whizkid3000@hotmail.com>
Date: Thu, 1 Nov 2018 14:50:05 -0700
Subject: [PATCH] MC-136865: Use valid item for enchantment checks on block
break
When an itemstack runs out of durability, the amount is reduced to
0 which then marks the item as invalid. This causes the last unit
of durability to not apply enchantments as the enchantment level
check sees the item as a dud.
keep the clone of the item used to a non empty value so it represents
the item used.
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index f692da609..5bc8bd7cd 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -354,10 +354,11 @@ public class PlayerInteractManager {
ItemStack itemstack1 = this.player.getItemInMainHand();
boolean flag1 = this.player.hasBlock(iblockdata);
+ ItemStack itemstack2 = flag && flag1 && event.isDropItems() && !itemstack1.isEmpty() ? itemstack1.cloneItemStack() : ItemStack.a; // Paper - MC-136865 - clone before use
itemstack1.a(this.world, iblockdata, blockposition, this.player);
// CraftBukkit start - Check if block should drop items
if (flag && flag1 && event.isDropItems()) {
- ItemStack itemstack2 = itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack();
+ //ItemStack itemstack2 = itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack(); // Paper - MC-136865 - move up
iblockdata.getBlock().a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack2);
}
--
2.21.0