PlayerParticles/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java

64 lines
2 KiB
Java
Raw Normal View History

package dev.esophose.playerparticles.styles;
2016-09-10 21:13:13 -07:00
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
2019-12-12 19:32:53 -07:00
import dev.esophose.playerparticles.particles.PParticle;
2020-01-05 17:26:45 -07:00
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.MathL;
import java.util.ArrayList;
import java.util.List;
2016-09-10 21:13:13 -07:00
import org.bukkit.Location;
public class ParticleStyleQuadhelix extends DefaultParticleStyle {
2016-09-10 21:13:13 -07:00
2018-10-13 16:38:01 -06:00
private static final int orbs = 4;
private static int maxStepX = 80;
private static int maxStepY = 60;
private int stepX = 0;
private int stepY = 0;
private boolean reverse = false;
public ParticleStyleQuadhelix() {
super("quadhelix", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
2019-12-12 19:32:53 -07:00
List<PParticle> particles = new ArrayList<>();
2018-10-13 16:38:01 -06:00
for (int i = 0; i < orbs; i++) {
double dx = -(MathL.cos((this.stepX / (double) maxStepX) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i))) * ((maxStepY - Math.abs(this.stepY)) / (double) maxStepY);
double dy = (this.stepY / (double) maxStepY) * 1.5;
double dz = -(MathL.sin((this.stepX / (double) maxStepX) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i))) * ((maxStepY - Math.abs(this.stepY)) / (double) maxStepY);
2018-10-06 21:41:39 -06:00
particles.add(new PParticle(location.clone().add(dx, dy, dz)));
}
return particles;
}
@Override
public void updateTimers() {
this.stepX++;
if (this.stepX > maxStepX) {
this.stepX = 0;
}
if (this.reverse) {
this.stepY++;
if (this.stepY > maxStepY)
this.reverse = false;
} else {
this.stepY--;
if (this.stepY < -maxStepY)
this.reverse = true;
}
}
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
@Override
protected void loadSettings(CommentedFileConfiguration config) {
2018-12-01 19:34:01 -07:00
}
2016-09-10 21:13:13 -07:00
}