From a49756ddaa8c5514c98d83dea6b9e31023291097 Mon Sep 17 00:00:00 2001 From: Electroblob <35599699+Electroblob77@users.noreply.github.com> Date: Sun, 24 Jun 2018 16:13:04 +0100 Subject: [PATCH] Add vector-based position and velocity methods to ParticleBuilder --- .../wizardry/util/ParticleBuilder.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/electroblob/wizardry/util/ParticleBuilder.java b/src/main/java/electroblob/wizardry/util/ParticleBuilder.java index 24bbae18..839dc831 100644 --- a/src/main/java/electroblob/wizardry/util/ParticleBuilder.java +++ b/src/main/java/electroblob/wizardry/util/ParticleBuilder.java @@ -6,6 +6,7 @@ import electroblob.wizardry.Wizardry; import net.minecraft.entity.Entity; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; /** @@ -184,6 +185,19 @@ public final class ParticleBuilder { return this; } + /** + * Sets the position of the particle being built. This is a vector-based alternative to {@link ParticleBuilder#pos( + * double, double, double)}, allowing for even more concise code when a vector is available. + *

+ * Affects: All particle types + * @param pos A vector representing the coordinates of the particle to be built. + * @return The particle builder instance, allowing other methods to be chained onto this one + * @throws IllegalStateException if the particle builder is not yet building. + */ + public ParticleBuilder pos(Vec3d pos){ + return pos(pos.x, pos.y, pos.z); + } + /** * Sets the velocity of the particle being built. If unspecified, this defaults to the particle's default velocity, * specified within its constructor. @@ -203,6 +217,19 @@ public final class ParticleBuilder { return this; } + /** + * Sets the velocity of the particle being built. This is a vector-based alternative to {@link ParticleBuilder#vel( + * double, double, double)}, allowing for even more concise code when a vector is available. + *

+ * Affects: All particle types + * @param vel A vector representing the velocity of the particle to be built. + * @return The particle builder instance, allowing other methods to be chained onto this one + * @throws IllegalStateException if the particle builder is not yet building. + */ + public ParticleBuilder vel(Vec3d vel){ + return vel(vel.x, vel.y, vel.z); + } + /** * Sets the colour of the particle being built. If unspecified, this defaults to the particle's default colour, * specified within its constructor.