Paper/patches/api/0226-More-lightning-API.patch

84 lines
3.8 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
2021-06-11 14:02:28 +02:00
Date: Sun, 26 Jul 2020 14:44:16 +0200
Subject: [PATCH] More lightning API
diff --git a/src/main/java/org/bukkit/entity/LightningStrike.java b/src/main/java/org/bukkit/entity/LightningStrike.java
2023-09-21 10:35:38 +02:00
index 76407851a3401982214c3e20aefb406fc5c63310..ba06afd01d1e1fef2123412735653593453d3ab7 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/LightningStrike.java
+++ b/src/main/java/org/bukkit/entity/LightningStrike.java
2023-09-21 10:35:38 +02:00
@@ -42,4 +42,72 @@ public interface LightningStrike extends Entity {
@Deprecated // Paper
2021-06-11 14:02:28 +02:00
Spigot spigot();
// Spigot end
+
+ // Paper start
+ /**
+ * Returns the amount of flash iterations that will be done before the lightning dies.
+ *
+ * @see #getLifeTicks() for how long the current flash will last
+ * @return amount of flashes that will be shown before the lightning dies
+ */
+ int getFlashCount();
+
+ /**
+ * Sets the amount of life iterations that will be done before the lightning dies.
+ * Default number of flashes on creation is between 1-3.
+ *
+ * @param flashes amount of iterations that will be done before the lightning dies, must to be a positive number
+ */
+ void setFlashCount(int flashes);
+
+ /**
+ * Returns the amount of ticks the current flash will do damage for.
+ * Starts with 2 by default, will damage while it is equal to or above 0, with the next flash beginning somewhere between 0 and -9.
+ *
+ * @return ticks the current flash will do damage for
+ */
+ int getLifeTicks();
+
+ /**
+ * Sets the amount of ticks the current flash will do damage/fire for.
+ * Default is 2 for each flash, on which the sound and effect will also be played.
+ *
+ * @param lifeTicks ticks the current flash will do damage for
+ */
+ void setLifeTicks(int lifeTicks);
+
+ /**
+ * Returns the potential entity that caused this lightning strike to spawn in the world.
+ * <p>
+ * As of implementing this method, only {@link Player}s are capable of causing a lightning strike, however as this
+ * might change in future minecraft releases, this method does not guarantee a player as the cause of a lightning.
+ * Consumers of this method should hence validate whether or not the entity is a player if they want to use player
+ * specific methods through an {@code instanceOf} check.
+ * </p>
+ * <p>
+ * A player is, as of implementing this method, responsible for a lightning, and will hence be returned here as
+ * a cause, if they channeled a {@link Trident} to summon it or were explicitly defined as the cause of this
+ * lightning through {@link #setCausingPlayer(Player)}.
+ * </p>
+ *
+ * @return the entity that caused this lightning or null if the lightning was not caused by a entity (e.g. normal
+ * weather)
+ */
+ @org.jetbrains.annotations.Nullable
+ Entity getCausingEntity();
+
+ /**
+ * Updates the player that caused this lightning to be summoned into the world.
+ * By default, players that channel their {@link Trident} will be the cause of the respective lightning.
+ * <p>
+ * While the respective getter method {@link #getCausingEntity()} does not guarantee a player as the cause of a
+ * lightning to stay as future proof as possible, as of implementing this method, players are the only entities
+ * that can cause a lightning strike and hence this setter is restricted to players.
+ * </p>
+ *
+ * @param causingPlayer the player that should be the new cause of this lightning. {@code null} may be passed to
+ * indicate that no player is responsible for this lightning.
+ */
+ void setCausingPlayer(@org.jetbrains.annotations.Nullable Player causingPlayer);
2021-06-11 14:02:28 +02:00
+ // Paper end
}