2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-12-12 16:20:43 +00:00
|
|
|
From: kickash32 <kickash32@gmail.com>
|
|
|
|
Date: Mon, 19 Aug 2019 19:42:35 +0500
|
|
|
|
Subject: [PATCH] Prevent consuming the wrong itemstack
|
|
|
|
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
2021-03-16 13:04:28 +00:00
|
|
|
index ecceb272028e1ae1dd40c0c39d6f687fccfabb58..903c3cfdaae3dd1750aa2f32f6cdbb423909eb47 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -3201,10 +3201,13 @@ public abstract class EntityLiving extends Entity {
|
2020-08-25 02:22:08 +00:00
|
|
|
this.datawatcher.set(EntityLiving.ag, (byte) j);
|
2019-12-12 16:20:43 +00: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-08-25 02:22:08 +00:00
|
|
|
this.bd = itemstack.k();
|
2019-12-12 16:20:43 +00:00
|
|
|
if (!this.world.isClientSide) {
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -3282,6 +3285,7 @@ public abstract class EntityLiving extends Entity {
|
2020-06-25 23:38:24 +00:00
|
|
|
this.releaseActiveItem();
|
2019-12-12 16:20:43 +00: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;
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -3316,8 +3320,8 @@ public abstract class EntityLiving extends Entity {
|
2020-08-25 02:22:08 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 23:38:24 +00:00
|
|
|
this.clearActiveItem();
|
2019-12-12 16:20:43 +00: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
|