Skip to content

Commit 4caa694

Browse files
committed
Improve docs and +getRotationOrder()
1 parent 426823b commit 4caa694

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

src/main/java/com/cryptomorin/xseries/particles/ParticleDisplay.java

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@
4444
import java.util.function.Supplier;
4545

4646
/**
47-
* By default the particle xyz offsets and speed aren't 0, but
47+
* Represents how particles should be spawned. The simplest use case would be the following code
48+
* which spawns a single particle in front of the player:
49+
* <pre>{@code
50+
* ParticleDisplay.of(Particle.FLAME).spawn(player.getEyeLocation());
51+
* }</pre>
52+
* This class is disposable by {@link XParticle} methods.
53+
* It should not be used across multiple methods. I.e. it should not be
54+
* used even to spawn a simple particle after it was used by one of {@link XParticle} methods.
55+
* <p>
56+
* By default, the particle xyz offsets and speed aren't 0, but
4857
* everything will be 0 by default in this class.
4958
* Particles are spawned to a location. So all the nearby players can see it.
5059
* <p>
51-
* The fields of this class are publicly accessible for ease of use.
52-
* All the fields can be null except the particle type.
53-
* <p>
5460
* For cross-version compatibility, instead of Bukkit's {@link org.bukkit.Color}
5561
* the java awt {@link Color} class is used.
5662
* <p>
@@ -60,7 +66,7 @@
6066
* <code>[r, g, b, size]</code>
6167
*
6268
* @author Crypto Morin
63-
* @version 8.0.0
69+
* @version 8.1.0
6470
* @see XParticle
6571
*/
6672
public class ParticleDisplay implements Cloneable {
@@ -100,6 +106,11 @@ public class ParticleDisplay implements Cloneable {
100106
*/
101107
private final Vector directionNormal = new Vector(0, 1, 0);
102108
private Supplier<Vector> direction = () -> directionNormal;
109+
/**
110+
* The xyz axis order of how the particle's matrix should be rotated.
111+
* Yes, it matters which axis you rotate first as it'll have an impact on the
112+
* other rotations.
113+
*/
103114
@Nonnull
104115
private Axis[] rotationOrder = DEFAULT_ROTATION_ORDER;
105116
@Nullable
@@ -505,6 +516,7 @@ public static Vector rotateAround(@Nonnull Vector location, double x, double y,
505516

506517
/**
507518
* Rotates the given location vector around a certain axis.
519+
* It simply uses the <a href="https://en.wikipedia.org/wiki/Rotation_matrix">rotation matrix</a>.
508520
*
509521
* @param location the location to rotate.
510522
* @param axis the axis to rotate the location around.
@@ -840,10 +852,7 @@ public ParticleDisplay withLocationCaller(@Nullable Callable<Location> locationC
840852
}
841853

842854
/**
843-
* Sets the rotation order that the particles should be rotated.
844-
* Yes,it matters which axis you rotate first as it'll have an impact on the
845-
* other rotations.
846-
*
855+
* @see #rotationOrder
847856
* @since 7.0.0
848857
*/
849858
public ParticleDisplay rotationOrder(@Nonnull Axis first, @Nonnull Axis second, @Nonnull Axis third) {
@@ -855,8 +864,21 @@ public ParticleDisplay rotationOrder(@Nonnull Axis first, @Nonnull Axis second,
855864
return this;
856865
}
857866

867+
/**
868+
* This array should not be modified directed at all. Use {@link #rotationOrder(Axis, Axis, Axis)} instead.
869+
* @see #rotationOrder
870+
* @since 8.1.0
871+
*/
872+
@Nonnull
873+
public Axis[] getRotationOrder() {
874+
return rotationOrder;
875+
}
876+
858877
/**
859878
* Gets the location of an entity if specified or the constant location.
879+
* <p>
880+
* This method is usually the center of the shape if the algorithm which uses
881+
* it supports the use of {@link #advanceInDirection(double)}.
860882
*
861883
* @return the location of the particle.
862884
* @since 3.1.0
@@ -1054,6 +1076,7 @@ public ParticleDisplay cloneWithLocation(double x, double y, double z) {
10541076
public ParticleDisplay clone() {
10551077
ParticleDisplay display = ParticleDisplay.of(particle)
10561078
.withLocationCaller(locationCaller)
1079+
.withDirection(direction)
10571080
.withCount(count).offset(offset.clone())
10581081
.forceSpawn(force).onSpawn(onSpawn);
10591082

0 commit comments

Comments
 (0)