mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-08-08 05:22:58 +00:00
Add editable names for effects/styles. Remove cos/sin caching
This commit is contained in:
parent
2303696a09
commit
99b2e3796a
35 changed files with 339 additions and 354 deletions
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
import org.bukkit.Location;
|
||||
|
||||
public class ParticleStyleInvocation extends DefaultParticleStyle {
|
||||
|
||||
|
||||
private int points = 6;
|
||||
private double radius = 3.5;
|
||||
private double step = 0;
|
||||
|
@ -22,75 +22,75 @@ public class ParticleStyleInvocation extends DefaultParticleStyle {
|
|||
|
||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||
List<PParticle> particles = new ArrayList<>();
|
||||
double speed = getSpeedByEffect(particle.getEffect());
|
||||
|
||||
double speed = this.getSpeedByEffect(particle.getEffect());
|
||||
|
||||
// Circle around everything, spawn less often
|
||||
if (circleStep % 5 == 0) {
|
||||
for (int i = 0; i < numSteps; i++) {
|
||||
double dx = Math.cos(Math.PI * 2 * ((double)i / numSteps)) * radius;
|
||||
if (this.circleStep % 5 == 0) {
|
||||
for (int i = 0; i < this.numSteps; i++) {
|
||||
double dx = Math.cos(Math.PI * 2 * ((double) i / this.numSteps)) * this.radius;
|
||||
double dy = -0.9;
|
||||
double dz = Math.sin(Math.PI * 2 * ((double)i / numSteps)) * radius;
|
||||
double dz = Math.sin(Math.PI * 2 * ((double) i / this.numSteps)) * this.radius;
|
||||
particles.add(new PParticle(location.clone().add(dx, dy, dz)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Orbit going clockwise
|
||||
for (int i = 0; i < points; i++) {
|
||||
double dx = Math.cos(step + (Math.PI * 2 * ((double)i / points))) * radius;
|
||||
for (int i = 0; i < this.points; i++) {
|
||||
double dx = Math.cos(this.step + (Math.PI * 2 * ((double) i / this.points))) * this.radius;
|
||||
double dy = -0.9;
|
||||
double dz = Math.sin(step + (Math.PI * 2 * ((double)i / points))) * radius;
|
||||
double dz = Math.sin(this.step + (Math.PI * 2 * ((double) i / this.points))) * this.radius;
|
||||
double angle = Math.atan2(dz, dx);
|
||||
double xAng = -Math.cos(angle);
|
||||
double zAng = -Math.sin(angle);
|
||||
particles.add(new PParticle(location.clone().add(dx, dy, dz), xAng, 0, zAng, speed, true));
|
||||
}
|
||||
|
||||
|
||||
// Orbit going counter-clockwise
|
||||
for (int i = 0; i > -points; i--) {
|
||||
double dx = Math.cos(-step + (Math.PI * 2 * ((double)i / points))) * radius;
|
||||
for (int i = 0; i > -this.points; i--) {
|
||||
double dx = Math.cos(-this.step + (Math.PI * 2 * ((double) i / this.points))) * this.radius;
|
||||
double dy = -0.9;
|
||||
double dz = Math.sin(-step + (Math.PI * 2 * ((double)i / points))) * radius;
|
||||
double dz = Math.sin(-this.step + (Math.PI * 2 * ((double) i / this.points))) * this.radius;
|
||||
double angle = Math.atan2(dz, dx);
|
||||
double xAng = -Math.cos(angle);
|
||||
double zAng = -Math.sin(angle);
|
||||
particles.add(new PParticle(location.clone().add(dx, dy, dz), xAng, 0, zAng, speed, true));
|
||||
}
|
||||
|
||||
|
||||
return particles;
|
||||
}
|
||||
|
||||
|
||||
private double getSpeedByEffect(ParticleEffect effect) {
|
||||
switch (effect) {
|
||||
case CRIT:
|
||||
case DAMAGE_INDICATOR:
|
||||
case ENCHANTED_HIT:
|
||||
return 2;
|
||||
case DRAGON_BREATH:
|
||||
return 0.01;
|
||||
case ENCHANT:
|
||||
case NAUTILUS:
|
||||
case PORTAL:
|
||||
return radius * 2;
|
||||
case END_ROD:
|
||||
case SMOKE:
|
||||
case SQUID_INK:
|
||||
return 0.3;
|
||||
case FIREWORK:
|
||||
case SPIT:
|
||||
case SPLASH:
|
||||
return 0.5;
|
||||
case POOF:
|
||||
return 0.4;
|
||||
case TOTEM_OF_UNDYING:
|
||||
return 1.25;
|
||||
default:
|
||||
return 0.2; // Flame
|
||||
case CRIT:
|
||||
case DAMAGE_INDICATOR:
|
||||
case ENCHANTED_HIT:
|
||||
return 2;
|
||||
case DRAGON_BREATH:
|
||||
return 0.01;
|
||||
case ENCHANT:
|
||||
case NAUTILUS:
|
||||
case PORTAL:
|
||||
return radius * 2;
|
||||
case END_ROD:
|
||||
case SMOKE:
|
||||
case SQUID_INK:
|
||||
return 0.3;
|
||||
case FIREWORK:
|
||||
case SPIT:
|
||||
case SPLASH:
|
||||
return 0.5;
|
||||
case POOF:
|
||||
return 0.4;
|
||||
case TOTEM_OF_UNDYING:
|
||||
return 1.25;
|
||||
default:
|
||||
return 0.2; // Flame
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTimers() {
|
||||
step = (step + Math.PI * 2 / numSteps) % numSteps;
|
||||
circleStep = (circleStep + 1) % numSteps;
|
||||
this.step = (this.step + Math.PI * 2 / this.numSteps) % this.numSteps;
|
||||
this.circleStep = (this.circleStep + 1) % this.numSteps;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue