mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 12:42:05 -07:00
Add more item use API (#10304)
This commit is contained in:
@@ -6,6 +6,10 @@ 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 <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -19,6 +23,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ // 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();
|
||||
+ }
|
||||
|
Reference in New Issue
Block a user