Interface Firework

All Superinterfaces:
net.kyori.adventure.audience.Audience, CommandSender, DataComponentView, Entity, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>, Metadatable, Nameable, Permissible, PersistentDataHolder, PersistentDataViewHolder, net.kyori.adventure.pointer.Pointered, Projectile, ServerOperator, net.kyori.adventure.sound.Sound.Emitter, net.kyori.adventure.sound.Sound.Source.Provider

@NullMarked public interface Firework extends Projectile
Since:
1.4.6
  • Method Details

    • getFireworkMeta

      @Obsolete FireworkMeta getFireworkMeta()
      Get a copy of the fireworks meta
      Returns:
      A copy of the current Firework meta
      Since:
      1.4.6
      API Note:
      obsolete in favor of getItem() / setItem(ItemStack) with the equivalent DataComponentTypes.FIREWORKS component
    • setFireworkMeta

      @Obsolete void setFireworkMeta(FireworkMeta meta)
      Apply the provided meta to the fireworks

      Adjusts detonation ticks automatically.

      Parameters:
      meta - The FireworkMeta to apply
      Since:
      1.4.6
      API Note:
      obsolete in favor of getItem() / setItem(ItemStack) with the equivalent DataComponentTypes.FIREWORKS component
    • setAttachedTo

      boolean setAttachedTo(@Nullable LivingEntity entity)
      Set the LivingEntity to which this firework is attached.

      When attached to an entity, the firework effect will act as normal but remain positioned on the entity. If the entity LivingEntity#isGliding() is gliding, then the entity will receive a boost in the direction that they are looking.

      Parameters:
      entity - the entity to which the firework should be attached, or null to remove the attached entity
      Returns:
      true if the entity could be attached, false if the firework was already detonated
      Since:
      1.19.2
    • getAttachedTo

      @Nullable LivingEntity getAttachedTo()
      Get the LivingEntity to which this firework is attached.

      When attached to an entity, the firework effect will act as normal but remain positioned on the entity. If the entity LivingEntity#isGliding() is gliding, then the entity will receive a boost in the direction that they are looking.

      Returns:
      the attached entity, or null if none
      Since:
      1.19.2
    • setLife

      @Deprecated(forRemoval=true, since="1.18.2") boolean setLife(int ticks)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the ticks that this firework has been alive. If this value exceeds getMaxLife(), the firework will detonate.
      Parameters:
      ticks - the ticks to set. Must be greater than or equal to 0
      Returns:
      true if the life was set, false if this firework has already detonated
    • getLife

      @Deprecated(forRemoval=true, since="1.18.2") default int getLife()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the ticks that this firework has been alive. When this value reaches getMaxLife(), the firework will detonate.
      Returns:
      the life ticks
    • setMaxLife

      @Deprecated(forRemoval=true, since="1.18.2") boolean setMaxLife(int ticks)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the time in ticks this firework will exist until it is detonated.
      Parameters:
      ticks - the ticks to set. Must be greater than 0
      Returns:
      true if the time was set, false if this firework has already detonated
    • getMaxLife

      @Deprecated(forRemoval=true, since="1.18.2") default int getMaxLife()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the time in ticks this firework will exist until it is detonated.
      Returns:
      the maximum life in ticks
    • detonate

      void detonate()
      Cause this firework to explode at earliest opportunity, as if it has no remaining fuse.
      Since:
      1.7.2
    • isDetonated

      boolean isDetonated()
      Check whether or not this firework has detonated.
      Returns:
      true if detonated, false if still in the world
      Since:
      1.19.2
    • isShotAtAngle

      boolean isShotAtAngle()
      Gets if the firework was shot at an angle (i.e. from a crossbow). A firework which was not shot at an angle will fly straight upwards.
      Returns:
      shot at angle status
      Since:
      1.14.4
    • setShotAtAngle

      void setShotAtAngle(boolean shotAtAngle)
      Sets if the firework was shot at an angle (i.e. from a crossbow). A firework which was not shot at an angle will fly straight upwards.
      Parameters:
      shotAtAngle - the new shotAtAngle
      Since:
      1.14.4
    • getSpawningEntity

      @Nullable UUID getSpawningEntity()
      Retrieves the UUID of the entity responsible for spawning this firework.
      Returns:
      the UUID of the spawning entity, or null if no spawning entity is associated
      Since:
      1.11.2
    • getBoostedEntity

      @Deprecated(since="1.18.2") default @Nullable LivingEntity getBoostedEntity()
      Deprecated.
      If this firework is boosting an entity, return it
      Returns:
      The entity being boosted
      Since:
      1.11.2
      See Also:
    • getItem

      ItemStack getItem()
      Gets the item used in the firework.
      Returns:
      firework item
      Since:
      1.18.2
    • setItem

      void setItem(@Nullable ItemStack itemStack)
      Sets the item used in the firework.

      Firework explosion effects are used from this item.

      Parameters:
      itemStack - item to set
      Since:
      1.18.2
    • getTicksFlown

      int getTicksFlown()
      Gets the number of ticks the firework has flown.
      Returns:
      ticks flown
      Since:
      1.18.2
    • setTicksFlown

      void setTicksFlown(int ticks)
      Sets the number of ticks the firework has flown. Setting this greater than detonation ticks will cause the firework to explode.
      Parameters:
      ticks - ticks flown
      Since:
      1.18.2
    • getTicksToDetonate

      int getTicksToDetonate()
      Gets the number of ticks the firework will detonate on.
      Returns:
      the tick to detonate on
      Since:
      1.18.2
    • setTicksToDetonate

      void setTicksToDetonate(int ticks)
      Set the amount of ticks the firework will detonate on.
      Parameters:
      ticks - ticks to detonate on
      Since:
      1.18.2