Paper/Spigot-Server-Patches/0399-Prevent-consuming-the-wrong-itemstack.patch
Aikar e4d10a6d67
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears 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:
122289ff Add FaceAttachable interface to handle Grindstone facing in common with Switches
a6db750e SPIGOT-5647: ZombieVillager entity should have getVillagerType()

CraftBukkit Changes:
bbe3d58e SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException
3075579f Add FaceAttachable interface to handle Grindstone facing in common with Switches
95bd4238 SPIGOT-5647: ZombieVillager entity should have getVillagerType()
4d975ac3 SPIGOT-5617: setBlockData does not work when NotPlayEvent is called by redstone current
2020-04-02 17:09:17 -04:00

49 lines
2.3 KiB
Diff

From 7308ea37d709dcfe69c85d3c87113c4f851c0dab Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Mon, 19 Aug 2019 19:42:35 +0500
Subject: [PATCH] Prevent consuming the wrong itemstack
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index af79b6e378..b098cd6d77 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2893,10 +2893,13 @@ public abstract class EntityLiving extends Entity {
this.datawatcher.set(EntityLiving.ao, (byte) j);
}
- public void c(EnumHand enumhand) {
+ // Paper start -- OBFHELPER and forwarder to method with forceUpdate parameter
+ public void c(EnumHand enumhand) { this.updateActiveItem(enumhand, false); }
+ public void updateActiveItem(EnumHand enumhand, boolean forceUpdate) {
+ // Paper end
ItemStack itemstack = this.b(enumhand);
- if (!itemstack.isEmpty() && !this.isHandRaised()) {
+ if (!itemstack.isEmpty() && !this.isHandRaised() || forceUpdate) { // Paper use override flag
this.activeItem = itemstack;
this.bl = itemstack.k();
if (!this.world.isClientSide) {
@@ -2972,6 +2975,7 @@ public abstract class EntityLiving extends Entity {
this.clearActiveItem();
} else {
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
+ this.updateActiveItem(this.getRaisedHand(), true); // Paper
this.b(this.activeItem, 16);
// CraftBukkit start - fire PlayerItemConsumeEvent
ItemStack itemstack;
@@ -3002,8 +3006,8 @@ public abstract class EntityLiving extends Entity {
this.a(this.getRaisedHand(), itemstack);
// CraftBukkit end
this.dH();
- // Paper start - if the replacement is anything but the default, update the client inventory
- if (this instanceof EntityPlayer && !com.google.common.base.Objects.equal(defaultReplacement, itemstack)) {
+ // Paper start
+ if (this instanceof EntityPlayer) {
((EntityPlayer) this).getBukkitEntity().updateInventory();
}
// Paper end
--
2.25.1