Paper/patches/api/0346-More-Projectile-API.patch

450 lines
15 KiB
Diff
Raw Normal View History

2022-03-11 17:37:08 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Wed, 26 May 2021 19:34:43 -0400
Subject: [PATCH] More Projectile API
2022-08-14 16:53:36 +02:00
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2022-03-11 17:37:08 +01:00
diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java
Updated Upstream (Bukkit/CraftBukkit) (#10379) Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f02baa38 PR-988: Add World#getIntersectingChunks(BoundingBox) 9321d665 Move getItemInUse up to LivingEntity 819eef73 PR-959: Add access to current item's remaining ticks c4fdadb0 SPIGOT-7601: Add AbstractArrow#getItem be8261ca Add support for Java 22 26119676 PR-979: Add more translation keys 66753362 PR-985: Correct book maximum pages and characters per page documentation c8be92fa PR-980: Improve getArmorContents() documentation f1120ee2 PR-983: Expose riptide velocity to PlayerRiptideEvent CraftBukkit Changes: dfaa89bbe PR-1369: Add World#getIntersectingChunks(BoundingBox) 51bbab2b9 Move getItemInUse up to LivingEntity 668e09602 PR-1331: Add access to current item's remaining ticks a639406d1 SPIGOT-7601: Add AbstractArrow#getItem 0398930fc SPIGOT-7602: Allow opening in-world horse and related inventories ffd15611c SPIGOT-7608: Allow empty lists to morph to any PDT list 2188dcfa9 Add support for Java 22 45d6a609f SPIGOT-7604: Revert "SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime" 06d915943 SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime ca3bc3707 PR-1361: Add more translation keys 366c3ca80 SPIGOT-7600: EntityChangeBlockEvent is not fired for frog eggs 06d0f9ba8 SPIGOT-7593: Fix sapling growth physics / client-side updates 45c2608e4 PR-1366: Expose riptide velocity to PlayerRiptideEvent 29b6bb79b SPIGOT-7587: Remove fixes for now-resolved MC-142590 and MC-109346
2024-04-06 21:53:39 +02:00
index 839e5b7df49f42b5fec7729997bef3370ba36d80..b36298679d6d52d09fe4bb8e52e19e18f6df742a 100644
--- a/src/main/java/org/bukkit/entity/AbstractArrow.java
+++ b/src/main/java/org/bukkit/entity/AbstractArrow.java
Updated Upstream (Bukkit/CraftBukkit) (#10379) Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f02baa38 PR-988: Add World#getIntersectingChunks(BoundingBox) 9321d665 Move getItemInUse up to LivingEntity 819eef73 PR-959: Add access to current item's remaining ticks c4fdadb0 SPIGOT-7601: Add AbstractArrow#getItem be8261ca Add support for Java 22 26119676 PR-979: Add more translation keys 66753362 PR-985: Correct book maximum pages and characters per page documentation c8be92fa PR-980: Improve getArmorContents() documentation f1120ee2 PR-983: Expose riptide velocity to PlayerRiptideEvent CraftBukkit Changes: dfaa89bbe PR-1369: Add World#getIntersectingChunks(BoundingBox) 51bbab2b9 Move getItemInUse up to LivingEntity 668e09602 PR-1331: Add access to current item's remaining ticks a639406d1 SPIGOT-7601: Add AbstractArrow#getItem 0398930fc SPIGOT-7602: Allow opening in-world horse and related inventories ffd15611c SPIGOT-7608: Allow empty lists to morph to any PDT list 2188dcfa9 Add support for Java 22 45d6a609f SPIGOT-7604: Revert "SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime" 06d915943 SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime ca3bc3707 PR-1361: Add more translation keys 366c3ca80 SPIGOT-7600: EntityChangeBlockEvent is not fired for frog eggs 06d0f9ba8 SPIGOT-7593: Fix sapling growth physics / client-side updates 45c2608e4 PR-1366: Expose riptide velocity to PlayerRiptideEvent 29b6bb79b SPIGOT-7587: Remove fixes for now-resolved MC-142590 and MC-109346
2024-04-06 21:53:39 +02:00
@@ -130,17 +130,21 @@ public interface AbstractArrow extends Projectile {
* Gets the ItemStack which will be picked up from this arrow.
*
* @return The picked up ItemStack
+ * @deprecated use {@link #getItemStack()}
*/
@NotNull
@ApiStatus.Experimental
+ @Deprecated(forRemoval = true, since = "1.20.4") // Paper
public ItemStack getItem();
/**
* Sets the ItemStack which will be picked up from this arrow.
*
* @param item ItemStack set to be picked up
+ * @deprecated until 1.20.5 when the behavior is more defined
*/
@ApiStatus.Experimental
+ @Deprecated // Paper - remove in 1.20.5
public void setItem(@NotNull ItemStack item);
/**
@@ -194,4 +198,44 @@ public interface AbstractArrow extends Projectile {
CREATIVE_ONLY;
}
Updated Upstream (Bukkit/CraftBukkit) (#10379) Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f02baa38 PR-988: Add World#getIntersectingChunks(BoundingBox) 9321d665 Move getItemInUse up to LivingEntity 819eef73 PR-959: Add access to current item's remaining ticks c4fdadb0 SPIGOT-7601: Add AbstractArrow#getItem be8261ca Add support for Java 22 26119676 PR-979: Add more translation keys 66753362 PR-985: Correct book maximum pages and characters per page documentation c8be92fa PR-980: Improve getArmorContents() documentation f1120ee2 PR-983: Expose riptide velocity to PlayerRiptideEvent CraftBukkit Changes: dfaa89bbe PR-1369: Add World#getIntersectingChunks(BoundingBox) 51bbab2b9 Move getItemInUse up to LivingEntity 668e09602 PR-1331: Add access to current item's remaining ticks a639406d1 SPIGOT-7601: Add AbstractArrow#getItem 0398930fc SPIGOT-7602: Allow opening in-world horse and related inventories ffd15611c SPIGOT-7608: Allow empty lists to morph to any PDT list 2188dcfa9 Add support for Java 22 45d6a609f SPIGOT-7604: Revert "SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime" 06d915943 SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime ca3bc3707 PR-1361: Add more translation keys 366c3ca80 SPIGOT-7600: EntityChangeBlockEvent is not fired for frog eggs 06d0f9ba8 SPIGOT-7593: Fix sapling growth physics / client-side updates 45c2608e4 PR-1366: Expose riptide velocity to PlayerRiptideEvent 29b6bb79b SPIGOT-7587: Remove fixes for now-resolved MC-142590 and MC-109346
2024-04-06 21:53:39 +02:00
// Paper end
+
Updated Upstream (Bukkit/CraftBukkit) (#10379) Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f02baa38 PR-988: Add World#getIntersectingChunks(BoundingBox) 9321d665 Move getItemInUse up to LivingEntity 819eef73 PR-959: Add access to current item's remaining ticks c4fdadb0 SPIGOT-7601: Add AbstractArrow#getItem be8261ca Add support for Java 22 26119676 PR-979: Add more translation keys 66753362 PR-985: Correct book maximum pages and characters per page documentation c8be92fa PR-980: Improve getArmorContents() documentation f1120ee2 PR-983: Expose riptide velocity to PlayerRiptideEvent CraftBukkit Changes: dfaa89bbe PR-1369: Add World#getIntersectingChunks(BoundingBox) 51bbab2b9 Move getItemInUse up to LivingEntity 668e09602 PR-1331: Add access to current item's remaining ticks a639406d1 SPIGOT-7601: Add AbstractArrow#getItem 0398930fc SPIGOT-7602: Allow opening in-world horse and related inventories ffd15611c SPIGOT-7608: Allow empty lists to morph to any PDT list 2188dcfa9 Add support for Java 22 45d6a609f SPIGOT-7604: Revert "SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime" 06d915943 SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime ca3bc3707 PR-1361: Add more translation keys 366c3ca80 SPIGOT-7600: EntityChangeBlockEvent is not fired for frog eggs 06d0f9ba8 SPIGOT-7593: Fix sapling growth physics / client-side updates 45c2608e4 PR-1366: Expose riptide velocity to PlayerRiptideEvent 29b6bb79b SPIGOT-7587: Remove fixes for now-resolved MC-142590 and MC-109346
2024-04-06 21:53:39 +02:00
+ // Paper start - more projectile API
+ /**
+ * Gets the ItemStack for this arrow.
+ *
+ * @return The ItemStack, as if a player picked up the arrow
+ */
+ @NotNull
+ org.bukkit.inventory.ItemStack getItemStack();
+
+ /**
+ * Sets the amount of ticks this arrow has been alive in the world
+ * This is used to determine when the arrow should be automatically despawned.
+ *
+ * @param ticks lifetime ticks
+ */
+ void setLifetimeTicks(int ticks);
+
+ /**
+ * Gets how many ticks this arrow has been in the world for.
+ *
+ * @return ticks this arrow has been in the world
+ */
+ int getLifetimeTicks();
+
+ /**
+ * Gets the sound that is played when this arrow hits an entity.
+ *
+ * @return sound that plays
+ */
+ @NotNull
+ org.bukkit.Sound getHitSound();
+
+ /**
+ * Sets the sound that is played when this arrow hits an entity.
+ *
+ * @param sound sound that is played
+ */
+ void setHitSound(@NotNull org.bukkit.Sound sound);
Updated Upstream (Bukkit/CraftBukkit) (#10379) Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f02baa38 PR-988: Add World#getIntersectingChunks(BoundingBox) 9321d665 Move getItemInUse up to LivingEntity 819eef73 PR-959: Add access to current item's remaining ticks c4fdadb0 SPIGOT-7601: Add AbstractArrow#getItem be8261ca Add support for Java 22 26119676 PR-979: Add more translation keys 66753362 PR-985: Correct book maximum pages and characters per page documentation c8be92fa PR-980: Improve getArmorContents() documentation f1120ee2 PR-983: Expose riptide velocity to PlayerRiptideEvent CraftBukkit Changes: dfaa89bbe PR-1369: Add World#getIntersectingChunks(BoundingBox) 51bbab2b9 Move getItemInUse up to LivingEntity 668e09602 PR-1331: Add access to current item's remaining ticks a639406d1 SPIGOT-7601: Add AbstractArrow#getItem 0398930fc SPIGOT-7602: Allow opening in-world horse and related inventories ffd15611c SPIGOT-7608: Allow empty lists to morph to any PDT list 2188dcfa9 Add support for Java 22 45d6a609f SPIGOT-7604: Revert "SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime" 06d915943 SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime ca3bc3707 PR-1361: Add more translation keys 366c3ca80 SPIGOT-7600: EntityChangeBlockEvent is not fired for frog eggs 06d0f9ba8 SPIGOT-7593: Fix sapling growth physics / client-side updates 45c2608e4 PR-1366: Expose riptide velocity to PlayerRiptideEvent 29b6bb79b SPIGOT-7587: Remove fixes for now-resolved MC-142590 and MC-109346
2024-04-06 21:53:39 +02:00
+ // Paper end - more projectile API
}
2022-03-11 17:37:08 +01:00
diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java
index 0d31aa0b22cf1e849572294e2cfe38b48c9210af..217d348ad0bbef720b25d3b507a55ca8105b7731 100644
2022-03-11 17:37:08 +01:00
--- a/src/main/java/org/bukkit/entity/Firework.java
+++ b/src/main/java/org/bukkit/entity/Firework.java
@@ -16,6 +16,8 @@ public interface Firework extends Projectile {
2022-03-11 17:37:08 +01:00
/**
* Apply the provided meta to the fireworks
+ * <p>
+ * Adjusts detonation ticks automatically.
*
* @param meta The FireworkMeta to apply
*/
@@ -54,31 +56,39 @@ public interface Firework extends Projectile {
* {@link #getMaxLife()}, the firework will detonate.
*
* @param ticks the ticks to set. Must be greater than or equal to 0
+ * @deprecated use {@link #setTicksFlown(int)}
* @return true if the life was set, false if this firework has already detonated
*/
+ @Deprecated(forRemoval = true) // Paper
boolean setLife(int ticks);
/**
* Get the ticks that this firework has been alive. When this value reaches
* {@link #getMaxLife()}, the firework will detonate.
*
+ * @deprecated use {@link #getTicksFlown()}
* @return the life ticks
*/
+ @Deprecated(forRemoval = true) // Paper
int getLife();
/**
* Set the time in ticks this firework will exist until it is detonated.
*
* @param ticks the ticks to set. Must be greater than 0
+ * @deprecated use {@link #setTicksToDetonate(int)}
* @return true if the time was set, false if this firework has already detonated
*/
+ @Deprecated(forRemoval = true) // Paper
boolean setMaxLife(int ticks);
/**
* Get the time in ticks this firework will exist until it is detonated.
*
+ * @deprecated use {@link #getTicksToDetonate()}
* @return the maximum life in ticks
*/
+ @Deprecated(forRemoval = true) // Paper
int getMaxLife();
/**
@@ -127,4 +137,52 @@ public interface Firework extends Projectile {
return getAttachedTo();
}
2022-03-11 17:37:08 +01:00
// Paper end
+
+ // Paper start - Firework API
+ /**
+ * Gets the item used in the firework.
+ *
+ * @return firework item
+ */
+ @NotNull
+ public org.bukkit.inventory.ItemStack getItem();
+
+ /**
+ * Sets the item used in the firework.
+ * <p>
+ * Firework explosion effects are used from this item.
+ *
+ * @param itemStack item to set
+ */
+ void setItem(@org.jetbrains.annotations.Nullable org.bukkit.inventory.ItemStack itemStack);
+
+ /**
+ * Gets the number of ticks the firework has flown.
+ *
+ * @return ticks flown
+ */
+ int getTicksFlown();
+
+ /**
+ * Sets the number of ticks the firework has flown.
+ * Setting this greater than detonation ticks will cause the firework to explode.
+ *
+ * @param ticks ticks flown
+ */
+ void setTicksFlown(int ticks);
+
+ /**
+ * Gets the number of ticks the firework will detonate on.
+ *
+ * @return the tick to detonate on
+ */
+ int getTicksToDetonate();
+
+ /**
+ * Set the amount of ticks the firework will detonate on.
+ *
+ * @param ticks ticks to detonate on
+ */
+ void setTicksToDetonate(int ticks);
+ // Paper end
2022-03-11 17:37:08 +01:00
}
diff --git a/src/main/java/org/bukkit/entity/FishHook.java b/src/main/java/org/bukkit/entity/FishHook.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9188) * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor 201399fb PR-853: Add API for directly setting Display transformation matrices ecfa559a PR-849: Add InventoryView#setTitle 653d7edb SPIGOT-519: Add TNTPrimeEvent 22fccc09 PR-846: Add method to get chunk load level a070a52c PR-844: Add methods to convert Vector to and from JOML vectors cc7111fe PR-276: Add accessors to Wither's invulnerability ticks 777d24e9 SPIGOT-7209: Accessors and events for player's exp cooldown ccb2d01b SPIGOT-6308: Deprecate the location name property of map items cd04a31b PR-780: Add PlayerSpawnChangeEvent 7d1f5b64 SPIGOT-6780: Improve documentation for World#spawnFallingBlock 5696668a SPIGOT-6885: Add test and easier to debug code for reference in yaml configuration comments 2e13cff7 PR-589: Expand the FishHook API 2c7d3da5 PR-279: Minor edits to various Javadocs CraftBukkit Changes: 01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting 7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices a7cfc778f PR-1176: Add InventoryView#setTitle 563d42226 SPIGOT-519: Add TNTPrimeEvent ccbc6abca Add test for Chunk.LoadLevel mirroring 2926e0513 PR-1171: Add method to get chunk load level 63cad7f84 PR-375: Add accessors to Wither's invulnerability ticks bfd8b1ac8 SPIGOT-7209: Accessors and events for player's exp cooldown f92a41c39 PR-1181: Consolidate Location conversion code 10f866759 SPIGOT-6308: Deprecate the location name property of map items 82f7b658a PR-1095: Add PlayerSpawnChangeEvent b421af7e4 PR-808: Expand the FishHook API 598ad7b3f Increase outdated build delay Spigot Changes: d1bd3bd2 Rebuild patches e4265cc8 SPIGOT-7297: Entity Tracking Range option for Display entities * Work around javac bug * Call PlayerSpawnChangeEvent * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor 201399fb PR-853: Add API for directly setting Display transformation matrices CraftBukkit Changes: 01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting 7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices Spigot Changes: 7da74dae Rebuild patches
2023-05-12 13:10:08 +02:00
index 94e1a30ea1bc26821065a6d89c1f5669bd1d08ae..6ed83d3e4d23e0dc0e1b156a1ee221aaba5c7210 100644
--- a/src/main/java/org/bukkit/entity/FishHook.java
+++ b/src/main/java/org/bukkit/entity/FishHook.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9188) * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor 201399fb PR-853: Add API for directly setting Display transformation matrices ecfa559a PR-849: Add InventoryView#setTitle 653d7edb SPIGOT-519: Add TNTPrimeEvent 22fccc09 PR-846: Add method to get chunk load level a070a52c PR-844: Add methods to convert Vector to and from JOML vectors cc7111fe PR-276: Add accessors to Wither's invulnerability ticks 777d24e9 SPIGOT-7209: Accessors and events for player's exp cooldown ccb2d01b SPIGOT-6308: Deprecate the location name property of map items cd04a31b PR-780: Add PlayerSpawnChangeEvent 7d1f5b64 SPIGOT-6780: Improve documentation for World#spawnFallingBlock 5696668a SPIGOT-6885: Add test and easier to debug code for reference in yaml configuration comments 2e13cff7 PR-589: Expand the FishHook API 2c7d3da5 PR-279: Minor edits to various Javadocs CraftBukkit Changes: 01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting 7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices a7cfc778f PR-1176: Add InventoryView#setTitle 563d42226 SPIGOT-519: Add TNTPrimeEvent ccbc6abca Add test for Chunk.LoadLevel mirroring 2926e0513 PR-1171: Add method to get chunk load level 63cad7f84 PR-375: Add accessors to Wither's invulnerability ticks bfd8b1ac8 SPIGOT-7209: Accessors and events for player's exp cooldown f92a41c39 PR-1181: Consolidate Location conversion code 10f866759 SPIGOT-6308: Deprecate the location name property of map items 82f7b658a PR-1095: Add PlayerSpawnChangeEvent b421af7e4 PR-808: Expand the FishHook API 598ad7b3f Increase outdated build delay Spigot Changes: d1bd3bd2 Rebuild patches e4265cc8 SPIGOT-7297: Entity Tracking Range option for Display entities * Work around javac bug * Call PlayerSpawnChangeEvent * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor 201399fb PR-853: Add API for directly setting Display transformation matrices CraftBukkit Changes: 01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting 7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices Spigot Changes: 7da74dae Rebuild patches
2023-05-12 13:10:08 +02:00
@@ -322,4 +322,20 @@ public interface FishHook extends Projectile {
*/
BOBBING;
}
+
+ // Paper start - More FishHook API
+ /**
+ * Get the number of ticks the hook needs to wait for a fish to bite.
+ *
+ * @return Number of ticks
+ */
+ int getWaitTime();
+
+ /**
+ * Sets the number of ticks the hook needs to wait for a fish to bite.
+ *
+ * @param ticks Number of ticks
+ */
+ void setWaitTime(int ticks);
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Projectile.java b/src/main/java/org/bukkit/entity/Projectile.java
index 06e3ad9cd8f39de0ef6ead794df1492415bc4302..c3933fb5cd9708826effeef2ad2f81c9f7900a37 100644
--- a/src/main/java/org/bukkit/entity/Projectile.java
+++ b/src/main/java/org/bukkit/entity/Projectile.java
@@ -12,6 +12,7 @@ public interface Projectile extends Entity {
* Retrieve the shooter of this projectile.
*
* @return the {@link ProjectileSource} that shot this projectile
+ * @see #getOwnerUniqueId()
*/
@Nullable
public ProjectileSource getShooter();
@@ -41,4 +42,89 @@ public interface Projectile extends Entity {
*/
@Deprecated(forRemoval = true)
public void setBounce(boolean doesBounce);
+ // Paper start
+
+ /**
+ * Gets whether the projectile has left the
+ * hitbox of their shooter and can now hit entities.
+ *
+ * @return has left shooter's hitbox
+ */
+ boolean hasLeftShooter();
+
+ /**
+ * Sets whether the projectile has left the
+ * hitbox of their shooter and can now hit entities.
+ *
+ * This is recalculated each tick if the projectile has a shooter.
+ *
+ * @param leftShooter has left shooter's hitbox
+ */
+ void setHasLeftShooter(boolean leftShooter);
+
+ /**
+ * Gets whether the projectile has been
+ * shot into the world and has sent a projectile
+ * shot game event.
+ *
+ * @return has been shot into the world
+ */
+ boolean hasBeenShot();
+
+ /**
+ * Sets whether the projectile has been
+ * shot into the world and has sent a projectile
+ * shot game event in the next tick.
+ *
+ * Setting this to false will cause a game event
+ * to fire and the value to be set back to true.
+ *
+ * @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);
+
+ /**
+ * Gets the owner's UUID
+ *
+ * @return the owner's UUID, or null if not owned
+ * @see #getShooter()
+ */
+ @Nullable
+ java.util.UUID getOwnerUniqueId();
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/ShulkerBullet.java b/src/main/java/org/bukkit/entity/ShulkerBullet.java
index 4623e0d767b343cbdc6fcf20b3b2ff7ff14863cf..dd69a68d1f005c25329bb0366d161ae9b061e108 100644
--- a/src/main/java/org/bukkit/entity/ShulkerBullet.java
+++ b/src/main/java/org/bukkit/entity/ShulkerBullet.java
@@ -18,4 +18,61 @@ public interface ShulkerBullet extends Projectile {
* @param target the entity to target
*/
void setTarget(@Nullable Entity target);
+ // Paper start
+ /**
+ * Gets the relative offset that this shulker bullet should move towards,
+ * note that this will change each tick as the skulker bullet approaches the target.
+ *
+ * @return target delta offset
+ */
+ @org.jetbrains.annotations.NotNull
+ org.bukkit.util.Vector getTargetDelta();
+
+
+ /**
+ * Sets the relative offset that this shulker bullet should move towards,
+ * note that this will change each tick as the skulker bullet approaches the target.
+ * This is usually relative towards their target.
+ *
+ * @param vector target
+ */
+ void setTargetDelta(@org.jetbrains.annotations.NotNull org.bukkit.util.Vector vector);
+
+ /**
+ * Gets the current movement direction.
+ * This is used to determine the next movement direction to ensure
+ * that the bullet does not move in the same direction.
+ *
+ * @return null or their current direction
+ */
+ @Nullable
+ org.bukkit.block.BlockFace getCurrentMovementDirection();
+
+ /**
+ * Set the current movement direction.
+ * This is used to determine the next movement direction to ensure
+ * that the bullet does not move in the same direction.
+ *
+ * Set to null to simply pick a random direction.
+ *
+ * @param movementDirection null or a direction
+ */
+ void setCurrentMovementDirection(@Nullable org.bukkit.block.BlockFace movementDirection);
+
+ /**
+ * Gets how many ticks this shulker bullet
+ * will attempt to move in its current direction.
+ *
+ * @return number of steps
+ */
+ int getFlightSteps();
+
+ /**
+ * Sets how many ticks this shulker bullet
+ * will attempt to move in its current direction.
+ *
+ * @param steps number of steps
+ */
+ void setFlightSteps(int steps);
+ // Paper end
}
2022-03-11 17:37:08 +01:00
diff --git a/src/main/java/org/bukkit/entity/ThrownPotion.java b/src/main/java/org/bukkit/entity/ThrownPotion.java
index 7051e07b4e456aae0ec9e37808b59e5fa62a4027..225ac312613b9e8f3cf680819f2ebe350d1bf48a 100644
2022-03-11 17:37:08 +01:00
--- a/src/main/java/org/bukkit/entity/ThrownPotion.java
+++ b/src/main/java/org/bukkit/entity/ThrownPotion.java
@@ -32,12 +32,34 @@ public interface ThrownPotion extends ThrowableProjectile {
2022-03-11 17:37:08 +01:00
/**
* Set the ItemStack for this thrown potion.
- * <p>
- * The ItemStack must be of type {@link org.bukkit.Material#SPLASH_POTION}
- * or {@link org.bukkit.Material#LINGERING_POTION}, otherwise an exception
- * is thrown.
*
* @param item New ItemStack
*/
public void setItem(@NotNull ItemStack item);
+
+ // Paper start - Projectile API
+ /**
+ * Gets a copy of the PotionMeta for this thrown potion.
+ * This includes what effects will be applied by this potion.
+ *
+ * @return potion meta
+ */
+ @NotNull
+ org.bukkit.inventory.meta.PotionMeta getPotionMeta();
+
+ /**
+ * Sets the PotionMeta of this thrown potion.
+ * This will modify the effects applied by this potion.
+ * <p>
+ * Note that the type of {@link #getItem()} is irrelevant
+ *
+ * @param meta potion meta
+ */
+ void setPotionMeta(@NotNull org.bukkit.inventory.meta.PotionMeta meta);
2022-08-14 16:53:36 +02:00
+
+ /**
+ * Splashes the potion at its current location.
+ */
+ void splash();
2022-03-11 17:37:08 +01:00
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Trident.java b/src/main/java/org/bukkit/entity/Trident.java
index c8015ff610e3c1222cb368ea1d8a0c2f3785d9c7..02584eced96944a551140f8150c65a7c0f4bb55e 100644
--- a/src/main/java/org/bukkit/entity/Trident.java
+++ b/src/main/java/org/bukkit/entity/Trident.java
@@ -38,5 +38,24 @@ public interface Trident extends AbstractArrow, ThrowableProjectile {
* @throws IllegalArgumentException if the loyalty level is lower than 0 or greater than 127
*/
void setLoyaltyLevel(int loyaltyLevel);
+
+ /**
+ * Gets if this trident has dealt damage to an
+ * entity yet or has hit the floor.
+ *
+ * If neither of these events have occurred yet, this will
+ * return false.
+ *
+ * @return has dealt damage
+ */
+ boolean hasDealtDamage();
+
+ /**
+ * Sets if this trident has dealt damage to an entity
+ * yet or has hit the floor.
+ *
+ * @param hasDealtDamage has dealt damage or hit the floor
+ */
+ void setHasDealtDamage(boolean hasDealtDamage);
}
// Paper end