Skip to content

Instantly share code, notes, and snippets.

@Exerosis
Created February 21, 2018 20:50
Show Gist options
  • Select an option

  • Save Exerosis/4b5b1f16ac413527ed0c5469844704f9 to your computer and use it in GitHub Desktop.

Select an option

Save Exerosis/4b5b1f16ac413527ed0c5469844704f9 to your computer and use it in GitHub Desktop.
public static class Particle {
private final String id;
private int count = 0;
private float data, x, y, z = 0;
public Particle(String id) {
this.id = id;
}
public static Particle create(String id) {
return new Particle(id);
}
@NotNull
public Particle color(@NotNull Color color) {
return color(color.getRed(), color.getGreen(), color.getBlue());
}
@NotNull
public Particle color(@NotNull Number red, @NotNull Number green, @NotNull Number blue) {
x = red.intValue() / 255f;
y = green.intValue() / 255f;
z = blue.intValue() / 255f;
return this;
}
@NotNull
public Particle offset(@NotNull Vector vector) {
x = (float) vector.getX();
y = (float) vector.getY();
z = (float) vector.getZ();
return this;
}
@NotNull
public Particle offset(@NotNull Number randSeed) {
return offset(randSeed, randSeed, randSeed);
}
@NotNull
public Particle offset(@NotNull Number x, @NotNull Number y, @NotNull Number z) {
this.x = x.floatValue();
this.y = y.floatValue();
this.z = z.floatValue();
return this;
}
@NotNull
public Particle data(float data) {
this.data = data;
return this;
}
@NotNull
public Particle count(@NotNull Number count) {
this.count = count.intValue();
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment