From 182e79bce1260a11558232e626867b3a3b319155 Mon Sep 17 00:00:00 2001 From: Tamion <70228790+notTamion@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:44:27 +0200 Subject: [PATCH] Add more item use API (#10304) --- .../0117-LivingEntity-Active-Item-API.patch | 33 +++++++++++++++++-- patches/api/0185-Entity-Jump-API.patch | 4 +-- ...yPickupItemAnimation-to-LivingEntity.patch | 4 +-- ...224-Add-LivingEntity-clearActiveItem.patch | 4 +-- ...9-Expose-LivingEntity-hurt-direction.patch | 4 +-- patches/api/0297-Missing-Entity-API.patch | 2 +- ...-swingHand-EquipmentSlot-convenience.patch | 4 +-- .../api/0380-Add-entity-knockback-API.patch | 4 +-- patches/api/0387-ItemStack-damage-API.patch | 4 +-- .../api/0400-Add-Entity-Body-Yaw-API.patch | 4 +-- .../0204-LivingEntity-Active-Item-API.patch | 23 +++++++++++-- patches/server/0328-Entity-Jump-API.patch | 4 +-- ...yPickupItemAnimation-to-LivingEntity.patch | 4 +-- ...456-Add-LivingEntity-clearActiveItem.patch | 4 +-- ...7-Expose-LivingEntity-hurt-direction.patch | 4 +-- .../server/0559-More-Enchantment-API.patch | 4 +-- .../0797-Add-entity-knockback-API.patch | 4 +-- .../server/0815-ItemStack-damage-API.patch | 4 +-- patches/server/0816-Friction-API.patch | 4 +-- .../server/0842-Add-Entity-Body-Yaw-API.patch | 4 +-- 20 files changed, 87 insertions(+), 39 deletions(-) diff --git a/patches/api/0117-LivingEntity-Active-Item-API.patch b/patches/api/0117-LivingEntity-Active-Item-API.patch index ce3d823f36..1324ec1fdc 100644 --- a/patches/api/0117-LivingEntity-Active-Item-API.patch +++ b/patches/api/0117-LivingEntity-Active-Item-API.patch @@ -23,7 +23,7 @@ index 2308fa3ca898bcb6c0ac2d4853f82a3398bf51f3..15115b1049bc5053796b84539acbf576 /** diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java -index 4a4a749449bc561a73e6747386c8ad51e623fc1e..c75315b921a1854fbbdbe8ecdfba7dacdaa155c1 100644 +index 4a4a749449bc561a73e6747386c8ad51e623fc1e..81a851580f81b2d6f6a2b2ebec38530f1d68530d 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -202,15 +202,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -56,13 +56,42 @@ index 4a4a749449bc561a73e6747386c8ad51e623fc1e..c75315b921a1854fbbdbe8ecdfba7dac public void setItemInUseTicks(int ticks); /** -@@ -850,4 +856,101 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource +@@ -850,4 +856,130 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ void setShieldBlockingDelay(int delay); // Paper end + + // Paper start - active item API + /** ++ * Starts using the item in the specified hand, making it the ++ * currently active item. When, for example, called on a skeleton, ++ * this will cause it to start drawing its bow. ++ *
++ * Only HAND or OFF_HAND may be used for the hand parameter. ++ *
++ * When used on a player, the client will stop using the item ++ * if right click is held down. ++ *
++ * This method does not make any guarantees about the effect of this method ++ * as such depends on the entity and its state. ++ * ++ * @param hand the hand that contains the item to be used ++ */ ++ @org.jetbrains.annotations.ApiStatus.Experimental ++ void startUsingItem(@NotNull org.bukkit.inventory.EquipmentSlot hand); ++ ++ /** ++ * Finishes using the currently active item. When, for example, a ++ * skeleton is drawing its bow, this will cause it to release and ++ * fire the arrow. ++ *
++ * This method does not make any guarantees about the effect of this method
++ * as such depends on the entity and its state.
++ */
++ @org.jetbrains.annotations.ApiStatus.Experimental
++ void completeUsingActiveItem();
++
++ /**
+ * Gets the item being actively "used" or consumed.
+ *
+ * @return the item
diff --git a/patches/api/0185-Entity-Jump-API.patch b/patches/api/0185-Entity-Jump-API.patch
index ea563c013a..cdbac20564 100644
--- a/patches/api/0185-Entity-Jump-API.patch
+++ b/patches/api/0185-Entity-Jump-API.patch
@@ -61,10 +61,10 @@ index 0000000000000000000000000000000000000000..a6306c957fcacdcbcc8037b4ee33a167
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 3e5b7dc8f72bd211a18ec6a930c4f02beea4205a..0a0e3fe33158f0424398c0abf50ea55825c452c5 100644
+index c2d6a2d45d733fff7cb6bf1d687bdff35d2be7f4..c7c242fb4ac106edad87032f0accd14d128a5b37 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1118,4 +1118,26 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1147,4 +1147,26 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
return this.getActiveItemHand();
}
// Paper end - active item API
diff --git a/patches/api/0209-Add-playPickupItemAnimation-to-LivingEntity.patch b/patches/api/0209-Add-playPickupItemAnimation-to-LivingEntity.patch
index 809eb90a68..bc76c0005c 100644
--- a/patches/api/0209-Add-playPickupItemAnimation-to-LivingEntity.patch
+++ b/patches/api/0209-Add-playPickupItemAnimation-to-LivingEntity.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add playPickupItemAnimation to LivingEntity
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 0a0e3fe33158f0424398c0abf50ea55825c452c5..d9dee0486c5f7c9a948a2c1a3497e2745d747965 100644
+index c7c242fb4ac106edad87032f0accd14d128a5b37..5d8433cbea6cfe6a7621d7ab110f7aa0ed120136 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1140,4 +1140,29 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1169,4 +1169,29 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
void setJumping(boolean jumping);
// Paper end - entity jump API
diff --git a/patches/api/0224-Add-LivingEntity-clearActiveItem.patch b/patches/api/0224-Add-LivingEntity-clearActiveItem.patch
index e3e004cb9d..463b79867d 100644
--- a/patches/api/0224-Add-LivingEntity-clearActiveItem.patch
+++ b/patches/api/0224-Add-LivingEntity-clearActiveItem.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add LivingEntity#clearActiveItem
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 898cbd4f690777ce855244331f95e624c6a1fbd4..66dfeb4490505a3eaed547dd86e6c68b85ba5568 100644
+index 5d8433cbea6cfe6a7621d7ab110f7aa0ed120136..f00ae13ee252c52963c7c8ce95cde984b8721f46 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1030,6 +1030,11 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1059,6 +1059,11 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
org.bukkit.inventory.@NotNull ItemStack getActiveItem();
diff --git a/patches/api/0229-Expose-LivingEntity-hurt-direction.patch b/patches/api/0229-Expose-LivingEntity-hurt-direction.patch
index a7a62153d3..0f5490de89 100644
--- a/patches/api/0229-Expose-LivingEntity-hurt-direction.patch
+++ b/patches/api/0229-Expose-LivingEntity-hurt-direction.patch
@@ -26,10 +26,10 @@ index 5ecfb98540c00da05b13bc5370debb89c52cc76f..083d5798ccc7f37c6df5e234c7ef2332
* Get the sleep ticks of the player. This value may be capped.
*
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 546ecf762d588b8a8239c832fbbe96b8714a07cb..8d2a74e17e4b7089ff91d263b669e8623d7e688a 100644
+index f00ae13ee252c52963c7c8ce95cde984b8721f46..9c8202d672e293c963218a7f3b0d51aa4e7dec5a 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1170,4 +1170,22 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1199,4 +1199,22 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
void playPickupItemAnimation(@NotNull Item item, int quantity);
// Paper end - pickup animation API
diff --git a/patches/api/0297-Missing-Entity-API.patch b/patches/api/0297-Missing-Entity-API.patch
index ee44607e5c..be2838d08e 100644
--- a/patches/api/0297-Missing-Entity-API.patch
+++ b/patches/api/0297-Missing-Entity-API.patch
@@ -661,7 +661,7 @@ index a253ac2b60b038177e6c4f20d8367be36f10b1bd..2036e7b464f631054abb94333a8674d3
+
// Paper start - active item API
/**
- * Gets the item being actively "used" or consumed.
+ * Starts using the item in the specified hand, making it the
diff --git a/src/main/java/org/bukkit/entity/Llama.java b/src/main/java/org/bukkit/entity/Llama.java
index d23226ccb0f6c25028f000ce31346cd0a8898e6a..bc84b892cae5fe7019a3ad481e9da79956efa1fe 100644
--- a/src/main/java/org/bukkit/entity/Llama.java
diff --git a/patches/api/0379-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch b/patches/api/0379-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
index e870d6f074..75708a14a8 100644
--- a/patches/api/0379-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
+++ b/patches/api/0379-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add LivingEntity#swingHand(EquipmentSlot) convenience method
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 7ed163813bb13ea6e1b60a94f4ef98b3b55f163c..ec3e597a9e683e5966ef4fff3300c30bde1dd49d 100644
+index 5500f5273624b133b48327fe74b0b2e2708d76c4..bdd34708b2e75aaa8a3365c0d7284d85e7cb61e5 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1300,4 +1300,24 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1329,4 +1329,24 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@Deprecated
void setHurtDirection(float hurtDirection);
// Paper end - hurt direction API
diff --git a/patches/api/0380-Add-entity-knockback-API.patch b/patches/api/0380-Add-entity-knockback-API.patch
index 4dbce197ca..024e3244b0 100644
--- a/patches/api/0380-Add-entity-knockback-API.patch
+++ b/patches/api/0380-Add-entity-knockback-API.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add entity knockback API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index ec3e597a9e683e5966ef4fff3300c30bde1dd49d..b5d882622d9b350b81b6c61348515cbc5aa65777 100644
+index bdd34708b2e75aaa8a3365c0d7284d85e7cb61e5..3943b5cb1306fb1eb830e56cea696fdc587c09f4 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1320,4 +1320,18 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1349,4 +1349,18 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
}
}
// Paper end - swing hand API
diff --git a/patches/api/0387-ItemStack-damage-API.patch b/patches/api/0387-ItemStack-damage-API.patch
index a07dfddbc3..2bcc0d05b3 100644
--- a/patches/api/0387-ItemStack-damage-API.patch
+++ b/patches/api/0387-ItemStack-damage-API.patch
@@ -8,10 +8,10 @@ to simulate damage done to an itemstack and all
the logic associated with damaging them
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index b5d882622d9b350b81b6c61348515cbc5aa65777..6807354bf157060cbddb395dd6220040b84e7c8d 100644
+index 3943b5cb1306fb1eb830e56cea696fdc587c09f4..a8b442cf03887ebe212a298d35cea5f6383ccfab 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1334,4 +1334,53 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1363,4 +1363,53 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
void knockback(double strength, double directionX, double directionZ);
// Paper end - knockback API
diff --git a/patches/api/0400-Add-Entity-Body-Yaw-API.patch b/patches/api/0400-Add-Entity-Body-Yaw-API.patch
index 2236bdf2cf..6b8119d161 100644
--- a/patches/api/0400-Add-Entity-Body-Yaw-API.patch
+++ b/patches/api/0400-Add-Entity-Body-Yaw-API.patch
@@ -53,10 +53,10 @@ index 2d6f7b2bf4cb23ef43a4dcbab2ecd2a7c7c2809c..0be4107270fb7fdba5c7d0e6f3964d33
// Paper start - Collision API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 92c33fc9680159ab4e901cfba08092d868845c63..e3ff310a83b320c26de63e9239db63de271321c2 100644
+index 30222c65bcc78ff3fe5c0937c64c6fe7b0b2fe36..2e6a6c9e8e150f940842f8f134b18987412e4766 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1383,4 +1383,22 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1412,4 +1412,22 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
void damageItemStack(org.bukkit.inventory.@NotNull EquipmentSlot slot, int amount);
// Paper end - ItemStack damage API
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