aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0414-Prevent-consuming-the-wrong-itemstack.patch
blob: 383afca7f47b82fbda81d611ffb7b7abf6e6a92c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From f4f54ad4f65341733ca29e1cc2e469952103dfa4 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 31d14b19b..f675ad2f5 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2822,10 +2822,13 @@ public abstract class EntityLiving extends Entity {
         this.datawatcher.set(EntityLiving.ar, (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.bo = itemstack.k();
             if (!this.world.isClientSide) {
@@ -2898,6 +2901,7 @@ public abstract class EntityLiving extends Entity {
 
     protected void q() {
         if (!this.activeItem.isEmpty() && this.isHandRaised()) {
+            this.updateActiveItem(this.getRaisedHand(), true); // Paper
             PlayerItemConsumeEvent event = null; // Paper
             this.b(this.activeItem, 16);
             // CraftBukkit start - fire PlayerItemConsumeEvent
@@ -2928,8 +2932,8 @@ public abstract class EntityLiving extends Entity {
             this.a(this.getRaisedHand(), itemstack);
             // CraftBukkit end
             this.dp();
-            // 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.23.0