geforkt von Mirrors/Paper
Add Entity Movement Direction API (#7085)
This allows you to get player movement when riding vehicles, etc.
Dieser Commit ist enthalten in:
Ursprung
aa933b773e
Commit
5cca94a05e
@ -512,6 +512,68 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Llama.java
|
||||
|
@ -746,6 +746,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren