Add some of the Easter Particles

This commit is contained in:
2025-03-03 09:35:42 +01:00
parent 85c0db873c
commit 0a60654a28
16 changed files with 251 additions and 36 deletions
@@ -1,10 +1,13 @@
package de.steamwar.lobby.particle.elements;
import de.steamwar.lobby.particle.Gradient;
import de.steamwar.lobby.particle.ParticleElement;
import de.steamwar.lobby.particle.ParticleTickData;
import org.bukkit.Location;
import org.bukkit.Particle;
import java.awt.*;
public class DustParticle implements ParticleElement {
private Particle particle;
@@ -13,32 +16,44 @@ public class DustParticle implements ParticleElement {
private float vz = 0.01f;
private double speed = 0.01;
private int count = 5;
private Gradient gradient;
public DustParticle(Particle particle) {
public DustParticle(Particle particle, Gradient gradient) {
this.particle = particle;
this.gradient = gradient;
}
public DustParticle(Particle particle, float vx, float vy, float vz) {
public DustParticle(Particle particle, float vx, float vy, float vz, Gradient gradient) {
this.particle = particle;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.gradient = gradient;
}
public DustParticle(Particle particle, float vx, float vy, float vz, double speed, int count) {
public DustParticle(Particle particle, float vx, float vy, float vz, double speed, int count, Gradient gradient) {
this.particle = particle;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.speed = speed;
this.count = count;
this.gradient = gradient;
}
@Override
public void tick(ParticleTickData particleTickData) {
Location location = particleTickData.getLocation().add(0.0, 0.2, 0.0);
Particle.DustOptions dustOptions;
if (gradient != null) {
double result = particleTickData.getDeg() % 360;
Color color = gradient.getColor(result, 360);
dustOptions = withColor(color.getRed(), color.getGreen(), color.getBlue());
} else {
dustOptions = randomParticleDust();
}
display(location, particleTickData.getPlayer(), particleTickData.isOnlySelf(), particleTickData.isOnlyOthers(), player -> {
player.spawnParticle(particle, location, count, vx, vy, vz, speed, randomParticleDust());
player.spawnParticle(particle, location, count, vx, vy, vz, speed, dustOptions);
});
}
}
@@ -0,0 +1,61 @@
package de.steamwar.lobby.particle.elements;
import de.steamwar.lobby.particle.ParticleElement;
import de.steamwar.lobby.particle.ParticleTickData;
import de.steamwar.lobby.particle.ParticleTickType;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class TrippleCircle extends Circle {
private ParticleElement second;
private ParticleElement third;
private double distance;
private double speed;
public TrippleCircle(ParticleElement first, ParticleElement second, ParticleElement third) {
super(first);
this.second = second;
this.distance = 1;
this.speed = 1;
}
public TrippleCircle(ParticleElement first, ParticleElement second, ParticleElement third, double distance, double speed) {
super(first);
this.second = second;
this.distance = distance;
this.speed = speed;
}
@Override
public String attribute() {
return "PARTICLE_ATTRIBUTE_TRI_CIRCLE";
}
@Override
public ParticleTickType tickType() {
if (particleElement.tickType() == second.tickType() && particleElement.tickType() == third.tickType()) {
return particleElement.tickType();
}
return ParticleTickType.MOVE;
}
@Override
public void tick(ParticleTickData particleTickData) {
Location location = particleTickData.getLocation();
Vector vector = new Vector(distance, 0, 0);
vector.rotateAroundY((particleTickData.getDeg() * speed) % 360);
ParticleTickData nParticleTickData = particleTickData.withLocation(location.clone().add(vector));
particleElement.tick(nParticleTickData);
vector.rotateAroundY(120);
nParticleTickData = particleTickData.withLocation(location.clone().add(vector));
second.tick(nParticleTickData);
vector.rotateAroundY(120);
nParticleTickData = particleTickData.withLocation(location.clone().add(vector));
third.tick(nParticleTickData);
}
}
@@ -10,13 +10,15 @@ public class YOffset extends DelegatingParticleElement {
private double minY;
private double maxY;
private boolean inverted;
private boolean bounce;
public YOffset(ParticleElement particleElement, double speed, double minY, double maxY, boolean inverted) {
public YOffset(ParticleElement particleElement, double speed, double minY, double maxY, boolean inverted, boolean bounce) {
super(particleElement);
this.multiplication = speed;
this.minY = minY;
this.maxY = maxY;
this.inverted = inverted;
this.bounce = bounce;
}
@Override
@@ -26,19 +28,28 @@ public class YOffset extends DelegatingParticleElement {
@Override
public void tick(ParticleTickData particleTickData) {
double value = ((particleTickData.getDeg() * multiplication) % 360) / 180;
double y;
if (inverted) {
if (value <= 1) {
y = maxY - (maxY - minY) * value;
if (bounce) {
double value = ((particleTickData.getDeg() * multiplication) % 360) / 180;
if (inverted) {
if (value <= 1) {
y = maxY - (maxY - minY) * value;
} else {
y = minY + (maxY - minY) * (value - 1);
}
} else {
y = minY + (maxY - minY) * (value - 1);
if (value <= 1) {
y = minY + (maxY - minY) * value;
} else {
y = maxY - (maxY - minY) * (value - 1);
}
}
} else {
if (value <= 1) {
y = minY + (maxY - minY) * value;
double value = ((particleTickData.getDeg() * multiplication) % 360) / 360;
if (inverted) {
y = maxY - (maxY - minY) * value;
} else {
y = maxY - (maxY - minY) * (value - 1);
y = minY + (maxY - minY) * value;
}
}
ParticleTickData current = particleTickData.withLocation(particleTickData.getLocation().clone().add(0, y, 0));