Class ParticleBuilder
java.lang.Object
com.destroystokyo.paper.ParticleBuilder
- All Implemented Interfaces:
Cloneable
Helps prepare a particle to be sent to players.
Usage of the builder is preferred over the super long World.spawnParticle(Particle, List, Player, double, double, double, int, double, double, double, double, double, double, Object, boolean, Particle.RandomizationType) API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSends this particle to all players in the world.clone()color(int color) Sets the particle Color.color(int r, int g, int b) Sets the particle Color.color(int a, int r, int g, int b) Sets the particle Color.Sets the particle Color.Sets the particle Color and size or power.colorTransition(int fromRgb, int toRgb) Sets the particle Color Transition.colorTransition(int fromRed, int fromGreen, int fromBlue, int toRed, int toGreen, int toBlue) Sets the particle Color Transition.colorTransition(Color fromColor, Color toColor) Sets the particle Color Transition.colorTransition(Color fromColor, Color toColor, float size) Sets the particle Color Transition and size.intcount()count(int count) Sets the number of particles to spawn<T> @Nullable Tdata()Gets the particle custom data.<T> ParticleBuilderSets the particle custom data.doubleextra()Deprecated, for removal: This API element is subject to removal in a future version.extra(double extra) Deprecated, for removal: This API element is subject to removal in a future version.usespeed(double)insteadbooleanforce()force(boolean force) Sets whether the particle is forcefully shown to the player.booleanExample use:location()Sets the location of where to spawn the particleSets the location of where to spawn the particleoffset(double offsetX, double offsetY, double offsetZ) Sets the particle offset.doubleoffsetX()Particle offset X.doubleoffsetY()Particle offset Y.doubleoffsetZ()Particle offset Z.particle()Changes what particle will be sentGets the randomization type for the particle.randomizationType(Particle.RandomizationType randomizationType) Sets the randomization type for the particle.receivers(int radius) Selects all players within a cuboid selection around the particle location, within the specified bounding box.receivers(int radius, boolean byDistance) Selects all players within the specified radius around the particle location.receivers(int xzRadius, int yRadius) Selects all players within a cuboid selection around the particle location, within the specified bounding box.receivers(int xzRadius, int yRadius, boolean byDistance) Selects all players within the specified radius around the particle location.receivers(int xRadius, int yRadius, int zRadius) Selects all players within a cuboid selection around the particle location, within the specified bounding box.receivers(@Nullable Collection<Player> receivers) source()Sets the source of this particle for visibility concerns (Vanish API)spawn()Sends the particle to all receiving players (or all).speed(double speed) Sets the particle speed.speed(double speedX, double speedY, double speedZ) Sets the particle speed.doublespeedX()Particle speed X.doublespeedY()Particle speed Y.doublespeedZ()Particle speed Z.
-
Constructor Details
-
ParticleBuilder
-
-
Method Details
-
spawn
Sends the particle to all receiving players (or all). This method is safe to use Asynchronously- Returns:
- a reference to this object.
-
particle
- Returns:
- The particle going to be sent
-
particle
Changes what particle will be sent- Parameters:
particle- The particle- Returns:
- a reference to this object.
-
receivers
-
hasReceivers
public boolean hasReceivers()Example use:builder.receivers(16); if (builder.hasReceivers()) { sendParticleAsync(builder); }
- Returns:
- If this particle is going to be sent to someone
-
allPlayers
Sends this particle to all players in the world. This is rather silly, and you should likely not be doing this.Just be a logical person and use receivers by radius or collection.
- Returns:
- a reference to this object.
-
receivers
- Parameters:
receivers- List of players to receive this particle, or null for all players in the world- Returns:
- a reference to this object.
-
receivers
- Parameters:
receivers- List of players to receive this particle, or null for all players in the world- Returns:
- a reference to this object.
-
receivers
- Parameters:
receivers- List of players to receive this particle, or null for all players in the world- Returns:
- a reference to this object.
-
receivers
Selects all players within a cuboid selection around the particle location, within the specified bounding box. If you want a more spherical check, seereceivers(int, boolean)- Parameters:
radius- amount to add on all axis- Returns:
- a reference to this object.
-
receivers
Selects all players within the specified radius around the particle location. If byDistance is false, behavior uses cuboid selection the same asreceivers(int, int)If byDistance is true, radius is tested by distance in a spherical shape- Parameters:
radius- amount to add on each axisbyDistance- true to use a spherical radius, false to use a cuboid- Returns:
- a reference to this object.
-
receivers
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, seereceivers(int, int, boolean)If you want a more spherical check, seereceivers(int, boolean)- Parameters:
xzRadius- amount to add on the x/z axisyRadius- amount to add on the y axis- Returns:
- a reference to this object.
-
receivers
Selects all players within the specified radius around the particle location. If byDistance is false, behavior uses cuboid selection the same asreceivers(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.- Parameters:
xzRadius- amount to add on the x/z axisyRadius- amount to add on the y axisbyDistance- true to use a cylinder shape, false to use cuboid- Returns:
- a reference to this object.
- Throws:
IllegalStateException- if a location hasn't been specified yet
-
receivers
Selects all players within a cuboid selection around the particle location, within the specified bounding box. If you want a more cylinder check, seereceivers(int, int, boolean)If you want a more spherical check, seereceivers(int, boolean)- Parameters:
xRadius- amount to add on the x axisyRadius- amount to add on the y axiszRadius- amount to add on the z axis- Returns:
- a reference to this object.
-
source
-
source
Sets the source of this particle for visibility concerns (Vanish API)- Parameters:
source- The player who is considered the source- Returns:
- a reference to this object.
-
location
-
location
Sets the location of where to spawn the particle- Parameters:
location- The location of the particle- Returns:
- a reference to this object.
-
location
Sets the location of where to spawn the particle- Parameters:
world- World to spawn particle inx- X locationy- Y locationz- Z location- Returns:
- a reference to this object.
-
count
public int count()- Returns:
- Number of particles to spawn
-
count
Sets the number of particles to spawn- Parameters:
count- Number of particles- Returns:
- a reference to this object.
-
offsetX
public double offsetX()Particle offset X. Varies by particle on how this is used- Returns:
- Particle offset X.
-
offsetY
public double offsetY()Particle offset Y. Varies by particle on how this is used- Returns:
- Particle offset Y.
-
offsetZ
public double offsetZ()Particle offset Z. Varies by particle on how this is used- Returns:
- Particle offset Z.
-
offset
Sets the particle offset. Varies by particle on how this is used- Parameters:
offsetX- Particle offset XoffsetY- Particle offset YoffsetZ- Particle offset Z- Returns:
- a reference to this object.
-
extra
Deprecated, for removal: This API element is subject to removal in a future version.use one of thespeedmethods insteadGets the Particle extra data (speedX). Varies by particle on how this is used- Returns:
- the extra particle data
-
extra
Deprecated, for removal: This API element is subject to removal in a future version.usespeed(double)insteadSets the particle extra data. Varies by particle on how this is used- Parameters:
extra- the extra particle data- Returns:
- a reference to this object.
-
speedX
public double speedX()Particle speed X. Varies by particle on how this is used- Returns:
- the particle speed X
-
speedY
public double speedY()Particle speed Y. Varies by particle on how this is used- Returns:
- the particle speed Y
-
speedZ
public double speedZ()Particle speed Z. Varies by particle on how this is used- Returns:
- the particle speed Z
-
speed
Sets the particle speed. Varies by particle on how this is used- Parameters:
speed- Particle speed- Returns:
- a reference to this object.
-
speed
Sets the particle speed. Varies by particle on how this is used- Parameters:
speedX- Particle speed XspeedY- Particle speed YspeedZ- Particle speed Z- Returns:
- a reference to this object.
-
data
Gets the particle custom data. Varies by particle on how this is used- Type Parameters:
T- The Particle data type- Returns:
- the ParticleData for this particle
-
data
Sets the particle custom data. Varies by particle on how this is used- Type Parameters:
T- The Particle data type- Parameters:
data- The new particle data- Returns:
- a reference to this object.
-
force
public boolean force()- Returns:
- whether the particle is forcefully shown to players.
-
force
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.- Parameters:
force- true to force, false for normal- Returns:
- a reference to this object.
-
randomizationType
Gets the randomization type for the particle. This determines how the particle's position and velocity are randomized.- Returns:
- the randomization type for the particle
-
randomizationType
Sets the randomization type for the particle. This determines how the particle's position and velocity are randomized.- Parameters:
randomizationType- the new randomization type for the particle- Returns:
- a reference to this object.
-
color
Sets the particle Color. Only valid for particles with a data type ofColor,Particle.DustOptionsorParticle.Spell.- Parameters:
color- the new particle color- Returns:
- a reference to this object.
-
color
Sets the particle Color and size or power. Only valid for particles with a data type ofParticle.DustOptionsorParticle.Spell.- Parameters:
color- the new particle colorvalue- the size or power of the particle- Returns:
- a reference to this object.
-
color
Sets the particle Color. Only valid for particles with a data type ofColor,Particle.DustOptionsorParticle.Spell.- Parameters:
r- red color componentg- green color componentb- blue color component- Returns:
- a reference to this object.
-
color
Sets the particle Color. Only valid for particles with a data type ofColor,Particle.DustOptionsorParticle.Spell.This method detects if the provided color integer is in RGB or ARGB format. If the alpha channel is zero, it treats the color as RGB. Otherwise, it treats it as ARGB.
- Parameters:
color- an integer representing the color components. If the highest byte (alpha channel) is zero, the color is treated as RGB. Otherwise, it is treated as ARGB.- Returns:
- a reference to this object.
-
color
Sets the particle Color. Only valid for particles with a data type ofColor,Particle.DustOptionsorParticle.Spell.- Parameters:
a- alpha color componentr- red color componentg- green color componentb- blue color component- Returns:
- a reference to this object.
-
colorTransition
Sets the particle Color Transition. Only valid forParticle.DUST_COLOR_TRANSITION.- Parameters:
fromColor- the new particle from colortoColor- the new particle to color- Returns:
- a reference to this object.
- Throws:
IllegalArgumentException- if the particle builder'sparticle()isn'tParticle.DUST_COLOR_TRANSITION.
-
colorTransition
public ParticleBuilder colorTransition(int fromRed, int fromGreen, int fromBlue, int toRed, int toGreen, int toBlue) Sets the particle Color Transition. Only valid forParticle.DUST_COLOR_TRANSITION.- Parameters:
fromRed- red color component for the "from" colorfromGreen- green color component for the "from" colorfromBlue- blue color component for the "from" colortoRed- red color component for the to colortoGreen- green color component for the to colortoBlue- blue color component for the to color- Returns:
- a reference to this object.
- Throws:
IllegalArgumentException- if the particle builder'sparticle()isn'tParticle.DUST_COLOR_TRANSITION.
-
colorTransition
Sets the particle Color Transition. Only valid forParticle.DUST_COLOR_TRANSITION.- Parameters:
fromRgb- an integer representing the red, green, and blue color components for the "from" colortoRgb- an integer representing the red, green, and blue color components for the "to" color- Returns:
- a reference to this object.
- Throws:
IllegalArgumentException- if the particle builder'sparticle()isn'tParticle.DUST_COLOR_TRANSITION.
-
colorTransition
Sets the particle Color Transition and size. Only valid forParticle.DUST_COLOR_TRANSITION.- Parameters:
fromColor- the new particle color for the "from" color.toColor- the new particle color for the "to" color.size- the size of the particle- Returns:
- a reference to this object.
- Throws:
IllegalArgumentException- if the particle builder'sparticle()isn'tParticle.DUST_COLOR_TRANSITION.
-
clone
-
speedmethods instead