2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-12-12 17:20:43 +01:00
|
|
|
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
|
2020-06-26 01:38:24 +02:00
|
|
|
index 79cf31d6fcd0e82ee146c489448a93a6e55e4190..d44d594b52cd63adcede55fbe6548b758b482c90 100644
|
2019-12-12 17:20:43 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-06-26 01:38:24 +02:00
|
|
|
@@ -3062,10 +3062,13 @@ public abstract class EntityLiving extends Entity {
|
|
|
|
this.datawatcher.set(EntityLiving.an, (byte) j);
|
2019-12-12 17:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- 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;
|
2020-06-26 01:38:24 +02:00
|
|
|
this.bk = itemstack.k();
|
2019-12-12 17:20:43 +01:00
|
|
|
if (!this.world.isClientSide) {
|
2020-06-26 01:38:24 +02:00
|
|
|
@@ -3141,6 +3144,7 @@ public abstract class EntityLiving extends Entity {
|
|
|
|
this.releaseActiveItem();
|
2019-12-12 17:20:43 +01:00
|
|
|
} else {
|
|
|
|
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
|
|
|
+ this.updateActiveItem(this.getRaisedHand(), true); // Paper
|
|
|
|
this.b(this.activeItem, 16);
|
|
|
|
// CraftBukkit start - fire PlayerItemConsumeEvent
|
|
|
|
ItemStack itemstack;
|
2020-06-26 01:38:24 +02:00
|
|
|
@@ -3171,8 +3175,8 @@ public abstract class EntityLiving extends Entity {
|
2019-12-12 17:20:43 +01:00
|
|
|
this.a(this.getRaisedHand(), itemstack);
|
|
|
|
// CraftBukkit end
|
2020-06-26 01:38:24 +02:00
|
|
|
this.clearActiveItem();
|
2019-12-12 17:20:43 +01:00
|
|
|
- // 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
|