mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 10:49:40 +01:00
4104545b11
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
53 lines
2.7 KiB
Diff
53 lines
2.7 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 32507c52d90393101ef5140de0d82518e5cbfbcc..53951f2c4dc77e9723d0a6314781d9ee0aa8ce54 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3548,15 +3548,18 @@ public abstract class LivingEntity extends Entity {
|
|
this.entityData.set(LivingEntity.DATA_LIVING_ENTITY_FLAGS, (byte) j);
|
|
}
|
|
|
|
- public void startUsingItem(InteractionHand hand) {
|
|
- ItemStack itemstack = this.getItemInHand(hand);
|
|
+ // Paper start -- OBFHELPER and forwarder to method with forceUpdate parameter
|
|
+ public void startUsingItem(InteractionHand hand) { this.updateActiveItem(hand, false); }
|
|
+ public void updateActiveItem(InteractionHand enumhand, boolean forceUpdate) {
|
|
+ // Paper end
|
|
+ ItemStack itemstack = this.getItemInHand(enumhand);
|
|
|
|
- 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) {
|
|
this.setLivingEntityFlag(1, true);
|
|
- this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
|
+ this.setLivingEntityFlag(2, enumhand == InteractionHand.OFF_HAND);
|
|
}
|
|
|
|
}
|
|
@@ -3629,6 +3632,7 @@ public abstract class LivingEntity extends Entity {
|
|
this.releaseUsingItem();
|
|
} else {
|
|
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
|
+ this.updateActiveItem(this.getUsedItemHand(), true); // Paper
|
|
this.triggerItemUseEffects(this.useItem, 16);
|
|
// CraftBukkit start - fire PlayerItemConsumeEvent
|
|
ItemStack itemstack;
|
|
@@ -3663,8 +3667,8 @@ public abstract class LivingEntity extends Entity {
|
|
}
|
|
|
|
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
|