13
0

Add Wing
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-04-04 10:03:51 +02:00
Ursprung 9576843d83
Commit 0f8a1757eb
2 geänderte Dateien mit 77 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,41 @@
package de.steamwar.lobby.otherparticle;
import de.steamwar.lobby.particle.decorator.WingParticle;
import lombok.SneakyThrows;
import org.bukkit.util.Vector;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public interface WingDesign {
@SneakyThrows
static Vector[] create(String resource) {
List<Vector> vectors = new ArrayList<>();
BufferedImage bufferedImage = ImageIO.read(WingParticle.class.getResourceAsStream(resource));
for (int x = 0; x < bufferedImage.getWidth(); x++) {
for (int y = 0; y < bufferedImage.getHeight(); y++) {
int rgb = bufferedImage.getRGB(x, y);
if (Color.WHITE.getRGB() != rgb) {
vectors.add(new Vector(x - bufferedImage.getWidth() / 2.0, bufferedImage.getHeight() - y - 1.0, 0));
}
}
}
return vectors.toArray(new Vector[0]);
}
Vector[] getVectors();
WingDesign SIMPLE = () -> create("/de/steamwar/lobby/particle/decorator/WingSimple4.png");
WingDesign COMPLEX = () -> create("/de/steamwar/lobby/particle/decorator/WingSimple2.png");
WingDesign SWORD = () -> create("/de/steamwar/lobby/particle/decorator/WingSword.png");
WingDesign SW = () -> create("/de/steamwar/lobby/particle/decorator/WingSW.png");
WingDesign WGS = () -> create("/de/steamwar/lobby/particle/decorator/WingWGS.png");
WingDesign SWORD_CROSSED = () -> create("/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png");
WingDesign MWGL = () -> create("/de/steamwar/lobby/particle/decorator/MWGL.png");
WingDesign ECLIPSE = () -> create("/de/steamwar/lobby/particle/decorator/ECLIPSE-Logo.png");
}

Datei anzeigen

@ -0,0 +1,36 @@
package de.steamwar.lobby.otherparticle.elements;
import de.steamwar.lobby.otherparticle.ParticleElement;
import de.steamwar.lobby.otherparticle.ParticleTickData;
import de.steamwar.lobby.otherparticle.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.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);
}
}
}