mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
46 lines
2.5 KiB
Diff
46 lines
2.5 KiB
Diff
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
|
|
index 63d1c5e8441eb5a32fc298ff2d2f3157cbd19557..ebfea3adbedd2695f645421019a276efbc73ee63 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3993,9 +3993,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
public void startUsingItem(InteractionHand hand) {
|
|
+ // Paper start - Prevent consuming the wrong itemstack
|
|
+ this.startUsingItem(hand, false);
|
|
+ }
|
|
+ public void startUsingItem(InteractionHand hand, boolean forceUpdate) {
|
|
+ // Paper end - Prevent consuming the wrong itemstack
|
|
ItemStack itemstack = this.getItemInHand(hand);
|
|
|
|
- if (!itemstack.isEmpty() && !this.isUsingItem()) {
|
|
+ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
|
this.useItem = itemstack;
|
|
this.useItemRemaining = itemstack.getUseDuration(this);
|
|
if (!this.level().isClientSide) {
|
|
@@ -4066,6 +4071,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
this.releaseUsingItem();
|
|
} else {
|
|
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
|
+ this.startUsingItem(this.getUsedItemHand(), true); // Paper - Prevent consuming the wrong itemstack
|
|
// CraftBukkit start - fire PlayerItemConsumeEvent
|
|
ItemStack itemstack;
|
|
PlayerItemConsumeEvent event = null; // Paper
|
|
@@ -4103,8 +4109,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
this.stopUsingItem();
|
|
- // 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
|