Particles
These types give a mod’s blocks particles the way vanilla’s blocks have them: leaves that fall
from a leaf block, particle types culled by the Particles option or always shown, their client
providers, a client particle a mod adds and then colors and sizes, and particles the server
shows to the players near a point. FallingLeaves and SimpleParticles make particle types
registered in common code; their providers are registered in client initialization.
At a glance
Section titled “At a glance”| Type | Summary | Status | Since | Side | Thread |
|---|---|---|---|---|---|
ClientParticles |
Client particles a mod adds and then adjusts. | Experimental | 2.17.0 | client | render |
FallingLeaves |
Leaves that drift down from a block, as vanilla cherry leaves do. | Experimental | 2.4.0 | both | render |
LeafFall |
The look and fall of a falling-leaf particle. | Experimental | 2.10.0 | client | any |
ParticleProviders |
Gives a particle type its client provider from a sprite set, including Stope’s falling leaves. | Experimental | 2.4.0 | client | setup |
ServerParticles |
Particles sent from the server. | Experimental | 2.15.0 | server | server |
SimpleParticles |
Particle types with no options. | Experimental | 2.17.0 | both | any |
Quick start
Section titled “Quick start”Register the particle type in common initialization with REGISTRAR, the mod’s Registrar.
The field is public because the client code below reads it from the mod’s client package:
public static final Registered<SimpleParticleType> MAPLE_LEAF = REGISTRAR.register(Registries.PARTICLE_TYPE, "maple_leaf", FallingLeaves::newType);Then, in client initialization:
ParticleProviders.fallingLeaves(MAPLE_LEAF);FallingLeaves
Section titled “FallingLeaves”Experimental · Since 2.4.0 · Side: both · Thread: render
FallingLeaves makes a leaf block drop drifting leaf particles, as cherry leaves do. With
MAPLE_LEAF from the quick start, the leaf block emits it:
@Overridepublic void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { super.animateTick(state, level, pos, random); FallingLeaves.animateTick(level, pos, random, MAPLE_LEAF.get(), FallingLeaves.CHERRY_CHANCE);}ParticleProviders
Section titled “ParticleProviders”LeafFall: Experimental · Since 2.10.0 · Side: client · Thread: any
ParticleProviders: Experimental · Since 2.4.0 · Side: client · Thread: setup
ParticleProviders tells the client how to draw a mod’s particle types;
ParticleProviders#fallingLeaves draws a type made by FallingLeaves, as the
quick start shows. Leaves that should fall slower than cherry leaves, or share one gray sprite, take a LeafFall
in place of the call above. In client initialization, with MAPLE_PETAL, a second type
registered as MAPLE_LEAF is:
ParticleProviders.fallingLeaves(MAPLE_PETAL, LeafFall.asCherry().tinted(0xFFB7C5).fallSpeed(0.5f));ServerParticles
Section titled “ServerParticles”Experimental · Since 2.15.0 · Side: server · Thread: server
ServerParticles shows particles from the server to every player near a point, as a machine’s
warning puff. In a block entity’s server tick, with overloaded, the machine’s own state, and
smokeAt, a Vec3 field the block entity sets once to the point above its top, so the tick
makes no position:
if (overloaded && level instanceof ServerLevel server) { ServerParticles.send(server, ParticleTypes.SMOKE, smokeAt, 4);}See also
Section titled “See also”- Block rendering: how a block is drawn.
- Registration and ids: registering the particle types these calls take.
- Client events:
ParticleSpawnCallback, whichClientParticles#spawnasks before it adds a particle.