Paper/patches/api/0370-More-Projectile-API.patch
Nassim Jahnke 928bcc8d3a
Updated Upstream (Bukkit/CraftBukkit) (#8430)
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:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events

CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
2022-10-02 09:56:36 +02:00

182 Zeilen
5.7 KiB
Diff

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
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java
index 0d31aa0b22cf1e849572294e2cfe38b48c9210af..571712e17551f24b369044b8215b722f7183ae7d 100644
--- 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 {
/**
* 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();
}
// 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 stop
}
diff --git a/src/main/java/org/bukkit/entity/FishHook.java b/src/main/java/org/bukkit/entity/FishHook.java
index d1b37530319f6d37ee37f62080289c1e45848bc8..e94c7e279356c510f60508b26277d4891a4258fa 100644
--- a/src/main/java/org/bukkit/entity/FishHook.java
+++ b/src/main/java/org/bukkit/entity/FishHook.java
@@ -162,4 +162,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/ThrownPotion.java b/src/main/java/org/bukkit/entity/ThrownPotion.java
index 7051e07b4e456aae0ec9e37808b59e5fa62a4027..225ac312613b9e8f3cf680819f2ebe350d1bf48a 100644
--- 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 {
/**
* 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);
+
+ /**
+ * Splashes the potion at its current location.
+ */
+ void splash();
+ // Paper end
}