Dieser Commit ist enthalten in:
Ursprung
9576843d83
Commit
0f8a1757eb
41
src/de/steamwar/lobby/otherparticle/WingDesign.java
Normale Datei
41
src/de/steamwar/lobby/otherparticle/WingDesign.java
Normale Datei
@ -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");
|
||||||
|
}
|
36
src/de/steamwar/lobby/otherparticle/elements/Wing.java
Normale Datei
36
src/de/steamwar/lobby/otherparticle/elements/Wing.java
Normale Datei
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren