diff --git a/patches/api/More-lightning-API.patch b/patches/api/More-lightning-API.patch index 95cfe8ba05..c4c854e699 100644 --- a/patches/api/More-lightning-API.patch +++ b/patches/api/More-lightning-API.patch @@ -45,5 +45,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @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. ++ *

++ * 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. ++ *

++ *

++ * 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)}. ++ *

++ * ++ * @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. ++ *

++ * 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. ++ *

++ * ++ * @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); + // Paper end } diff --git a/patches/server/More-lightning-API.patch b/patches/server/More-lightning-API.patch index 8f7f315443..98a98102a4 100644 --- a/patches/server/More-lightning-API.patch +++ b/patches/server/More-lightning-API.patch @@ -34,5 +34,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setLifeTicks(int lifeTicks) { + getHandle().life = lifeTicks; + } ++ ++ @Override ++ public @org.jetbrains.annotations.Nullable org.bukkit.entity.Entity getCausingEntity() { ++ final var cause = this.getHandle().getCause(); ++ return cause == null ? null : cause.getBukkitEntity(); ++ } ++ ++ @Override ++ public void setCausingPlayer(@org.jetbrains.annotations.Nullable org.bukkit.entity.Player causingPlayer) { ++ this.getHandle().setCause(causingPlayer == null ? null : ((CraftPlayer) causingPlayer).getHandle()); ++ } + // Paper end }