java.lang.Object
me.emafire003.dev.particleanimationlib.Effect
Direct Known Subclasses:
AnimatedBallEffect, SphereEffect, TargetedEffect, YPREffect

public class Effect extends Object
  • Field Details

    • iterations

      protected int iterations
    • originPos

      protected net.minecraft.util.math.Vec3d originPos
    • updatePositions

      protected boolean updatePositions
    • useEyePosAsOrigin

      protected boolean useEyePosAsOrigin
      If true and an entity is the origin it will use their head position if possible
    • entityOrigin

      protected net.minecraft.entity.Entity entityOrigin
    • originOffset

      protected net.minecraft.util.math.Vec3d originOffset
    • executeOnStop

      public EffectModifier executeOnStop
      A function that executes when the effect stops. For example, you could use it to chain effects one after the other
    • shouldSpawnParticlesEveryNIteration

      public boolean shouldSpawnParticlesEveryNIteration
      Set this to true to skip some iteration of particles spawning to save up on server and client resources
    • spawnParticlesEveryNIteration

      public int spawnParticlesEveryNIteration
      How many iterations to skip between a particle spawning and the other. By default, it's a quarter of a second Only works if shouldSpawnParticlesEveryNIteration is enabled
    • shouldLimitParticlesSpawnedPerIteration

      public boolean shouldLimitParticlesSpawnedPerIteration
      Set this to true to limit the max number of particles spawned each iteration, to save up on memory By default it's on and is capped at 5000 particles per tick. Which is a lot.
    • particleLimit

      public int particleLimit
      The limit of particles spawned at a given time (like on one iteration)
    • shouldLimitParticlesEveryNIterations

      public boolean shouldLimitParticlesEveryNIterations
      Limits the number of particles spawned every N iterations specified below
    • limitParticlesEveryNIterations

      public int limitParticlesEveryNIterations
      Every N iterations specified here the number of maximum particles spawned in that time frame is particleLimit
    • forced

      public boolean forced
      Weather or not the particles spawned have the "forced" property aka rendered much further away and bypass the option to not show them on the client
    • world

      protected net.minecraft.server.world.ServerWorld world
    • particle

      protected net.minecraft.particle.ParticleEffect particle
    • type

      public EffectType type
    • delay

      protected int delay
    • done

      protected boolean done
    • ticks

      protected int ticks
  • Constructor Details

    • Effect

      public Effect(net.minecraft.server.world.ServerWorld world, EffectType type, net.minecraft.particle.ParticleEffect particle, net.minecraft.util.math.Vec3d originPos)
  • Method Details

    • copy

      protected static void copy(Effect original, Effect copy)
    • onRun

      protected void onRun()
      Main method to extend, here the animation code is run EACH tick
    • onStop

      protected void onStop()
      Can be override to add a finishing effect i guess
    • getExecuteOnStop

      public EffectModifier getExecuteOnStop()
      A function that executes when the effect stops. For example you could use it to chain effects one after the other
    • setExecuteOnStop

      public void setExecuteOnStop(EffectModifier executeOnStop)
      Execute a function when the effect stops. For example you could use it to chain effects one after the other
    • getType

      public EffectType getType()
    • updatePos

      public void updatePos()
    • runFor

      public void runFor(double seconds)
      Runs the effect for the specified amount of seconds You can do the same thing by setting the number of iterations manually using setIterations(int). Each iteration is one tick, and 20 ticks are one second. Does not work with instant effects (wow eh?)
      Parameters:
      seconds - The number of seconds to run the effect for. Will be rounded to the closest tick number once calculated. For example 0.5 seconds will be 10 ticks, 0.01 seconds will be 0 ticks.
    • runFor

      public void runFor(double seconds, EffectModifier modifier)
      Runs the effect for the specified amount of seconds

      You can also provide a custom lambda function to modify the effect while it runs. You have access to the effect instance and the current tick

      You can do the same thing by setting the number of iterations manually using setIterations(int). Each iteration is one tick, and 20 ticks are one second.

      Does not work with instant effects (wow eh?)

      Parameters:
      seconds - The number of seconds to run the effect for. Will be rounded to the closest tick number once calculated. For example 0.5 seconds will be 10 ticks, 0.01 seconds will be 0 ticks.
    • run

      public void run()
      Runs the effect
    • run

      public void run(EffectModifier modifier)
      Runs the effect, you can also provide a custom lambda function to modify the effect while it runs. You have access to the effect instance and the current tick
    • displayParticle

      public void displayParticle(net.minecraft.particle.ParticleEffect effect, net.minecraft.util.math.Vec3d pos)
      Needs to be overridden by the other classes Not yet ready, may be scrapped
    • displayParticle

      public void displayParticle(net.minecraft.util.math.Vec3d pos, int color, float size)
    • displayParticle

      public void displayParticle(net.minecraft.particle.ParticleEffect effect, net.minecraft.util.math.Vec3d pos, net.minecraft.util.math.Vec3d vel)
    • getIterations

      public int getIterations()
    • setIterations

      public void setIterations(int iterations)
    • getDelay

      public int getDelay()
    • setDelay

      public void setDelay(int delay)
    • getOriginPos

      @Nullable public @Nullable net.minecraft.util.math.Vec3d getOriginPos()
      Already sums the offsets!
    • setOriginPos

      public void setOriginPos(net.minecraft.util.math.Vec3d origin_pos)
    • isUpdatePositions

      public boolean isUpdatePositions()
    • setUpdatePositions

      public void setUpdatePositions(boolean updatePositions)
    • getEntityOrigin

      public net.minecraft.entity.Entity getEntityOrigin()
    • setEntityOrigin

      public void setEntityOrigin(net.minecraft.entity.Entity entityOrigin)
    • getOriginOffset

      public net.minecraft.util.math.Vec3d getOriginOffset()
    • setOriginOffset

      public void setOriginOffset(net.minecraft.util.math.Vec3d originOffset)
    • isUseEyePosAsOrigin

      public boolean isUseEyePosAsOrigin()
    • setUseEyePosAsOrigin

      public void setUseEyePosAsOrigin(boolean useEyePosAsOrigin)
    • getWorld

      public net.minecraft.server.world.ServerWorld getWorld()
    • getWorldRegistryKey

      public net.minecraft.registry.RegistryKey<net.minecraft.world.World> getWorldRegistryKey()
    • setWorld

      public void setWorld(net.minecraft.server.world.ServerWorld world)
    • getParticle

      public net.minecraft.particle.ParticleEffect getParticle()
    • setParticle

      public void setParticle(net.minecraft.particle.ParticleEffect particle)
    • getLimitParticlesEveryNIterations

      public int getLimitParticlesEveryNIterations()
    • setLimitParticlesEveryNIterations

      public void setLimitParticlesEveryNIterations(int limitParticlesEveryNIterations)
    • shouldLimitParticlesEveryNIterations

      public boolean shouldLimitParticlesEveryNIterations()
    • setShouldLimitParticlesEveryNIterations

      public void setShouldLimitParticlesEveryNIterations(boolean shouldLimitParticlesEveryNIterations)
    • getParticleLimit

      public int getParticleLimit()
    • setParticleLimit

      public void setParticleLimit(int particleLimit)
    • getSpawnParticlesEveryNIteration

      public int getSpawnParticlesEveryNIteration()
    • setSpawnParticlesEveryNIteration

      public void setSpawnParticlesEveryNIteration(int spawnParticlesEveryNIteration)
    • shouldSpawnParticlesEveryNIteration

      public boolean shouldSpawnParticlesEveryNIteration()
    • setShouldSpawnParticlesEveryNIteration

      public void setShouldSpawnParticlesEveryNIteration(boolean shouldSpawnParticlesEveryNIteration)
    • shouldLimitParticlesSpawnedPerIteration

      public boolean shouldLimitParticlesSpawnedPerIteration()
    • setShouldLimitParticlesSpawnedPerIteration

      public void setShouldLimitParticlesSpawnedPerIteration(boolean shouldLimitParticlesSpawnedPerIteration)
    • isForced

      public boolean isForced()
    • setForced

      public void setForced(boolean forced)