mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-28 10:53:51 -07:00
Add projectile hit simulation API (#8816)
This adds API to force a projectile to hit a provided entity. Example usage could be if you have a player disguised as another entity, you could simulate an arrow colliding with the (fake) entity hitbox.
This commit is contained in:
@@ -225,6 +225,41 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @param beenShot has been in shot into the world
|
||||
+ */
|
||||
+ void setHasBeenShot(boolean beenShot);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether this projectile can hit an entity.
|
||||
+ * <p>
|
||||
+ * This method returns true under the following conditions:
|
||||
+ * <p>
|
||||
+ * - The shooter can see the entity ({@link Player#canSee(Entity)}) <p>
|
||||
+ * - The entity is alive and not a spectator <p>
|
||||
+ * - The projectile has left the hitbox of the shooter ({@link #hasLeftShooter()})<p>
|
||||
+ * - If this is an arrow with piercing, it has not pierced the entity already
|
||||
+ *
|
||||
+ * @param entity the entity to check if this projectile can hit
|
||||
+ * @return true if this projectile can damage the entity, false otherwise
|
||||
+ */
|
||||
+ boolean canHitEntity(@org.jetbrains.annotations.NotNull Entity entity);
|
||||
+
|
||||
+ /**
|
||||
+ * Makes this projectile hit a specific entity.
|
||||
+ * This uses the current position of the projectile for the hit point.
|
||||
+ * Using this method will result in {@link org.bukkit.event.entity.ProjectileHitEvent} being called.
|
||||
+ * @param entity the entity to hit
|
||||
+ * @see #hitEntity(Entity, org.bukkit.util.Vector)
|
||||
+ * @see #canHitEntity(Entity)
|
||||
+ */
|
||||
+ void hitEntity(@org.jetbrains.annotations.NotNull Entity entity);
|
||||
+
|
||||
+ /**
|
||||
+ * Makes this projectile hit a specific entity from a specific point.
|
||||
+ * Using this method will result in {@link org.bukkit.event.entity.ProjectileHitEvent} being called.
|
||||
+ * @param entity the entity to hit
|
||||
+ * @param vector the direction to hit from
|
||||
+ * @see #hitEntity(Entity)
|
||||
+ * @see #canHitEntity(Entity)
|
||||
+ */
|
||||
+ void hitEntity(@org.jetbrains.annotations.NotNull Entity entity, @org.jetbrains.annotations.NotNull org.bukkit.util.Vector vector);
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/ShulkerBullet.java b/src/main/java/org/bukkit/entity/ShulkerBullet.java
|
||||
|
Reference in New Issue
Block a user