aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0204-LivingEntity-Active-Item-API.patch
diff options
context:
space:
mode:
authorTamion <[email protected]>2024-04-06 23:44:27 +0200
committerGitHub <[email protected]>2024-04-06 17:44:27 -0400
commit182e79bce1260a11558232e626867b3a3b319155 (patch)
treeb6d4d081824b21c4125341b04b6c87214c0183c3 /patches/server/0204-LivingEntity-Active-Item-API.patch
parentd8456ee65b75adfa854ca56c1badc160f27ddd9a (diff)
downloadPaper-182e79bce1260a11558232e626867b3a3b319155.tar.gz
Paper-182e79bce1260a11558232e626867b3a3b319155.zip
Add more item use API (#10304)
Diffstat (limited to 'patches/server/0204-LivingEntity-Active-Item-API.patch')
-rw-r--r--patches/server/0204-LivingEntity-Active-Item-API.patch23
1 files changed, 21 insertions, 2 deletions
diff --git a/patches/server/0204-LivingEntity-Active-Item-API.patch b/patches/server/0204-LivingEntity-Active-Item-API.patch
index e50ff8549c..a9e0dd9922 100644
--- a/patches/server/0204-LivingEntity-Active-Item-API.patch
+++ b/patches/server/0204-LivingEntity-Active-Item-API.patch
@@ -6,19 +6,38 @@ Subject: [PATCH] LivingEntity Active Item API
API relating to items being actively used by a LivingEntity
such as a bow or eating food.
+== AT ==
+public net/minecraft/world/entity/LivingEntity completeUsingItem()V
+public net/minecraft/server/level/ServerPlayer completeUsingItem()V
+
Co-authored-by: Jake Potrebic <[email protected]>
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index 1c6abeff5b541cdea914ac956f2ab1d2e1c5769f..de52fdc1c94f69de7c5c5099fc586fdeba60b6fa 100644
+index 1c6abeff5b541cdea914ac956f2ab1d2e1c5769f..0fe087cd6037b4dd694cc3c5c3eac8203ea6d519 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -866,4 +866,38 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -866,4 +866,53 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
getHandle().setShieldBlockingDelay(delay);
}
// Paper end
+
+ // Paper start - active item API
+ @Override
++ public void startUsingItem(org.bukkit.inventory.EquipmentSlot hand) {
++ Preconditions.checkArgument(hand != null, "hand must not be null");
++ switch (hand) {
++ case HAND -> getHandle().startUsingItem(InteractionHand.MAIN_HAND);
++ case OFF_HAND -> getHandle().startUsingItem(InteractionHand.OFF_HAND);
++ default -> throw new IllegalArgumentException("hand may only be HAND or OFF_HAND");
++ }
++ }
++
++ @Override
++ public void completeUsingActiveItem() {
++ getHandle().completeUsingItem();
++ }
++
++ @Override
+ public ItemStack getActiveItem() {
+ return this.getHandle().getUseItem().asBukkitMirror();
+ }