2021-06-11 14:02:28 +02: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
|
2024-07-06 21:19:14 +02:00
|
|
|
index e047911c7faa3cdcd3df8899857fcadf3eec3d89..f13fb8d408e02e3c561e8f2b9c823c13033b4f94 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-07-06 21:19:14 +02:00
|
|
|
@@ -3855,9 +3855,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2021-11-24 06:44:21 +01:00
|
|
|
public void startUsingItem(InteractionHand hand) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ // Paper start - Prevent consuming the wrong itemstack
|
2021-11-24 06:44:21 +01:00
|
|
|
+ this.startUsingItem(hand, false);
|
|
|
|
+ }
|
|
|
|
+ public void startUsingItem(InteractionHand hand, boolean forceUpdate) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ // Paper end - Prevent consuming the wrong itemstack
|
2021-11-24 06:44:21 +01:00
|
|
|
ItemStack itemstack = this.getItemInHand(hand);
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
- if (!itemstack.isEmpty() && !this.isUsingItem()) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
2021-06-11 14:02:28 +02:00
|
|
|
this.useItem = itemstack;
|
2024-06-13 22:14:13 +02:00
|
|
|
this.useItemRemaining = itemstack.getUseDuration(this);
|
2023-06-07 23:14:56 +02:00
|
|
|
if (!this.level().isClientSide) {
|
2024-07-06 21:19:14 +02:00
|
|
|
@@ -3942,6 +3947,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-11-24 23:26:32 +01:00
|
|
|
this.releaseUsingItem();
|
|
|
|
} else {
|
|
|
|
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
2024-01-21 12:53:04 +01:00
|
|
|
+ this.startUsingItem(this.getUsedItemHand(), true); // Paper - Prevent consuming the wrong itemstack
|
2021-11-24 23:26:32 +01:00
|
|
|
this.triggerItemUseEffects(this.useItem, 16);
|
|
|
|
// CraftBukkit start - fire PlayerItemConsumeEvent
|
|
|
|
ItemStack itemstack;
|
2024-07-06 21:19:14 +02:00
|
|
|
@@ -3976,8 +3982,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-11-24 23:26:32 +01:00
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2021-11-24 23:26:32 +01:00
|
|
|
this.stopUsingItem();
|
2023-06-07 23:14:56 +02: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
|