aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOwen <[email protected]>2023-11-11 16:04:34 -0500
committerGitHub <[email protected]>2023-11-11 16:04:34 -0500
commitdd47ec6fe283c27d008f8ad1e69dc144f3732989 (patch)
tree98e37ade37009e3bc901c1aab5bab885a9a87e82
parentd8847bc1f3a77be9edf69a6b5b71fbfd8292eb57 (diff)
downloadPaper-dd47ec6fe283c27d008f8ad1e69dc144f3732989.tar.gz
Paper-dd47ec6fe283c27d008f8ad1e69dc144f3732989.zip
Add Entity Movement Direction API (#7085)
This allows you to get player movement when riding vehicles, etc.
-rw-r--r--patches/api/0299-Missing-Entity-API.patch62
-rw-r--r--patches/api/0384-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch4
-rw-r--r--patches/api/0385-Add-entity-knockback-API.patch4
-rw-r--r--patches/api/0392-ItemStack-damage-API.patch4
-rw-r--r--patches/api/0406-Add-Entity-Body-Yaw-API.patch4
-rw-r--r--patches/server/0624-Missing-Entity-API.patch29
-rw-r--r--patches/server/0864-Add-entity-knockback-API.patch4
-rw-r--r--patches/server/0884-ItemStack-damage-API.patch4
-rw-r--r--patches/server/0885-Friction-API.patch4
-rw-r--r--patches/server/0912-Add-Entity-Body-Yaw-API.patch6
10 files changed, 107 insertions, 18 deletions
diff --git a/patches/api/0299-Missing-Entity-API.patch b/patches/api/0299-Missing-Entity-API.patch
index 223734aaeb..b3de1351da 100644
--- a/patches/api/0299-Missing-Entity-API.patch
+++ b/patches/api/0299-Missing-Entity-API.patch
@@ -512,6 +512,68 @@ index 6b3c9bef9a8a34ddc6ff42cf358541a2665bf5e3..9c618a27d590f186f29c5d9094fc565e
+ void setExplosionPower(int explosionPower);
+ // Paper end
}
+diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
+index b665b99ca6de3a35c3296a500db1527a8513a711..56a59bfee3138bfb93cbb85c5d8b86e3aa977b05 100644
+--- a/src/main/java/org/bukkit/entity/LivingEntity.java
++++ b/src/main/java/org/bukkit/entity/LivingEntity.java
+@@ -971,6 +971,57 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+ void clearActiveItem();
+ // Paper end
+
++ // Paper start
++ /**
++ * Retrieves the sideways movement direction of the entity.
++ * <p>
++ * The returned value ranges from -1 to 1, where:
++ * - Positive 1 represents movement to the left.
++ * - Negative 1 represents movement to the right.
++ * <p>
++ * Please note that for entities of type {@link Player}, this value is updated only when riding another entity.
++ * <p>
++ * This method specifically provides information about the entity's sideways movement, whereas {@link #getVelocity()} returns
++ * a vector representing the entity's overall current momentum.
++ *
++ * @return Sideways movement direction, ranging from -1 (right) to 1 (left).
++ */
++ float getSidewaysMovement();
++
++ /**
++ * Retrieves the upwards movement direction of the entity.
++ * <p>
++ * The returned value ranges from -1 to 1, where:
++ * - Positive 1 represents upward movement.
++ * - Negative 1 represents downward movement.
++ * <p>
++ * Please note that for entities of type {@link Player}, this value is never updated.
++ * <p>
++ * This method specifically provides information about the entity's vertical movement,
++ * whereas {@link #getVelocity()} returns a vector representing the entity's overall
++ * current momentum.
++ *
++ * @return Upwards movement direction, ranging from -1 (downward) to 1 (upward).
++ */
++ float getUpwardsMovement();
++
++ /**
++ * Retrieves the forwards movement direction of the entity.
++ * <p>
++ * The returned value ranges from -1 to 1, where:
++ * - Positive 1 represents movement forwards.
++ * - Negative 1 represents movement backwards.
++ * <p>
++ * Please note that for entities of type {@link Player}, this value is updated only when riding another entity.
++ * <p>
++ * This method specifically provides information about the entity's forward and backward movement,
++ * whereas {@link #getVelocity()} returns a vector representing the entity's overall current momentum.
++ *
++ * @return Forwards movement direction, ranging from -1 (backward) to 1 (forward).
++ */
++ float getForwardsMovement();
++ // Paper end
++
+ /**
+ * 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
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/0384-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch b/patches/api/0384-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
index 8ba283e9b1..86203fb4c3 100644
--- a/patches/api/0384-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
+++ b/patches/api/0384-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 26f12a6e4b2aff8ec052342939435f1ae4c02e2d..930c328880708cea182ccb031d31305e7d1c529b 100644
+index 4c1c87c07735eecc2a1eaef2da77d3fe636adefb..ac87b7a28553425dc45af11ac6f5089f5197ce20 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1089,5 +1089,23 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1140,5 +1140,23 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
@Deprecated
void setHurtDirection(float hurtDirection);
diff --git a/patches/api/0385-Add-entity-knockback-API.patch b/patches/api/0385-Add-entity-knockback-API.patch
index 3852612f24..263f278b1b 100644
--- a/patches/api/0385-Add-entity-knockback-API.patch
+++ b/patches/api/0385-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 930c328880708cea182ccb031d31305e7d1c529b..14854e1325d61d0112cc928c8a5a92a8a45249d3 100644
+index ac87b7a28553425dc45af11ac6f5089f5197ce20..eced9bfd35aa822b1ba141ea60e603bca5a137f8 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1107,5 +1107,17 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1158,5 +1158,17 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
this.swingOffHand();
}
}
diff --git a/patches/api/0392-ItemStack-damage-API.patch b/patches/api/0392-ItemStack-damage-API.patch
index ffdcd4b728..3617adca85 100644
--- a/patches/api/0392-ItemStack-damage-API.patch
+++ b/patches/api/0392-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 14854e1325d61d0112cc928c8a5a92a8a45249d3..7889ec8e0954c98e9611a20811b1ddc5bcd93b7f 100644
+index eced9bfd35aa822b1ba141ea60e603bca5a137f8..088f42f294784e14f4478255193f4fd40cba4e53 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1119,5 +1119,52 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1170,5 +1170,52 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param directionZ The relative z position of the knockback source direction
*/
void knockback(double strength, double directionX, double directionZ);
diff --git a/patches/api/0406-Add-Entity-Body-Yaw-API.patch b/patches/api/0406-Add-Entity-Body-Yaw-API.patch
index d797fb4127..de7ca1a8b0 100644
--- a/patches/api/0406-Add-Entity-Body-Yaw-API.patch
+++ b/patches/api/0406-Add-Entity-Body-Yaw-API.patch
@@ -53,10 +53,10 @@ index 9c7eba228dc1c244d49cb5139e1710804b887d6a..db4231b6e77a7cf9fe430e5207c1fc9c
// 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 f4c5ec3f7e5c29b1799eef6c4f76617e9f23c0d7..03490d35a24c056ed148e45eea27d1786a58c8fc 100644
+index 4682df5d422c24c2d145bd28bc3d0fa8b1cd6ce8..bd5e53372ce860924f5403dca6b0c45878a9e4d2 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
-@@ -1166,5 +1166,21 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+@@ -1217,5 +1217,21 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param amount the amount of damage to do
*/
void damageItemStack(org.bukkit.inventory.@NotNull EquipmentSlot slot, int amount);
diff --git a/patches/server/0624-Missing-Entity-API.patch b/patches/server/0624-Missing-Entity-API.patch
index 388ac52bba..66c2117073 100644
--- a/patches/server/0624-Missing-Entity-API.patch
+++ b/patches/server/0624-Missing-Entity-API.patch
@@ -655,7 +655,7 @@ index fc0f0e841dc974d080e1abb9bbafb5165801131f..d657fd2c507a5b215aeab0a5f3e9c2ee
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
-index d270d9ca6f1dea0ad4e6a919b58b845eebf3dc87..0a29960fca388dd95710bdba19f37fde6be52073 100644
+index b23338739b7badbb4fae1428a02a67625133b6e0..af7fec4029a5b6cd11a401d31b327c32ba79667b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -232,10 +232,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -746,6 +746,33 @@ index 2cec61a1bb050c1ef81c5fc3d0afafe9ff29d459..97fa4e1e70203194bd939618b2fad926
+ }
+ // Paper end
}
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+index 7745c32b312a7f91e6919ccfb0871d765d0e06f3..a951d4f0754a4be03ae4efa07e60726d733b03e4 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+@@ -884,6 +884,22 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+ this.getHandle().persistentInvisibility = invisible;
+ this.getHandle().setSharedFlag(5, invisible);
+ }
++ // Paper start
++ @Override
++ public float getSidewaysMovement() {
++ return this.getHandle().xxa;
++ }
++
++ @Override
++ public float getForwardsMovement() {
++ return this.getHandle().zza;
++ }
++
++ @Override
++ public float getUpwardsMovement() {
++ return this.getHandle().yya;
++ }
++ // Paper end
+
+ // Paper start
+ @Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
index 9986ac517e11b076a29a8c8e3f480ec286fa5825..0ad16ee7b33582d214dab41eeee378d52c8e38ed 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
diff --git a/patches/server/0864-Add-entity-knockback-API.patch b/patches/server/0864-Add-entity-knockback-API.patch
index 2fab1f9c44..484fa604b3 100644
--- a/patches/server/0864-Add-entity-knockback-API.patch
+++ b/patches/server/0864-Add-entity-knockback-API.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add entity knockback API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index b31356c042b5262ccb47fe1ec56bed0791e84262..e76dfca102ef9b497fc28c9c221ac33fe3c31c10 100644
+index b6723468156cf500e6ae3def456e1d82589ab4ee..8924dc5c5291fdd8557eca95a5ae7d4a204cd3e7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -1016,5 +1016,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -1032,5 +1032,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
throw new IllegalArgumentException(entityCategory + " is an unrecognized entity category");
}
diff --git a/patches/server/0884-ItemStack-damage-API.patch b/patches/server/0884-ItemStack-damage-API.patch
index 83ab1c3ff4..76fc39cc9b 100644
--- a/patches/server/0884-ItemStack-damage-API.patch
+++ b/patches/server/0884-ItemStack-damage-API.patch
@@ -11,10 +11,10 @@ the logic associated with damaging them
public net.minecraft.world.entity.LivingEntity entityEventForEquipmentBreak(Lnet/minecraft/world/entity/EquipmentSlot;)B
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index e76dfca102ef9b497fc28c9c221ac33fe3c31c10..87a5260a94dc3388bad2803c64ecf15a8063ba9d 100644
+index 8924dc5c5291fdd8557eca95a5ae7d4a204cd3e7..c50a98ebfec5d8d708d5a42c77a45a101a3eac1b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -1017,6 +1017,53 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -1033,6 +1033,53 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
throw new IllegalArgumentException(entityCategory + " is an unrecognized entity category");
}
diff --git a/patches/server/0885-Friction-API.patch b/patches/server/0885-Friction-API.patch
index 7d174e0e49..439a4b7681 100644
--- a/patches/server/0885-Friction-API.patch
+++ b/patches/server/0885-Friction-API.patch
@@ -132,10 +132,10 @@ index 073643d7f83b974509cf2dd4ea41e3dd9cb90a0d..f444e843535ec68ede0f05e7e7ef182c
public int getHealth() {
return this.getHandle().health;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index 87a5260a94dc3388bad2803c64ecf15a8063ba9d..962f4653757f870aff1bea8e98bcafabe639dc86 100644
+index c50a98ebfec5d8d708d5a42c77a45a101a3eac1b..dd11d52ae56b4dabdc4ff461186e91c316be3488 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -1064,6 +1064,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -1080,6 +1080,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
});
}
diff --git a/patches/server/0912-Add-Entity-Body-Yaw-API.patch b/patches/server/0912-Add-Entity-Body-Yaw-API.patch
index e9df66e906..87bac311e4 100644
--- a/patches/server/0912-Add-Entity-Body-Yaw-API.patch
+++ b/patches/server/0912-Add-Entity-Body-Yaw-API.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Add Entity Body Yaw API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
-index 841a007f24c3d9be2e8b6a9d03ba1694544996fd..9bd6d3be29b2f50bc91fa02382e34213f51337f5 100644
+index a42be7d446e7066b5451f58834901672c293a34b..f02b6803e1fe9f3a18e47cd7b5e6776eb6fe183a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1450,6 +1450,31 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -41,10 +41,10 @@ index 841a007f24c3d9be2e8b6a9d03ba1694544996fd..9bd6d3be29b2f50bc91fa02382e34213
// Paper Start - Collision API
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index 962f4653757f870aff1bea8e98bcafabe639dc86..6a4639a4584f3497661f8870d5722e300638e52a 100644
+index dd11d52ae56b4dabdc4ff461186e91c316be3488..97e77f7e027471ee0074d0103df06baa9a90d1d9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -1056,6 +1056,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -1072,6 +1072,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
this.damageItemStack0(this.getHandle().getItemBySlot(nmsSlot), amount, nmsSlot);
}