Package me.deecaad.core.emitter
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
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidemit(@NotNull org.bukkit.Location point, @NotNull org.bukkit.util.Vector velocity) Spawns one emitted item.intgetAge()@Nullable org.bukkit.LocationThe location used byTickManagerimplementations to choose a region for scheduling.final @NotNull TransformThe transform node that places this object in a transform hierarchy.@Nullable org.bukkit.WorldgetWorld()protected booleanbooleandoublevoidsetWorld(@NotNull org.bukkit.World world) voidspawnAt(@NotNull org.bukkit.Location location) Convenience: seeds the transform fromlocation(position + yaw/pitch) and captures its world.voidstop()Requests early termination; the next tick returnstrue.final booleantick()Performs one tick of work.protected voidAdvances any persistent emitted items (display entities, etc.).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.deecaad.core.utils.TransformLike
applyTransform, update
-
Field Details
-
settings
-
-
Constructor Details
-
AbstractEmitter
-
-
Method Details
-
getSettings
-
getTransform
Description copied from interface:TransformLikeThe transform node that places this object in a transform hierarchy.- Specified by:
getTransformin interfaceTransformLike- Returns:
- The non-null transform.
-
spawnAt
public void spawnAt(@NotNull @NotNull org.bukkit.Location location) Convenience: seeds the transform fromlocation(position + yaw/pitch) and captures its world. Equivalent to setting the transform manually and callingsetWorld(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]bydurationTicks; returns0for infinite emitters.
-
stop
public void stop()Requests early termination; the next tick returnstrue. -
tick
public final boolean tick()Description copied from interface:TickablePerforms one tick of work. Returntruewhen finished; the manager will cancel and callTickable.remove(). -
getTickLocation
@Nullable public @Nullable org.bukkit.Location getTickLocation()Description copied from interface:TickableThe location used byTickManagerimplementations to choose a region for scheduling. Must return non-null on Folia.- Specified by:
getTickLocationin interfaceTickable- Returns:
- The location, or
nullif region-agnostic (non-Folia only).
-
isFinished
public boolean isFinished()- Specified by:
isFinishedin interfaceEmitter- Returns:
truewhen 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:
trueif any emitted item is still alive and must keep the emitter ticking past its duration.
-