Class ParticleEffect
java.lang.Object
com.destroystokyo.paper.ParticleBuilder
org.skriptlang.skript.bukkit.particles.particleeffects.ParticleEffect
- All Implemented Interfaces:
Debuggable,Cloneable
- Direct Known Subclasses:
ConvergingEffect,DirectionalEffect,ScalableEffect
A wrapper around Paper's ParticleBuilder to provide additional functionality
and a more fluent API for spawning particle effects. Categories of particles
with special behaviors may extend this class.
Particle behavior depends a lot on whether the count is zero or not. If count is zero, the offset and extra parameters are used to define a normal distribution for randomly offsetting particle positions. If count is greater than zero, the offset may be used for a number of special behaviors depending on the particle type. For example,
Particle behavior depends a lot on whether the count is zero or not. If count is zero, the offset and extra parameters are used to define a normal distribution for randomly offsetting particle positions. If count is greater than zero, the offset may be used for a number of special behaviors depending on the particle type. For example,
DirectionalEffects will use the offset as a velocity vector, multiplied
by the extra parameter. ScalableEffects will use the offset to determine scale.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedParticleEffect(org.bukkit.Particle particle) Internal constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsData(@Nullable Object data) Helper method to check if this effect accepts the provided data.copy()count(int count) <T> ParticleEffectdata(T data) Class<?> dataType()Alias forthis.particle().getDataType()org.joml.Vector3dAn alias for the offset.distribution(org.joml.Vector3d distribution) Sets the distribution for this particle.extra(double extra) force(boolean force) static String @NotNull []Gets all particle names that do not require data.booleanlocation(org.bukkit.Location location) location(org.bukkit.World world, double x, double y, double z) static @NotNull ParticleEffectof(@NotNull com.destroystokyo.paper.ParticleBuilder builder) Creates the appropriate ParticleEffect with the properties of the providedParticleBuilderstatic @NotNull ParticleEffectof(org.bukkit.Particle particle) Creates the appropriate ParticleEffect subclass based on the particle type.org.joml.Vector3doffset()offset(double offsetX, double offsetY, double offsetZ) offset(@NotNull org.joml.Vector3d offset) Set the offset from a JOML vectorstatic @Nullable ParticleEffectparse(String input, ParseContext context) Parses a particle effect from a string input.particle(org.bukkit.Particle particle) receivers(int radius) receivers(int radius, boolean byDistance) receivers(int xzRadius, int yRadius) receivers(int xzRadius, int yRadius, boolean byDistance) receivers(int xRadius, int yRadius, int zRadius) receivers(@Nullable Collection<org.bukkit.entity.Player> receivers) receivers(org.bukkit.entity.Player @Nullable ... receivers) receivers(@NotNull org.joml.Vector3d radii) Set the receiver radii from a JOML vector.receivers(@NotNull org.joml.Vector3i radii) Set the receiver radii from a JOML vectorsource(@Nullable org.bukkit.entity.Player source) spawn()spawn(org.bukkit.Location location) Ease of use method to spawn at a location.toString()Should returntoString(null, false)toString(@Nullable org.bukkit.event.Event event, boolean debug) static StringtoString(org.bukkit.Particle particle, int flags) Converts a Particle to its string representation.Methods inherited from class com.destroystokyo.paper.ParticleBuilder
clone, color, color, color, color, color, colorTransition, colorTransition, colorTransition, colorTransition, count, data, extra, force, hasReceivers, location, offsetX, offsetY, offsetZ, particle, receivers, source
-
Constructor Details
-
ParticleEffect
protected ParticleEffect(org.bukkit.Particle particle) Internal constructor. Useof(Particle)instead.- Parameters:
particle- The particle type
-
-
Method Details
-
of
@Contract("_ -> new") @NotNull public static @NotNull ParticleEffect of(org.bukkit.Particle particle) Creates the appropriate ParticleEffect subclass based on the particle type.- Parameters:
particle- The particle type- Returns:
- The appropriate ParticleEffect instance
-
of
@Contract("_ -> new") @NotNull public static @NotNull ParticleEffect of(@NotNull @NotNull com.destroystokyo.paper.ParticleBuilder builder) Creates the appropriate ParticleEffect with the properties of the providedParticleBuilder- Parameters:
builder- The builder to copy values from- Returns:
- The appropriate ParticleEffect instance with the properties copied from the builder
-
parse
Parses a particle effect from a string input. Prints errors if the particle requires data.- Parameters:
input- the input stringcontext- the parse context- Returns:
- the parsed ParticleEffect, or null if parsing failed
-
toString
Converts a Particle to its string representation.- Parameters:
particle- the particleflags- parsing flags- Returns:
- the string representation
-
getAllNamesWithoutData
Gets all particle names that do not require data.- Returns:
- array of particle names
-
spawn
- Overrides:
spawnin classcom.destroystokyo.paper.ParticleBuilder
-
spawn
Ease of use method to spawn at a location. Modifies the location value of this effect.- Parameters:
location- the location to spawn at.- Returns:
- This effect, with the location value modified.
-
offset
public org.joml.Vector3d offset()- Returns:
- The offset of this particle as a JOML vector
-
offset
Set the offset from a JOML vector- Parameters:
offset- the new offset- Returns:
- This effect, with the offset modified.
-
receivers
Set the receiver radii from a JOML vector- Parameters:
radii- the new radii to check for receivers in- Returns:
- This effect, with the receivers modified.
-
receivers
Set the receiver radii from a JOML vector. Values are truncated to ints.- Parameters:
radii- the new radii to check for receivers in- Returns:
- This effect, with the receivers modified.
-
isUsingNormalDistribution
public boolean isUsingNormalDistribution()- Returns:
- Whether this effect will use its offset value as a normal distribution (count > 0)
-
distribution
public org.joml.Vector3d distribution()An alias for the offset. Prefer using this when working with particles that have counts greater than 0. WhenisUsingNormalDistribution()is false, the returned value will not be the distribution and will instead depend on the particle's specific behavior when count = 0.- Returns:
- the distribution of this particle. The distribution is defined as 3 normal distributions in the x/y/z axes, with the returned vector containing the standard deviations. The mean will always be 0.
-
distribution
Sets the distribution for this particle. The distribution is defined as 3 normal distributions in the x/y/z axes, with the provided vector containing the standard deviations. The mean will always be 0. Sets the count to 1 if it was 0.- Parameters:
distribution- The new standard deviations to use.
-
data
- Overrides:
datain classcom.destroystokyo.paper.ParticleBuilder
-
acceptsData
Helper method to check if this effect accepts the provided data. Depends on the current particle.- Parameters:
data- The data to check.- Returns:
- Whether the data is of the right class.
-
dataType
Alias forthis.particle().getDataType()- Returns:
- The data type of the current particle.
-
copy
- Returns:
- a copy of this effect.
-
toString
Description copied from interface:DebuggableShould returntoString(null, false)- Specified by:
toStringin interfaceDebuggable- Overrides:
toStringin classObject
-
toString
- Specified by:
toStringin interfaceDebuggable- Parameters:
event- The event to get information from. This is always null if debug == false.debug- If true this should print more information, if false this should print what is shown to the end user- Returns:
- String representation of this object
-
particle
- Overrides:
particlein classcom.destroystokyo.paper.ParticleBuilder
-
allPlayers
- Overrides:
allPlayersin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
receivers
- Overrides:
receiversin classcom.destroystokyo.paper.ParticleBuilder
-
source
- Overrides:
sourcein classcom.destroystokyo.paper.ParticleBuilder
-
location
- Overrides:
locationin classcom.destroystokyo.paper.ParticleBuilder
-
location
- Overrides:
locationin classcom.destroystokyo.paper.ParticleBuilder
-
count
- Overrides:
countin classcom.destroystokyo.paper.ParticleBuilder
-
offset
- Overrides:
offsetin classcom.destroystokyo.paper.ParticleBuilder
-
extra
- Overrides:
extrain classcom.destroystokyo.paper.ParticleBuilder
-
force
- Overrides:
forcein classcom.destroystokyo.paper.ParticleBuilder
-