forked from SteamWar/SteamWar
57 lines
2.1 KiB
Java
57 lines
2.1 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.ParticleElement;
|
|
import de.steamwar.lobby.particle.ParticleTickData;
|
|
import de.steamwar.lobby.particle.WingDesign;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.util.Vector;
|
|
|
|
public class Wing extends DelegatingParticleElement {
|
|
|
|
private double size;
|
|
private WingDesign wingDesign;
|
|
|
|
public Wing(ParticleElement particleElement, double size, WingDesign wingDesign) {
|
|
super(particleElement);
|
|
this.size = size;
|
|
this.wingDesign = wingDesign;
|
|
}
|
|
|
|
@Override
|
|
public String attribute() {
|
|
return "PARTICLE_ATTRIBUTE_WING";
|
|
}
|
|
|
|
@Override
|
|
public void tick(ParticleTickData particleTickData) {
|
|
for (Vector dVector : wingDesign.getVectors()) {
|
|
Vector vector = new Vector(dVector.getX() * size, 0.6 + dVector.getY() * size - (particleTickData.getPlayer().isSneaking() ? 0.5 : 0), 0.5);
|
|
vector.rotateAroundY(Math.toRadians(particleTickData.getPlayer().getLocation().getYaw() * -1));
|
|
vector.setX(-vector.getX());
|
|
vector.setZ(-vector.getZ());
|
|
Location location = particleTickData.getPlayer().getLocation().clone().add(vector);
|
|
ParticleTickData current = particleTickData.withLocation(location);
|
|
particleElement.tick(current);
|
|
}
|
|
}
|
|
}
|