Add getHandRaised to LivingEntity (#5752)

This commit is contained in:
Jake Potrebic 2021-05-29 18:51:13 -07:00 committed by GitHub
parent 9072c349a0
commit 86ffde0384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 27 deletions

View File

@ -6,7 +6,7 @@ Subject: [PATCH] LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item 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 diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 879dec59f202ee95043bd7317a672cd59ab3bbbe..8b89c0701dd557bcab0c05c1593354ee704b9fe4 100644 index 879dec59f202ee95043bd7317a672cd59ab3bbbe..4f62a49e7b0538f0ce9cecd2c1b645f40ce17b3d 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -12,6 +12,7 @@ import org.bukkit.attribute.Attributable; @@ -12,6 +12,7 @@ import org.bukkit.attribute.Attributable;
@ -17,7 +17,7 @@ index 879dec59f202ee95043bd7317a672cd59ab3bbbe..8b89c0701dd557bcab0c05c1593354ee
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
@@ -642,5 +643,32 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -642,5 +643,42 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param delay Delay in ticks * @param delay Delay in ticks
*/ */
void setShieldBlockingDelay(int delay); void setShieldBlockingDelay(int delay);
@ -48,5 +48,15 @@ index 879dec59f202ee95043bd7317a672cd59ab3bbbe..8b89c0701dd557bcab0c05c1593354ee
+ * @return Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food) + * @return Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food)
+ */ + */
+ boolean isHandRaised(); + boolean isHandRaised();
+
+ /**
+ * Gets the hand raised by this living entity. Will be either
+ * {@link org.bukkit.inventory.EquipmentSlot#HAND} or
+ * {@link org.bukkit.inventory.EquipmentSlot#OFF_HAND}.
+ *
+ * @return the hand raised
+ */
+ @NotNull
+ org.bukkit.inventory.EquipmentSlot getHandRaised();
// Paper end // Paper end
} }

View File

@ -57,13 +57,13 @@ index 0000000000000000000000000000000000000000..f0067c2e953d18e1a33536980071ba3f
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 561db9d594633e3909fd6d69dad1dc2976928d58..a2f5639904881d9bef7d1550dbed810e4b17c8de 100644 index ac6921093457cee6d01fd27690c8bb6034b4af53..a46379b3a777a9071b0b13357bbd6af40dbfb569 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -785,5 +785,25 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -795,5 +795,25 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @return Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food)
*/ */
boolean isHandRaised(); @NotNull
org.bukkit.inventory.EquipmentSlot getHandRaised();
+ +
+ /** + /**
+ * Get entity jump state. + * Get entity jump state.

View File

@ -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 diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index a2f5639904881d9bef7d1550dbed810e4b17c8de..9bf525b795ff1d88d2596b1f2bc787ce0df047bb 100644 index a46379b3a777a9071b0b13357bbd6af40dbfb569..c4fe44dce3bcb3502b26af7c76ec6b36c2a2bebe 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -805,5 +805,28 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -815,5 +815,28 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param jumping entity jump state * @param jumping entity jump state
*/ */
void setJumping(boolean jumping); void setJumping(boolean jumping);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Expose LivingEntity hurt direction
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index e535750d01a6c1bf4b1fe94df518166213da9b08..9f0645dc5f76ee9ef73d88f768025429e5a9edf7 100644 index b96b5f4f2fc754298e2223b2f449a0755469278c..b6de41e3e718fa5d1b82c6f68b153e60a81265e7 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -835,5 +835,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -845,5 +845,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param quantity quantity of item * @param quantity quantity of item
*/ */
void playPickupItemAnimation(@NotNull Item item, int quantity); void playPickupItemAnimation(@NotNull Item item, int quantity);

View File

@ -6,7 +6,7 @@ Subject: [PATCH] LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item How long an entity has raised hands to charge an attack or use an item
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 4798eac1498ebeecf0476a61a093d3871c00d5a5..2b10ae84ee8e9f63382d732e8c051fc47f0c5d9f 100644 index daf09f3f0e6be57f540641d70e9c944de7fe6622..a530f13526ef1ee947adb22e24d5c9afb705a01d 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java --- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java +++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -212,7 +212,7 @@ public abstract class EntityLiving extends Entity { @@ -212,7 +212,7 @@ public abstract class EntityLiving extends Entity {
@ -32,10 +32,10 @@ index 4798eac1498ebeecf0476a61a093d3871c00d5a5..2b10ae84ee8e9f63382d732e8c051fc4
return this.isHandRaised() ? this.activeItem.k() - this.dZ() : 0; return this.isHandRaised() ? this.activeItem.k() - this.dZ() : 0;
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 2d1c54eed8fa6885837d63014ff1f4b33dd35bd7..bd24b9865f37c34ffd63cd411ddc84abe5ab30d0 100644 index 2d1c54eed8fa6885837d63014ff1f4b33dd35bd7..a0b006f24829ff9f5754293fbe389d19a14dc001 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -721,5 +721,25 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -721,5 +721,30 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setShieldBlockingDelay(int delay) { public void setShieldBlockingDelay(int delay) {
getHandle().setShieldBlockingDelay(delay); getHandle().setShieldBlockingDelay(delay);
} }
@ -58,6 +58,11 @@ index 2d1c54eed8fa6885837d63014ff1f4b33dd35bd7..bd24b9865f37c34ffd63cd411ddc84ab
+ @Override + @Override
+ public boolean isHandRaised() { + public boolean isHandRaised() {
+ return getHandle().isHandRaised(); + return getHandle().isHandRaised();
+ }
+
+ @Override
+ public org.bukkit.inventory.EquipmentSlot getHandRaised() {
+ return getHandle().getRaisedHand() == net.minecraft.world.EnumHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND;
+ } + }
// Paper end // Paper end
} }

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Entity Jump API
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 02d3b792cc9769b5daa6fcac57f5cda320a2a29e..86c6a8fd4511dfe426cc1651d289f38b467d3029 100644 index ffb4072f46456b3a2b2daa55947787cee774d26d..571e6bced3cfaacbd40378e67b01cdfda550feb7 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java --- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java +++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -2876,8 +2876,10 @@ public abstract class EntityLiving extends Entity { @@ -2876,8 +2876,10 @@ public abstract class EntityLiving extends Entity {
@ -34,12 +34,12 @@ index f755607872920caae1410d38c431c16b5238c00f..711b322007a0973ff0aebf3c25efbae8
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index ff586b8366a6298f1906551b068e8abb26fcabc7..b18292ef2e00b4ef8a0b2da5f63a596dbd04b1fd 100644 index db5d9a8107babd42200f911d2b8ebdc15b4d7c8b..468dca6d8c2ec77c3c77c93d04fb9dc329b1befa 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -799,5 +799,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -804,5 +804,19 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public boolean isHandRaised() { public org.bukkit.inventory.EquipmentSlot getHandRaised() {
return getHandle().isHandRaised(); return getHandle().getRaisedHand() == net.minecraft.world.EnumHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND;
} }
+ +
+ @Override + @Override
@ -55,6 +55,5 @@ index ff586b8366a6298f1906551b068e8abb26fcabc7..b18292ef2e00b4ef8a0b2da5f63a596d
+ ((EntityInsentient) getHandle()).getControllerJump().jump(); + ((EntityInsentient) getHandle()).getControllerJump().jump();
+ } + }
+ } + }
+
// Paper end // Paper end
} }

View File

@ -5,13 +5,14 @@ Subject: [PATCH] Add playPickupItemAnimation to LivingEntity
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 5563e7c1ecc9e607ba0be21ae16a544b24d6f030..090e0931df410526cb7b0aab196a01f57ffbb285 100644 index fdf4d258dd3e81cf4317ad66334c323be2d88fb2..de12a050739b8d12d268cc9ca496259ea2c46569 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -814,5 +814,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -818,5 +818,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
((EntityInsentient) getHandle()).getControllerJump().jump();
} }
} }
+
+ @Override + @Override
+ public void playPickupItemAnimation(org.bukkit.entity.Item item, int quantity) { + public void playPickupItemAnimation(org.bukkit.entity.Item item, int quantity) {
+ getHandle().receive(((CraftItem) item).getHandle(), quantity); + getHandle().receive(((CraftItem) item).getHandle(), quantity);

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Expose LivingEntity hurt direction
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 358bb6244b7b9e785c7dcc3725ee00cfbb917cec..deffd82dfca1d2eea6e5b8db9228015bf35ad0a3 100644 index b56c801c02e4f206b72db7dd74672727104bf246..b1adb0ddfeb94de6f92f40a7e9e586e00455160d 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java --- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java +++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -163,7 +163,7 @@ public abstract class EntityLiving extends Entity { @@ -163,7 +163,7 @@ public abstract class EntityLiving extends Entity {
@ -18,10 +18,10 @@ index 358bb6244b7b9e785c7dcc3725ee00cfbb917cec..deffd82dfca1d2eea6e5b8db9228015b
public float ar; public float ar;
public float as; public float as;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 5d2ed8a0cf8351df1c8b2946f8a614fe13c34673..e574e2453c7bc848168ff24372d6772bd423b672 100644 index 3bee6903a591bbfe312c6d7e276d7cef3dafc852..278a1c886f15b75e62bfe4c872fc779eda83c988 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -825,5 +825,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -830,5 +830,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void playPickupItemAnimation(org.bukkit.entity.Item item, int quantity) { public void playPickupItemAnimation(org.bukkit.entity.Item item, int quantity) {
getHandle().receive(((CraftItem) item).getHandle(), quantity); getHandle().receive(((CraftItem) item).getHandle(), quantity);
} }

View File

@ -111,10 +111,10 @@ index 5a14430f63894bbe9daa42900cf5a6519bea4f45..3b83852249e56609074ef1e8cdad6416
public net.minecraft.world.item.enchantment.Enchantment getHandle() { public net.minecraft.world.item.enchantment.Enchantment getHandle() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 3d497f69f89455b88fba423de8effb3db83e7af4..4545bac9309f5a3aad617f48f7808d8ae829602d 100644 index 9865eee8ec5e43f291968bfb2c4473260e5baf7c..32428b1260bbc4bae67ec74969c67f71272de418 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -842,5 +842,21 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -847,5 +847,21 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setHurtDirection(float hurtDirection) { public void setHurtDirection(float hurtDirection) {
getHandle().setHurtDirection(hurtDirection); getHandle().setHurtDirection(hurtDirection);
} }