3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/server/0305-Prevent-consuming-the-wrong-itemstack.patch

46 Zeilen
2.5 KiB
Diff

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
index f619171b3e436d7263d5229f7f9131954a0941f8..40ad459823268af0e57a348d241ac19bb576683a 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
@@ -3730,9 +3730,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) {
+ // 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) {
+ // 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()) {
+ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
2021-06-11 14:02:28 +02:00
this.useItem = itemstack;
this.useItemRemaining = itemstack.getUseDuration();
if (!this.level().isClientSide) {
@@ -3812,6 +3817,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
this.triggerItemUseEffects(this.useItem, 16);
// CraftBukkit start - fire PlayerItemConsumeEvent
ItemStack itemstack;
@@ -3846,8 +3852,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
2021-06-11 14:02:28 +02:00
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