Particles
This guide explains how to spawn different types of particles.
There are two methods to spawn particles:
World.spawnParticle()
which spawns the particle for all players andPlayer.spawnParticle()
which spawns the particle only for the player.
Directional particles
Section titled “Directional particles”This type of particle has an initial velocity when spawned. The velocity can be determined in two different ways, however
both take into account the extra
argument as speed.
In the following example 8 flame particles are spawned in a 1x1x1 cube shape randomly, with someLocation
serving as it’s center.
The last argument (extra) is set to 0, so the particles don’t move.
someWorld.spawnParticle(Particle.FLAME, someLocation, 8, 0.5, 0.5, 0.5, 0);
Random direction
Section titled “Random direction”Setting the count
parameter to anything positive will yield a random direction for the velocity. The offset arguments are used as random
spawn offset from the location.
An example of spawning 6 crit particles at a location without offset that will move in a random direction at a slow speed:
someWorld.spawnParticle(Particle.CRIT, someLocation, 6, 0, 0, 0, 0.12);
Specified direction
Section titled “Specified direction”To specify the velocity’s direction, set the count
argument to 0
and use the offset arguments as the direction vector.
The extra
argument will server as the vector’s multiplier, scaling it.
So for example if we set offsets to 2.5, 1.2, 0.4
and extra
to 5
, the final velocity vector would be (12.5, 6, 2)
.
An example of a repeating task spawning campfire smoke that slowly goes “up” (positive Y axis):
Bukkit.getScheduler().runTaskTimer(plugin, () -> someWorld.spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE, someLocation, 0, 0, 1, 0, 0.1), 0, 4);
We could also make the smoke go down if we wanted to:
Bukkit.getScheduler().runTaskTimer(plugin, () -> someWorld.spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE, someLocation, 0, 0, -1, 0, 0.1), 0, 4);
List of directional particles
Section titled “List of directional particles”Show list
- BLOCK,
- BUBBLE,
- BUBBLE_COLUMN_UP,
- CAMPFIRE_COSY_SMOKE,
- CAMPFIRE_SIGNAL_SMOKE,
- CLOUD,
- CRIT,
- DAMAGE_INDICATOR,
- DRAGON_BREATH,
- DUST_PLUME,
- ELECTRIC_SPARK,
- ENCHANTED_HIT,
- END_ROD,
- FIREWORK,
- FLAME,
- FLASH,
- GLOW_SQUID_INK,
- LARGE_SMOKE,
- POOF,
- REVERSE_PORTAL,
- SCRAPE,
- SCULK_CHARGE,
- SCULK_CHARGE_POP,
- SCULK_SOUL,
- SHRIEK,
- SMALL_FLAME,
- SMOKE,
- SNEEZE,
- SNOWFLAKE,
- SOUL,
- SOUL_FIRE_FLAME,
- SPIT,
- SPLASH,
- SQUID_INK,
- TOTEM_OF_UNDYING,
- TRIAL_SPAWNER_DETECTION,
- TRIAL_SPAWNER_DETECTION_OMINOUS,
- WAX_OFF,
- WAX_ON,
- WHITE_SMOKE.
Colored particles
Section titled “Colored particles”Dust particles
Section titled “Dust particles”The only Vanilla dust particle is the redstone particle. However, you can easily create a custom colored one by passing
Particle.DustOptions as data
.
An example of creating a vertical line of green dust particles
for (double i = 0; i <= 1.0; i += 0.1) { someWorld.spawnParticle( Particle.DUST, someLocation.clone().add(0, i, 0), 1, new Particle.DustOptions(Color.GREEN, 1.0f) );}
Dust transition particles
Section titled “Dust transition particles”Dust transition particles work similarly to dust particles, but they transition their color
from one to another. This can be achieved by passing Particle.DustTransition
as data
.
An example where 3 dust transition particles spawn on the x-axis within a 1 block length:
someWorld.spawnParticle( Particle.DUST_COLOR_TRANSITION, someLocation, 3 0.5, 0, 0, new Particle.DustTransition(Color.RED, Color.BLUE, 1.0f));
Effect and entity effect particles
Section titled “Effect and entity effect particles”While having a similar name and sharing the texture, there is big difference between the two. EFFECT
can not
be colored, while ENTITY_EFFECT
can be.
An example of spawning a group of colored (gold) entity effect particles:
someWorld.spawnParticle(Particle.ENTITY_EFFECT, 8, 1, 0.25, 1, Color.fromRGB(255, 215, 0));
Note particles
Section titled “Note particles”The note particles have two different behaviors based on the count
argument.
- If set to a positive number a random color (of the preset 24) will be chosen for each spawned particle.
- If set to
0
, theoffsetX
argument will be used as an addition to a HSB (hue, saturation, brightness) color format’s hue value, which has a starting point at a green color.
Example:
someWorld.spawnParticle(Particle.NOTE, someLocation, 0, 0.4f, 0, 0);
Tinted leaves
Section titled “Tinted leaves”The TINTED_LEAVES
particle is really simple to spawn, as it only requires a Color
object
to be passed as the data
argument.
Example of spawning 10 orange leaves in a 4x4 area:
someWorld.spawnParticle(Particle.TINTED_LEAVES, someLocation, 10, 2, 0, 2, Color.fromRGB(191, 87, 0));
Converging particles
Section titled “Converging particles”As the name implies, this type of particle converges to a single point (location), which in this case is the supplied location.
The particles have two different behaviors based on the count
argument:
- If set to a positive number, offset arguments are used normally,
- If set to
0
, the offset arguments will be used for a relative spawn location from the supplied location/coordinates. The particle will then travel from this relative location to the supplied location in a curve.
An example where an enchantment particle will spawn at someLocation.clone().add(2,0,2)
and travel to someLocation
:
someWorld.spawnParticle(Particle.ENCHANT, someLocation, 0, 2, 0, 2);
List of converging particles
Section titled “List of converging particles”Show list
- ENCHANT,
- NAUTILUS,
- PORTAL.
Material particles
Section titled “Material particles”BlockData
Section titled “BlockData”To spawn particles that require BlockData
, simply put BlockData
as it’s data
argument.
Example:
someWorld.spawnParticle(Particle.BLOCK_CRUMBLE, someLocation, 4, BlockType.GLOWSTONE.createBlockData());
ItemStack
Section titled “ItemStack”To spawn particles that require an ItemStack
, simply put an ItemStack
as it’s data
argument.
Example:
someWorld.spawnParticle(Particle.ITEM, someLocation, 4, ItemType.DIAMOND_PICKAXE.createItemStack());
Sculk particles
Section titled “Sculk particles”Sculk charge
Section titled “Sculk charge”The SCULK_CHARGE
particle takes a Float
as it’s data
. This is used as the particle’s “roll” or more formally,
the angle the particle displays at in radians.
Example of spawning a sculk charge particle at 45°.
someWorld.spawnParticle(Particle.SCULK_CHARGE, 1, Float.valueOf(0.7853f));
Shriek
Section titled “Shriek”The SHRIEK
particle takes an Integer
as it’s data
. This is used to set the delay in ticks before the particle spawns.
It is completely up to your implementation when choosing to use data
or a scheduler.
Example where a shriek particle will spawn after one second:
someWorld.spawnParticle(Particle.SHRIEK, 1, Integer.valueOf(20));
Vibration
Section titled “Vibration”Vibration particles require you to pass a Vibration
object as data
, where you can choose between a
location (Vibration.Destination.BlockDestination
)
or an entity target (Vibration.Destination.EntityDestination
).
someWorld.spawnParticle( Particle.VIBRATION, someLocation, 1, new Vibration(new Vibration.Destination.BlockDestination(otherLocation), 10));
Trail particles
Section titled “Trail particles”Trail particles require you to pass a Particle.Trail
object as data
.
An example where 8 randomly offset trail particles move towards someLocation
, which is in the center of the spawning
bounding box in 10 ticks.
someWorld.spawnParticle( Particle.TRAIL, someLocation, 8, 2, 2, 2, new Particle.Trail(someLocation, Color.RED, 10));