LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item Also aliased isHandsRaised for isChargingAttack in RangedEntity
This commit is contained in:
parent
7abf2eeeac
commit
98555e9b90
10 changed files with 195 additions and 44 deletions
|
@ -0,0 +1,50 @@
|
|||
From d76f522b7f164a56a7f9651170e439739ef6e015 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 29 Jun 2018 00:19:19 -0400
|
||||
Subject: [PATCH] LivingEntity Hand Raised/Item Use API
|
||||
|
||||
How long an entity has raised hands to charge an attack or use an item
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
index 5921c952..5ccb8ef3 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attributable;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
@@ -399,5 +400,27 @@ public interface LivingEntity extends Attributable, Entity, Damageable, Projecti
|
||||
* @param delay Delay in ticks
|
||||
*/
|
||||
void setShieldBlockingDelay(int delay);
|
||||
+
|
||||
+ /**
|
||||
+ * Get's the item being actively "used" or consumed.
|
||||
+ * @return The item. Will be null if no active item.
|
||||
+ */
|
||||
+ ItemStack getActiveItem();
|
||||
+
|
||||
+ /**
|
||||
+ * Get's remaining time a player needs to keep hands raised with an item to finish using it.
|
||||
+ * @return Remaining ticks to use the item
|
||||
+ */
|
||||
+ int getItemUseRemainingTime();
|
||||
+
|
||||
+ /**
|
||||
+ * Get how long the players hands have been raised (Charging Bow attack, using a potion, etc)
|
||||
+ */
|
||||
+ int getHandRaisedTime();
|
||||
+
|
||||
+ /**
|
||||
+ * Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food)
|
||||
+ */
|
||||
+ boolean isHandRaised();
|
||||
// Paper end
|
||||
}
|
||||
--
|
||||
2.18.0
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
From d22cc23fcedf807711836fcaedd9d7fd95f47f2d Mon Sep 17 00:00:00 2001
|
||||
From d2a1657e1c25dc241d143ee6486513c024a5695b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 26 Jun 2018 21:34:40 -0400
|
||||
Subject: [PATCH] RangedEntity API
|
||||
|
@ -8,10 +8,10 @@ and to perform an attack.
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
|
||||
new file mode 100644
|
||||
index 00000000..5153efab
|
||||
index 00000000..7b07f10c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
|
||||
@@ -0,0 +1,19 @@
|
||||
@@ -0,0 +1,28 @@
|
||||
+package com.destroystokyo.paper.entity;
|
||||
+
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
|
@ -26,10 +26,19 @@ index 00000000..5153efab
|
|||
+ void rangedAttack(LivingEntity target, float charge);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets that the Entity is "charging" up an attack, by raising its arms
|
||||
+ * @param charging Whether the entities arms are raised to charge attack
|
||||
+ * Sets that the Entity is "charging" up an attack, by raising its hands
|
||||
+ *
|
||||
+ * @param raiseHands Whether the entities hands are raised to charge attack
|
||||
+ */
|
||||
+ void setChargingAttack(boolean charging);
|
||||
+ void setChargingAttack(boolean raiseHands);
|
||||
+
|
||||
+ /**
|
||||
+ * Alias to {@link LivingEntity#isHandRaised()}, if the entity is charging an attack
|
||||
+ * @return If entities hands are raised
|
||||
+ */
|
||||
+ default boolean isChargingAttack() {
|
||||
+ return isHandRaised();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Illusioner.java b/src/main/java/org/bukkit/entity/Illusioner.java
|
||||
index 7c92c431..14e6c5ee 100644
|
Loading…
Add table
Add a link
Reference in a new issue