Skip to content

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.

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

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:

Register a falling-leaf particle type
public static final Registered<SimpleParticleType> MAPLE_LEAF =
REGISTRAR.register(Registries.PARTICLE_TYPE, "maple_leaf", FallingLeaves::newType);

Then, in client initialization:

Draw the falling-leaf particle on the client
ParticleProviders.fallingLeaves(MAPLE_LEAF);

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:

Drop leaves from a leaf block
@Override
public 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);
}

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:

Draw pink petals that fall at half a cherry leaf's rate
ParticleProviders.fallingLeaves(MAPLE_PETAL, LeafFall.asCherry().tinted(0xFFB7C5).fallSpeed(0.5f));

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:

Puff smoke over an overloaded machine
if (overloaded && level instanceof ServerLevel server) {
ServerParticles.send(server, ParticleTypes.SMOKE, smokeAt, 4);
}