Class Tracker

java.lang.Object
kr.toxicity.model.api.tracker.Tracker
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
DummyTracker, EntityTracker

public abstract class Tracker extends Object implements AutoCloseable
Tracker of a model.
  • Field Details

    • TRACKER_TICK_INTERVAL

      public static final int TRACKER_TICK_INTERVAL
      Tracker tick interval
      See Also:
    • MINECRAFT_TICK_MULTIPLIER

      public static final int MINECRAFT_TICK_MULTIPLIER
      Multiplier value for convert tracker tick to minecraft tick
      See Also:
    • pipeline

      protected final RenderPipeline pipeline
    • modifier

      protected final TrackerModifier modifier
    • rotator

      protected ModelRotator rotator
    • scaler

      protected ModelScaler scaler
  • Constructor Details

    • Tracker

      public Tracker(@NotNull @NotNull RenderPipeline pipeline, @NotNull @NotNull TrackerModifier modifier)
      Creates tracker
      Parameters:
      pipeline - target instance
      modifier - modifier
  • Method Details

    • isScheduled

      public boolean isScheduled()
      Returns this model is being scheduled.
      Returns:
      is scheduled
    • rotation

      @NotNull public @NotNull ModelRotation rotation()
      Gets model rotation.
      Returns:
      rotation
    • rotation

      public final void rotation(@NotNull @NotNull Supplier<ModelRotation> supplier)
    • rotator

      public final void rotator(@NotNull @NotNull ModelRotator rotator)
    • scaler

      @NotNull public @NotNull ModelScaler scaler()
    • scaler

      public void scaler(@NotNull @NotNull ModelScaler scaler)
    • task

      public void task(@NotNull @NotNull Runnable runnable)
      Register this task on next tick
      Parameters:
      runnable - task
    • frame

      public void frame(@NotNull @NotNull Tracker.ScheduledPacketHandler handler)
      Runs consumer on frame.
      Parameters:
      handler - handler
    • tick

      public void tick(@NotNull @NotNull Tracker.ScheduledPacketHandler handler)
      Runs consumer on tick.
      Parameters:
      handler - handler
    • tick

      public void tick(long tick, @NotNull @NotNull Tracker.ScheduledPacketHandler handler)
      Runs consumer on tick.
      Parameters:
      tick - tick
      handler - handler
    • perPlayerTick

      public void perPlayerTick(@NotNull @NotNull BiConsumer<Tracker,org.bukkit.entity.Player> perPlayerHandler)
      Runs consumer on tick per player.
      Parameters:
      perPlayerHandler - player
    • schedule

      public void schedule(long period, @NotNull @NotNull Tracker.ScheduledPacketHandler handler)
      Schedules some task.
      Parameters:
      period - period
      handler - handler
    • update

      protected void update()
    • name

      @NotNull public @NotNull String name()
      Gets tracker name
      Returns:
      name
    • height

      public double height()
      Gets tracker model's height
      Returns:
      height
    • isClosed

      public boolean isClosed()
      Checks this tracker is closed
      Returns:
      is closed
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • close

      protected void close(@NotNull @NotNull Tracker.CloseReason reason)
    • despawn

      public void despawn()
      Despawns this tracker to all players
    • modifier

      @NotNull public @NotNull TrackerModifier modifier()
      Gets tracker modifier
      Returns:
      tracker modifier
    • pause

      public boolean pause(boolean pause)
      Pauses this tracker's tick
      Parameters:
      pause - pause
      Returns:
      success
    • forceUpdate

      public boolean forceUpdate(boolean force)
      Forces packet update.
      Parameters:
      force - force
      Returns:
      success
    • spawn

      protected boolean spawn(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull PacketBundler bundler)
      Creates model spawn packet and registers player.
      Parameters:
      player - target player
      bundler - bundler
      Returns:
      success
    • remove

      public boolean remove(@NotNull @NotNull org.bukkit.entity.Player player)
      Removes model from player
      Parameters:
      player - player
      Returns:
      success
    • playerCount

      public int playerCount()
      Gets number of viewed players.
      Returns:
      viewed player amount
    • viewedPlayer

      @NotNull public @NotNull Stream<org.bukkit.entity.Player> viewedPlayer()
      Gets viewed players.
      Returns:
      viewed players list
    • location

      @NotNull public abstract @NotNull org.bukkit.Location location()
      Gets location of a model.
      Returns:
      location
    • animate

      public boolean animate(@NotNull @NotNull String animation)
      Players this animation by once
      Parameters:
      animation - animation's name
      Returns:
      success
    • animate

      public boolean animate(@NotNull @NotNull String animation, AnimationModifier modifier)
      Players this animation by once
      Parameters:
      animation - animation's name
      modifier - modifier
      Returns:
      success
    • animate

      public boolean animate(@NotNull @NotNull String animation, AnimationModifier modifier, Runnable removeTask)
      Players this animation by once
      Parameters:
      animation - animation's name
      modifier - modifier
      removeTask - remove task
      Returns:
      success
    • animate

      public boolean animate(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull String animation, @NotNull @NotNull AnimationModifier modifier, @NotNull @NotNull Runnable removeTask)
      Players this animation by once
      Parameters:
      filter - bone predicate
      animation - animation's name
      modifier - modifier
      removeTask - remove task
      Returns:
      success
    • animate

      public boolean animate(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull String animation, @NotNull @NotNull AnimationModifier modifier, @NotNull @NotNull AnimationEventHandler eventHandler)
      Players this animation by once
      Parameters:
      filter - bone predicate
      animation - animation's name
      modifier - modifier
      eventHandler - event handler
      Returns:
      success
    • animate

      public boolean animate(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull BlueprintAnimation animation, @NotNull @NotNull AnimationModifier modifier, @NotNull @NotNull Runnable removeTask)
      Players this animation by once
      Parameters:
      filter - bone predicate
      animation - animation
      modifier - modifier
      removeTask - remove task
      Returns:
      success
    • animate

      public boolean animate(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull BlueprintAnimation animation, @NotNull @NotNull AnimationModifier modifier, @NotNull @NotNull AnimationEventHandler eventHandler)
      Players this animation by once
      Parameters:
      filter - bone predicate
      animation - animation
      modifier - modifier
      eventHandler - event handler
      Returns:
      success
    • stopAnimation

      public boolean stopAnimation(@NotNull @NotNull String animation)
      Stops some animation
      Parameters:
      animation - animation's name
      Returns:
      success
    • stopAnimation

      public boolean stopAnimation(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull String animation)
      Stops some animation
      Parameters:
      filter - bone predicate
      animation - animation's name
      Returns:
      success
    • stopAnimation

      public boolean stopAnimation(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull String animation, @Nullable @Nullable org.bukkit.entity.Player player)
      Stops some animation
      Parameters:
      filter - bone predicate
      animation - animation's name
      player - player
      Returns:
      success
    • replace

      public boolean replace(@NotNull @NotNull String target, @NotNull @NotNull String animation, @NotNull @NotNull AnimationModifier modifier)
      Replaces some animation by loop
      Parameters:
      target - old animation's name
      animation - new animation's name
      modifier - modifier
      Returns:
      success
    • replace

      public boolean replace(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull String target, @NotNull @NotNull String animation, @NotNull @NotNull AnimationModifier modifier)
      Replaces some animation by loop
      Parameters:
      filter - bone predicate
      target - old animation's name
      animation - new animation's name
      modifier - modifier
      Returns:
      success
    • replace

      public boolean replace(@NotNull @NotNull Predicate<RenderedBone> filter, @NotNull @NotNull String target, @NotNull @NotNull BlueprintAnimation animation, @NotNull @NotNull AnimationModifier modifier)
      Replaces some animation by loop
      Parameters:
      filter - bone predicate
      target - old animation's name
      animation - new animation
      modifier - modifier
      Returns:
      success
    • tint

      public void tint(int rgb)
      Toggles red tint of a model.
      Parameters:
      rgb - toggle
    • tint

      public boolean tint(@NotNull @NotNull BonePredicate predicate, int rgb)
      Toggles red tint of a model.
      Parameters:
      predicate - predicate
      rgb - toggle
    • createHitBox

      public boolean createHitBox(@NotNull @NotNull EntityAdapter entity, @NotNull @NotNull BonePredicate predicate, @Nullable @Nullable HitBoxListener listener)
      Creates hitbox based on some entity
      Parameters:
      entity - entity base
      predicate - predicate
      listener - listener
      Returns:
      success
    • createNametag

      public boolean createNametag(@NotNull @NotNull BonePredicate predicate, @NotNull @NotNull Consumer<ModelNametag> consumer)
      Creates nametag
      Parameters:
      predicate - predicate
      consumer - nametag consumer
      Returns:
      success
    • updateDisplay

      public void updateDisplay(@NotNull @NotNull Predicate<RenderedBone> predicate)
      Updates item
      Parameters:
      predicate - predicate
    • updateDisplay

      public void updateDisplay(@NotNull @NotNull BonePredicate predicate)
      Updates item
      Parameters:
      predicate - predicate
    • update

      public <T extends TrackerUpdateAction> void update(@NotNull T action)
      Forces update of this tracker.
      Type Parameters:
      T - action type
      Parameters:
      action - action
    • update

      public <T extends TrackerUpdateAction> void update(@NotNull T action, @NotNull @NotNull Predicate<RenderedBone> predicate)
      Forces update of this tracker.
      Type Parameters:
      T - action type
      Parameters:
      action - action
      predicate - predicate
    • update

      public <T extends TrackerUpdateAction> void update(@NotNull T action, @NotNull @NotNull BonePredicate predicate)
      Forces update of this tracker.
      Type Parameters:
      T - action type
      Parameters:
      action - action
      predicate - predicate
    • tryUpdate

      public boolean tryUpdate(@NotNull @NotNull BiPredicate<RenderedBone,BonePredicate> action, @NotNull @NotNull BonePredicate predicate)
      Update data of this tracker.
      Parameters:
      action - action
      predicate - predicate
    • bone

      @Nullable public @Nullable RenderedBone bone(@NotNull @NotNull BoneName name)
      Gets bone by bone's name
      Parameters:
      name - bone's name
      Returns:
      bone or null
    • bone

      @Nullable public @Nullable RenderedBone bone(@NotNull @NotNull String name)
      Gets bone by bone's name
      Parameters:
      name - bone's name
      Returns:
      bone or null
    • bone

      @Nullable public @Nullable RenderedBone bone(@NotNull @NotNull Predicate<RenderedBone> predicate)
      Gets bone by bone's name
      Parameters:
      predicate - bone's predicate
      Returns:
      bone or null
    • bones

      @NotNull public @NotNull @Unmodifiable Collection<RenderedBone> bones()
      Gets all bones
      Returns:
      all bones
    • displays

      @NotNull public @NotNull Stream<ModelDisplay> displays()
      Gets all model displays
      Returns:
      all model displays
    • hide

      public boolean hide(@NotNull @NotNull org.bukkit.entity.Player player)
      Hides this tracker to some player
      Parameters:
      player - target player
      Returns:
      success
    • isHide

      public boolean isHide(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks this player is marked as hide
      Parameters:
      player - target player
      Returns:
      hide
    • show

      public boolean show(@NotNull @NotNull org.bukkit.entity.Player player)
      Shows this tracker to some player
      Parameters:
      player - target player
      Returns:
      success
    • handleCloseEvent

      public void handleCloseEvent(@NotNull @NotNull BiConsumer<Tracker,Tracker.CloseReason> consumer)
    • isSpawned

      public boolean isSpawned(@NotNull @NotNull UUID uuid)
      Checks this player is spawned in this tracker
      Parameters:
      uuid - uuid
      Returns:
      is spawned
    • isSpawned

      public boolean isSpawned(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks this player is spawned in this tracker
      Parameters:
      player - player
      Returns:
      is spawned
    • renderer

      @NotNull public @NotNull ModelRenderer renderer()
      Gets the renderer of this tracker
      Returns:
      renderer
    • forRemoval

      @Internal public void forRemoval(boolean removal)
      Marks future will remove this tracker
      Parameters:
      removal - removal
    • forRemoval

      @Internal public boolean forRemoval()
      Checks this tracker is for removal
      Returns:
      for removal
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object