Class AbstractEmitter<S extends EmitterSettings>

java.lang.Object
me.deecaad.core.emitter.AbstractEmitter<S>
All Implemented Interfaces:
Emitter, Tickable, TransformLike
Direct Known Subclasses:
DisplayEntityEmitter, ParticleEmitter

public abstract class AbstractEmitter<S extends EmitterSettings> extends Object implements Emitter
Common emission logic for emitters: holds the immutable EmitterSettings, the Transform that places the emitter in the hierarchy, and the per-tick emission scheduling. Subclasses fill in emit(Location, Vector) and (optionally) tickAlive() / hasLiveItems().

Set the world before registering with a TickManager: either via spawnAt(Location) (which also seeds the transform from the location) or via setWorld(World).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final S
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractEmitter(S settings)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    emit(@NotNull org.bukkit.Location point, @NotNull org.bukkit.util.Vector velocity)
    Spawns one emitted item.
    int
     
     
    @Nullable org.bukkit.Location
    The location used by TickManager implementations to choose a region for scheduling.
    final @NotNull Transform
    The transform node that places this object in a transform hierarchy.
    @Nullable org.bukkit.World
     
    protected boolean
     
    boolean
     
    double
     
    void
    setWorld(@NotNull org.bukkit.World world)
     
    void
    spawnAt(@NotNull org.bukkit.Location location)
    Convenience: seeds the transform from location (position + yaw/pitch) and captures its world.
    void
    Requests early termination; the next tick returns true.
    final boolean
    Performs one tick of work.
    protected void
    Advances any persistent emitted items (display entities, etc.).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface me.deecaad.core.tick.Tickable

    remove

    Methods inherited from interface me.deecaad.core.utils.TransformLike

    applyTransform, update
  • Field Details

  • Constructor Details

    • AbstractEmitter

      protected AbstractEmitter(@NotNull S settings)
  • Method Details

    • getSettings

      @NotNull public S getSettings()
    • getTransform

      @NotNull public final @NotNull Transform getTransform()
      Description copied from interface: TransformLike
      The transform node that places this object in a transform hierarchy.
      Specified by:
      getTransform in interface TransformLike
      Returns:
      The non-null transform.
    • spawnAt

      public void spawnAt(@NotNull @NotNull org.bukkit.Location location)
      Convenience: seeds the transform from location (position + yaw/pitch) and captures its world. Equivalent to setting the transform manually and calling setWorld(World).
    • setWorld

      public void setWorld(@NotNull @NotNull org.bukkit.World world)
    • getWorld

      @Nullable public @Nullable org.bukkit.World getWorld()
    • getAge

      public int getAge()
    • normalizedAge

      public double normalizedAge()
      Returns:
      Age normalized to [0, 1] by durationTicks; returns 0 for infinite emitters.
    • stop

      public void stop()
      Requests early termination; the next tick returns true.
    • tick

      public final boolean tick()
      Description copied from interface: Tickable
      Performs one tick of work. Return true when finished; the manager will cancel and call Tickable.remove().
      Specified by:
      tick in interface Tickable
      Returns:
      true to stop ticking.
    • getTickLocation

      @Nullable public @Nullable org.bukkit.Location getTickLocation()
      Description copied from interface: Tickable
      The location used by TickManager implementations to choose a region for scheduling. Must return non-null on Folia.
      Specified by:
      getTickLocation in interface Tickable
      Returns:
      The location, or null if region-agnostic (non-Folia only).
    • isFinished

      public boolean isFinished()
      Specified by:
      isFinished in interface Emitter
      Returns:
      true when the emitter's duration has elapsed AND no live emitted items remain (so the tick manager can remove it).
    • emit

      protected abstract void emit(@NotNull @NotNull org.bukkit.Location point, @NotNull @NotNull org.bukkit.util.Vector velocity)
      Spawns one emitted item. Called once per item selected by the emission scheduler.
    • tickAlive

      protected void tickAlive()
      Advances any persistent emitted items (display entities, etc.). No-op by default for fire-and-forget emitters like particles.
    • hasLiveItems

      protected boolean hasLiveItems()
      Returns:
      true if any emitted item is still alive and must keep the emitter ticking past its duration.