Class ParticleControllerInstance

java.lang.Object
at.minecraftschurli.mods.arsmagicalegacy.api.client.particle.ParticleControllerInstance

public final class ParticleControllerInstance extends Object
An instance of a ParticleController, holding runtime context.
  • Field Details

    • particle

      public final ControlledParticle particle
    • controller

      public final ParticleController controller
    • caster

      public final @Nullable net.minecraft.world.entity.LivingEntity caster
    • directEntity

      public final @Nullable net.minecraft.world.entity.Entity directEntity
    • hitResult

      public final @Nullable net.minecraft.world.phys.HitResult hitResult
  • Constructor Details

    • ParticleControllerInstance

      public ParticleControllerInstance(ControlledParticle particle, ParticleController controller, @Nullable net.minecraft.world.entity.LivingEntity caster, @Nullable net.minecraft.world.entity.Entity directEntity, @Nullable net.minecraft.world.phys.HitResult hitResult)
      Parameters:
      particle - The ControlledParticle the controller belongs to.
      controller - The ParticleController to query for values.
      caster - The LivingEntity casting the Spell. May be null if this is not called from a spell cast.
      directEntity - The entity applying the Spell, e.g. a projectile. May or may not be identical to the caster. May be null if this is not called from a spell cast.
      hitResult - The HitResult of the spell cast. May be null if this is not called from a spell cast.
  • Method Details

    • tick

      public void tick()
      Ticks the instance.
    • finish

      public void finish()
      Marks the instance as finished and (if ParticleController.killOnFinish() is true) removes the particle.
    • isFinished

      public boolean isFinished()
      Returns:
      Whether the instance is marked as finished.
    • getTickCount

      public int getTickCount()
      Returns:
      The amount of ticks this instance has been active so far.
    • hasContext

      public boolean hasContext(String key)
      Parameters:
      key - The key of the context value to check.
      Returns:
      Whether the instance contains a context value by the given key.
    • getContext

      public <T> @Nullable T getContext(String key)
      Type Parameters:
      T - The type of the context value.
      Parameters:
      key - The key of the context value to get.
      Returns:
      The associated context value.
    • setContext

      public <T> void setContext(String key, T value)
      Puts an extra instance context value.
      Type Parameters:
      T - The type of the context value.
      Parameters:
      key - The key of the context value.
      value - The context value.
    • getTargetOrFinish

      public @Nullable net.minecraft.world.entity.Entity getTargetOrFinish()
      Tries to get the Entity from the HitResult. If unsuccessful, finishes the controller and returns null.
      Returns:
      The target Entity or null.
    • getLocationOrFinish

      public @Nullable net.minecraft.world.phys.Vec3 getLocationOrFinish()
      Tries to get the Entity from the HitResult. If unsuccessful, finishes the controller and returns null.
      Returns:
      The target Entity or null.