Files
SteamWar/LobbySystem/src/de/steamwar/lobby/particle/elements/DustParticle.java
T
2025-10-23 17:56:43 +02:00

79 lines
2.7 KiB
Java

/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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;
private float vx = 0.01f;
private float vy = 0.01f;
private float vz = 0.01f;
private double speed = 0.01;
private int count = 5;
private Gradient gradient;
public DustParticle(Particle particle, Gradient gradient) {
this.particle = particle;
this.gradient = gradient;
}
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, 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() * 10) % 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, dustOptions);
});
}
}