2020-05-06 11:48:49 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2018-05-01 02:32:15 +02:00
From: Aikar <aikar@aikar.co>
Date: Tue, 29 Aug 2017 23:58:48 -0400
Subject: [PATCH] Expand World.spawnParticle API and add Builder
Adds ability to control who receives it and who is the source/sender (vanish API)
the standard API is to send the packet to everyone in the world, which is ineffecient.
This adds a new Builder API which is much friendlier to use.
diff --git a/src/main/java/com/destroystokyo/paper/ParticleBuilder.java b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
new file mode 100644
2020-05-06 11:48:49 +02:00
index 0000000000000000000000000000000000000000..06f1602f5b327705f726d0a99dd6b95e1554d382
2018-05-01 02:32:15 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
2019-03-20 01:28:15 +01:00
@@ -0,0 +1,478 @@
2018-05-01 02:32:15 +02:00
+package com.destroystokyo.paper;
+
+import com.google.common.collect.Lists;
+import org.bukkit.Color;
+import org.bukkit.Location;
+import org.bukkit.Particle;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
2018-06-07 02:59:04 +02:00
+import org.bukkit.util.NumberConversions;
2018-05-01 02:32:15 +02:00
+
2018-06-07 02:59:04 +02:00
+import java.util.Collection;
2018-05-01 02:32:15 +02:00
+import java.util.List;
2019-03-20 01:28:15 +01:00
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
2018-05-01 02:32:15 +02:00
+
+/**
+ * Helps prepare a particle to be sent to players.
+ *
+ * Usage of the builder is preferred over the super long {@link World#spawnParticle(Particle, Location, int, double, double, double, double, Object)} API
+ */
+public class ParticleBuilder {
2019-03-20 01:28:15 +01:00
+
2018-05-01 02:32:15 +02:00
+ private Particle particle;
+ private List<Player> receivers;
+ private Player source;
+ private Location location;
+ private int count = 1;
+ private double offsetX = 0, offsetY = 0, offsetZ = 0;
+ private double extra = 1;
+ private Object data;
2018-08-14 07:42:31 +02:00
+ private boolean force = true;
2018-05-01 02:32:15 +02:00
+
2019-03-20 01:28:15 +01:00
+ public ParticleBuilder(@NotNull Particle particle) {
2018-05-01 02:32:15 +02:00
+ this.particle = particle;
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Sends the particle to all receiving players (or all). This method is safe to use
+ * Asynchronously
2018-08-16 13:20:58 +02:00
+ *
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder spawn() {
+ if (this.location == null) {
+ throw new IllegalStateException("Please specify location for this particle");
+ }
+ location.getWorld().spawnParticle(particle, receivers, source,
+ location.getX(), location.getY(), location.getZ(),
2018-08-14 07:42:31 +02:00
+ count, offsetX, offsetY, offsetZ, extra, data, force
2018-05-01 02:32:15 +02:00
+ );
+ return this;
+ }
+
+ /**
+ * @return The particle going to be sent
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public Particle particle() {
+ return particle;
+ }
+
+ /**
+ * Changes what particle will be sent
2019-03-20 01:28:15 +01:00
+ *
2018-05-01 02:32:15 +02:00
+ * @param particle The particle
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder particle(@NotNull Particle particle) {
2018-05-01 02:32:15 +02:00
+ this.particle = particle;
+ return this;
+ }
+
+ /**
+ * @return List of players who will receive the particle, or null for all in world
+ */
+ @Nullable
+ public List<Player> receivers() {
+ return receivers;
+ }
+
+ /**
2018-06-07 03:27:50 +02:00
+ * Example use:
+ *
2019-03-20 01:28:15 +01:00
+ * builder.receivers(16); if (builder.hasReceivers()) { sendParticleAsync(builder); }
+ *
2018-06-07 03:27:50 +02:00
+ * @return If this particle is going to be sent to someone
+ */
+ public boolean hasReceivers() {
2019-03-20 01:28:15 +01:00
+ return (receivers == null && !location.getWorld().getPlayers().isEmpty()) || (
+ receivers != null && !receivers.isEmpty());
2018-06-07 03:27:50 +02:00
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Sends this particle to all players in the world. This is rather silly and you should likely not
+ * be doing this.
2018-06-07 03:45:30 +02:00
+ *
+ * Just be a logical person and use receivers by radius or collection.
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder allPlayers() {
2019-03-20 01:28:15 +01:00
+ this.receivers = null;
+ return this;
2018-05-01 02:32:15 +02:00
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * @param receivers List of players to receive this particle, or null for all players in the
+ * world
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder receivers(@Nullable List<Player> receivers) {
2018-06-07 02:59:04 +02:00
+ // Had to keep this as we first made API List<> and not Collection, but removing this may break plugins compiled on older jars
+ // TODO: deprecate?
2018-06-07 03:27:50 +02:00
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
+ return this;
2018-06-07 02:59:04 +02:00
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * @param receivers List of players to receive this particle, or null for all players in the
+ * world
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-06-07 02:59:04 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-06-07 02:59:04 +02:00
+ public ParticleBuilder receivers(@Nullable Collection<Player> receivers) {
2018-05-01 02:32:15 +02:00
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
+ return this;
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * @param receivers List of players to be receive this particle, or null for all players in the
+ * world
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder receivers(@Nullable Player... receivers) {
2018-06-07 03:27:50 +02:00
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
2018-05-01 02:32:15 +02:00
+ return this;
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Selects all players within a cuboid selection around the particle location, within the
+ * specified bounding box. If you want a more spherical check, see {@link #receivers(int,
+ * boolean)}
2018-06-07 02:59:04 +02:00
+ *
+ * @param radius amount to add on all axis
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-06-07 02:59:04 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-06-07 02:59:04 +02:00
+ public ParticleBuilder receivers(int radius) {
+ return receivers(radius, radius);
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Selects all players within the specified radius around the particle location. If byDistance is
+ * false, behavior uses cuboid selection the same as {@link #receivers(int, int)} If byDistance is
+ * true, radius is tested by distance in a spherical shape
+ *
+ * @param radius amount to add on each axis
2018-06-07 02:59:04 +02:00
+ * @param byDistance true to use a spherical radius, false to use a cuboid
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-06-07 02:59:04 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-06-07 02:59:04 +02:00
+ public ParticleBuilder receivers(int radius, boolean byDistance) {
+ if (!byDistance) {
+ return receivers(radius, radius, radius);
+ } else {
+ this.receivers = Lists.newArrayList();
2019-03-20 01:28:15 +01:00
+ for (Player nearbyPlayer : location.getWorld()
+ .getNearbyPlayers(location, radius, radius, radius)) {
2018-06-07 02:59:04 +02:00
+ Location loc = nearbyPlayer.getLocation();
+ double x = NumberConversions.square(location.getX() - loc.getX());
+ double y = NumberConversions.square(location.getY() - loc.getY());
+ double z = NumberConversions.square(location.getZ() - loc.getZ());
+ if (Math.sqrt(x + y + z) > radius) {
+ continue;
+ }
+ this.receivers.add(nearbyPlayer);
+ }
+ return this;
+ }
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Selects all players within a cuboid selection around the particle location, within the
+ * specified bounding box. Allows specifying a different Y size than X and Z If you want a more
+ * cylinder check, see {@link #receivers(int, int, boolean)} If you want a more spherical check,
+ * see {@link #receivers(int, boolean)}
2018-06-07 02:59:04 +02:00
+ *
+ * @param xzRadius amount to add on the x/z axis
+ * @param yRadius amount to add on the y axis
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-06-07 02:59:04 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-06-07 02:59:04 +02:00
+ public ParticleBuilder receivers(int xzRadius, int yRadius) {
+ return receivers(xzRadius, yRadius, xzRadius);
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Selects all players within the specified radius around the particle location. If byDistance is
+ * false, behavior uses cuboid selection the same as {@link #receivers(int, int)} If byDistance is
+ * true, radius is tested by distance on the y plane and on the x/z plane, in a cylinder shape.
+ *
2018-06-07 02:59:04 +02:00
+ * @param xzRadius amount to add on the x/z axis
+ * @param yRadius amount to add on the y axis
+ * @param byDistance true to use a cylinder shape, false to use cuboid
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-06-07 02:59:04 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-06-07 02:59:04 +02:00
+ public ParticleBuilder receivers(int xzRadius, int yRadius, boolean byDistance) {
+ if (!byDistance) {
+ return receivers(xzRadius, yRadius, xzRadius);
+ } else {
+ this.receivers = Lists.newArrayList();
2019-03-20 01:28:15 +01:00
+ for (Player nearbyPlayer : location.getWorld()
+ .getNearbyPlayers(location, xzRadius, yRadius, xzRadius)) {
2018-06-07 02:59:04 +02:00
+ Location loc = nearbyPlayer.getLocation();
+ if (Math.abs(loc.getY() - this.location.getY()) > yRadius) {
+ continue;
+ }
+ double x = NumberConversions.square(location.getX() - loc.getX());
+ double z = NumberConversions.square(location.getZ() - loc.getZ());
+ if (x + z > NumberConversions.square(xzRadius)) {
+ continue;
+ }
+ this.receivers.add(nearbyPlayer);
+ }
+ return this;
+ }
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Selects all players within a cuboid selection around the particle location, within the
+ * specified bounding box. If you want a more cylinder check, see {@link #receivers(int, int,
+ * boolean)} If you want a more spherical check, see {@link #receivers(int, boolean)}
2018-06-07 02:59:04 +02:00
+ *
+ * @param xRadius amount to add on the x axis
+ * @param yRadius amount to add on the y axis
+ * @param zRadius amount to add on the z axis
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-06-07 02:59:04 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-06-07 02:59:04 +02:00
+ public ParticleBuilder receivers(int xRadius, int yRadius, int zRadius) {
+ if (location == null) {
+ throw new IllegalStateException("Please set location first");
+ }
+ return receivers(location.getWorld().getNearbyPlayers(location, xRadius, yRadius, zRadius));
+ }
+
+ /**
2018-05-01 02:32:15 +02:00
+ * @return The player considered the source of this particle (for Visibility concerns), or null
+ */
2019-03-20 01:28:15 +01:00
+ @Nullable
2018-05-01 02:32:15 +02:00
+ public Player source() {
+ return source;
+ }
+
+ /**
+ * Sets the source of this particle for visibility concerns (Vanish API)
2019-03-20 01:28:15 +01:00
+ *
2018-05-01 02:32:15 +02:00
+ * @param source The player who is considered the source
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder source(@Nullable Player source) {
2018-05-01 02:32:15 +02:00
+ this.source = source;
+ return this;
+ }
+
+ /**
+ * @return Location of where the particle will spawn
+ */
2019-03-20 01:28:15 +01:00
+ @Nullable
2018-05-01 02:32:15 +02:00
+ public Location location() {
+ return location;
+ }
+
+ /**
+ * Sets the location of where to spawn the particle
2019-03-20 01:28:15 +01:00
+ *
2018-05-01 02:32:15 +02:00
+ * @param location The location of the particle
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder location(@NotNull Location location) {
2018-05-01 02:32:15 +02:00
+ this.location = location.clone();
+ return this;
+ }
+
+ /**
+ * Sets the location of where to spawn the particle
2019-03-20 01:28:15 +01:00
+ *
2018-05-01 02:32:15 +02:00
+ * @param world World to spawn particle in
+ * @param x X location
+ * @param y Y location
+ * @param z Z location
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder location(@NotNull World world, double x, double y, double z) {
2018-05-01 02:32:15 +02:00
+ this.location = new Location(world, x, y, z);
+ return this;
+ }
+
+ /**
+ * @return Number of particles to spawn
+ */
+ public int count() {
+ return count;
+ }
+
+ /**
+ * Sets the number of particles to spawn
2019-03-20 01:28:15 +01:00
+ *
2018-05-01 02:32:15 +02:00
+ * @param count Number of particles
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder count(int count) {
+ this.count = count;
+ return this;
+ }
+
+ /**
+ * Particle offset X. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @return Particle offset X.
2018-05-01 02:32:15 +02:00
+ */
+ public double offsetX() {
+ return offsetX;
+ }
2019-03-20 01:28:15 +01:00
+
2018-05-01 02:32:15 +02:00
+ /**
+ * Particle offset Y. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @return Particle offset Y.
2018-05-01 02:32:15 +02:00
+ */
+ public double offsetY() {
+ return offsetY;
+ }
2019-03-20 01:28:15 +01:00
+
2018-05-01 02:32:15 +02:00
+ /**
+ * Particle offset Z. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @return Particle offset Z.
2018-05-01 02:32:15 +02:00
+ */
+ public double offsetZ() {
+ return offsetZ;
+ }
+
+ /**
+ * Sets the particle offset. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @param offsetX Particle offset X
+ * @param offsetY Particle offset Y
+ * @param offsetZ Particle offset Z
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder offset(double offsetX, double offsetY, double offsetZ) {
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ this.offsetZ = offsetZ;
+ return this;
+ }
+
+ /**
+ * Gets the Particle extra data. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @return the extra particle data
2018-05-01 02:32:15 +02:00
+ */
+ public double extra() {
+ return extra;
+ }
+
+ /**
+ * Sets the particle extra data. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @param extra the extra particle data
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder extra(double extra) {
+ this.extra = extra;
+ return this;
+ }
+
+ /**
+ * Gets the particle custom data. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @param <T> The Particle data type
+ * @return the ParticleData for this particle
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @Nullable
2018-05-01 02:32:15 +02:00
+ public <T> T data() {
+ //noinspection unchecked
+ return (T) data;
+ }
+
+ /**
+ * Sets the particle custom data. Varies by particle on how this is used
2019-03-20 01:28:15 +01:00
+ *
2018-08-16 13:20:58 +02:00
+ * @param data The new particle data
+ * @param <T> The Particle data type
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public <T> ParticleBuilder data(@Nullable T data) {
2018-05-01 02:32:15 +02:00
+ this.data = data;
+ return this;
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Sets whether the particle is forcefully shown to the player. If forced, the particle will show
+ * faraway, as far as the player's view distance allows. If false, the particle will show
+ * according to the client's particle settings.
2018-08-14 07:42:31 +02:00
+ *
+ * @param force true to force, false for normal
2018-08-16 13:20:58 +02:00
+ * @return a reference to this object.
2018-08-14 07:42:31 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-08-14 07:42:31 +02:00
+ public ParticleBuilder force(boolean force) {
+ this.force = force;
+ return this;
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Sets the particle Color. Only valid for REDSTONE.
+ *
2018-08-16 13:20:58 +02:00
+ * @param color the new particle color
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder color(@Nullable Color color) {
2018-09-09 01:52:56 +02:00
+ return color(color, 1);
+ }
+
+ /**
2019-03-20 01:28:15 +01:00
+ * Sets the particle Color and size. Only valid for REDSTONE.
+ *
2018-09-09 01:52:56 +02:00
+ * @param color the new particle color
+ * @param size the size of the particle
+ * @return a reference to this object.
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
+ public ParticleBuilder color(@Nullable Color color, float size) {
+ if (particle != Particle.REDSTONE && color != null) {
2018-09-09 01:52:56 +02:00
+ throw new IllegalStateException("Color may only be set on REDSTONE");
+ }
2019-03-20 01:28:15 +01:00
+
+ // We don't officially support reusing these objects, but here we go
+ if (color == null) {
+ if (data instanceof Particle.DustOptions) {
+ return data(null);
+ } else {
+ return this;
+ }
+ }
+
2018-09-09 01:52:56 +02:00
+ return data(new Particle.DustOptions(color, size));
2018-05-01 02:32:15 +02:00
+ }
+
+ /**
+ * Sets the particle Color.
2018-09-09 01:52:56 +02:00
+ * Only valid for REDSTONE.
2018-08-16 13:20:58 +02:00
+ * @param r red color component
+ * @param g green color component
+ * @param b blue color component
+ * @return a reference to this object.
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public ParticleBuilder color(int r, int g, int b) {
2018-09-09 01:52:56 +02:00
+ return color(Color.fromRGB(r, g, b));
2018-05-01 02:32:15 +02:00
+ }
+}
diff --git a/src/main/java/org/bukkit/Particle.java b/src/main/java/org/bukkit/Particle.java
2020-06-25 04:33:35 +02:00
index b32de827cf8d1780861c271b4215276fdaab7165..1020002ff7127877db2d7e096f2c521751bf13a7 100644
2018-05-01 02:32:15 +02:00
--- a/src/main/java/org/bukkit/Particle.java
+++ b/src/main/java/org/bukkit/Particle.java
2020-06-25 04:33:35 +02:00
@@ -106,6 +106,17 @@ public enum Particle {
2018-05-01 02:32:15 +02:00
return dataType;
}
2018-07-14 03:44:35 +02:00
2018-05-01 02:32:15 +02:00
+ // Paper start - Particle API expansion
+ /**
+ * Creates a {@link com.destroystokyo.paper.ParticleBuilder}
2018-08-16 13:20:58 +02:00
+ *
+ * @return a {@link com.destroystokyo.paper.ParticleBuilder} for the particle
2018-05-01 02:32:15 +02:00
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-05-01 02:32:15 +02:00
+ public com.destroystokyo.paper.ParticleBuilder builder() {
+ return new com.destroystokyo.paper.ParticleBuilder(this);
+ }
+ // Paper end
2018-07-14 03:44:35 +02:00
/**
* Options which can be applied to redstone dust particles - a particle
* color and size.
2018-05-01 02:32:15 +02:00
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
2021-02-21 21:55:01 +01:00
index ed7d484416f127467c2898411564937f256d8861..7a96670447fde144e2263d107771e01cd642aaf4 100644
2018-05-01 02:32:15 +02:00
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
2021-02-21 21:55:01 +01:00
@@ -2559,7 +2559,57 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad
2020-12-19 10:39:37 +01:00
* @param data the data to use for the particle or null,
2018-05-01 02:32:15 +02:00
* the type of this depends on {@link Particle#getDataType()}
*/
2019-03-20 01:28:15 +01:00
- public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data);
+ public default <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data) { spawnParticle(particle, null, null, x, y, z, count, offsetX, offsetY, offsetZ, extra, data, true); }// Paper start - Expand Particle API
2018-05-01 02:32:15 +02:00
+ /**
+ * Spawns the particle (the number of times specified by count)
+ * at the target location. The position of each particle will be
+ * randomized positively and negatively by the offset parameters
+ * on each axis.
+ *
+ * @param particle the particle to spawn
+ * @param receivers List of players to receive the particles, or null for all in world
+ * @param source Source of the particles to be used in visibility checks, or null if no player source
+ * @param x the position on the x axis to spawn at
+ * @param y the position on the y axis to spawn at
+ * @param z the position on the z axis to spawn at
+ * @param count the number of particles
+ * @param offsetX the maximum random offset on the X axis
+ * @param offsetY the maximum random offset on the Y axis
+ * @param offsetZ the maximum random offset on the Z axis
+ * @param extra the extra data for this particle, depends on the
+ * particle used (normally speed)
+ * @param data the data to use for the particle or null,
+ * the type of this depends on {@link Particle#getDataType()}
+ * @param <T> Type
+ */
2019-03-20 01:28:15 +01:00
+ public default <T> void spawnParticle(@NotNull Particle particle, @Nullable List<Player> receivers, @NotNull Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data) { spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, extra, data, true); }
2018-08-14 07:42:31 +02:00
+ /**
+ * Spawns the particle (the number of times specified by count)
+ * at the target location. The position of each particle will be
+ * randomized positively and negatively by the offset parameters
+ * on each axis.
+ *
+ * @param particle the particle to spawn
+ * @param receivers List of players to receive the particles, or null for all in world
+ * @param source Source of the particles to be used in visibility checks, or null if no player source
+ * @param x the position on the x axis to spawn at
+ * @param y the position on the y axis to spawn at
+ * @param z the position on the z axis to spawn at
+ * @param count the number of particles
+ * @param offsetX the maximum random offset on the X axis
+ * @param offsetY the maximum random offset on the Y axis
+ * @param offsetZ the maximum random offset on the Z axis
+ * @param extra the extra data for this particle, depends on the
+ * particle used (normally speed)
+ * @param data the data to use for the particle or null,
+ * the type of this depends on {@link Particle#getDataType()}
+ * @param <T> Type
+ * @param force allows the particle to be seen further away from the player
+ * and shows to players using any vanilla client particle settings
+ */
2019-03-20 01:28:15 +01:00
+ public <T> void spawnParticle(@NotNull Particle particle, @Nullable List<Player> receivers, @Nullable Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force);
2018-05-01 02:32:15 +02:00
+ // Paper end
2018-08-14 07:42:31 +02:00
+
2018-05-01 02:32:15 +02:00
2018-08-26 20:11:49 +02:00
/**
* Spawns the particle (the number of times specified by count)