2021-06-11 12:02:28 +00:00
|
|
|
From 0000000000000000000000000000000000000000 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/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2022-10-02 07:56:36 +00:00
|
|
|
index 4e490415e31fcd1a5d780a085ac916cbfc54bb12..b85b98aaa1148c23232a633447c815003373c7c3 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2022-10-02 07:56:36 +00:00
|
|
|
@@ -3624,9 +3624,14 @@ public abstract class LivingEntity extends Entity {
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 05:44:21 +00:00
|
|
|
public void startUsingItem(InteractionHand hand) {
|
|
|
|
+ // Paper start - forwarder to method with forceUpdate parameter
|
|
|
|
+ this.startUsingItem(hand, false);
|
|
|
|
+ }
|
|
|
|
+ public void startUsingItem(InteractionHand hand, boolean forceUpdate) {
|
|
|
|
+ // Paper end
|
|
|
|
ItemStack itemstack = this.getItemInHand(hand);
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
- if (!itemstack.isEmpty() && !this.isUsingItem()) {
|
|
|
|
+ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag
|
|
|
|
this.useItem = itemstack;
|
|
|
|
this.useItemRemaining = itemstack.getUseDuration();
|
|
|
|
if (!this.level.isClientSide) {
|
2022-10-02 07:56:36 +00:00
|
|
|
@@ -3706,6 +3711,7 @@ public abstract class LivingEntity extends Entity {
|
2021-11-24 22:26:32 +00:00
|
|
|
this.releaseUsingItem();
|
|
|
|
} else {
|
|
|
|
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
2021-11-24 05:44:21 +00:00
|
|
|
+ this.startUsingItem(this.getUsedItemHand(), true); // Paper
|
2021-11-24 22:26:32 +00:00
|
|
|
this.triggerItemUseEffects(this.useItem, 16);
|
|
|
|
// CraftBukkit start - fire PlayerItemConsumeEvent
|
|
|
|
ItemStack itemstack;
|
2022-10-02 07:56:36 +00:00
|
|
|
@@ -3741,8 +3747,8 @@ public abstract class LivingEntity extends Entity {
|
2021-11-24 22:26:32 +00:00
|
|
|
}
|
2021-06-11 12:02:28 +00:00
|
|
|
|
2021-11-24 22:26:32 +00:00
|
|
|
this.stopUsingItem();
|
2021-06-11 12:02:28 +00:00
|
|
|
- // Paper start - if the replacement is anything but the default, update the client inventory
|
|
|
|
- if (this instanceof ServerPlayer && !com.google.common.base.Objects.equal(defaultReplacement, itemstack)) {
|
|
|
|
+ // Paper start
|
|
|
|
+ if (this instanceof ServerPlayer) {
|
|
|
|
((ServerPlayer) this).getBukkitEntity().updateInventory();
|
|
|
|
}
|
|
|
|
// Paper end
|