Skip to main content
Version: 26.3

Particles

dev.architectury.registry.client.particle.ParticleProviderRegistry

Register the ParticleProvider that renders a custom particle type.

ParticleProviderRegistry provides four register overloads. They accept the particle type either as a RegistrySupplier or as a ParticleType<T>, and the provider either as a ParticleProvider<T> or as a DeferredParticleProvider<T>.

MethodParticle typeProvider
register(RegistrySupplier<? extends ParticleType<T>>, ParticleProvider<T>)RegistrySupplierDoes not use a sprite set
register(RegistrySupplier<? extends ParticleType<T>>, DeferredParticleProvider<T>)RegistrySupplierReceives the sprite set
register(ParticleType<T>, ParticleProvider<T>)ParticleTypeDoes not use a sprite set
register(ParticleType<T>, DeferredParticleProvider<T>)ParticleTypeReceives the sprite set

ParticleProviderRegistry is a client-only class. Call it from client code, or guard the call with Platform.getEnvironment() == Env.CLIENT.

Registering with a RegistrySupplier​

When the particle type is registered through a DeferredRegister, pass its RegistrySupplier. The provider is registered once the particle type has been registered:

public static final DeferredRegister<ParticleType<?>> PARTICLE_TYPES =
DeferredRegister.create(MyMod.MOD_ID, Registries.PARTICLE_TYPE);

public static final RegistrySupplier<SimpleParticleType> MY_PARTICLE =
PARTICLE_TYPES.register("my_particle", () -> new SimpleParticleType(false) {});

public static void init() {
PARTICLE_TYPES.register();

if (Platform.getEnvironment() == Env.CLIENT) {
// A provider that does not need the sprite set:
ParticleProviderRegistry.register(MY_PARTICLE, MyParticle.Provider::new);
}
}

Registering with a ParticleType​

When the ParticleType<T> instance is already available, pass it directly:

ParticleProviderRegistry.register(MyParticleTypes.MY_PARTICLE, MyParticle.Provider::new);

The particle type must already be registered when this method is called. If it is registered through a DeferredRegister, either use the RegistrySupplier overloads above, or call this method from a RegistrySupplier.listen callback:

MY_PARTICLE.listen(type -> ParticleProviderRegistry.register(type, MyParticle.Provider::new));

Using the sprite set​

A DeferredParticleProvider<T> is a functional interface whose create(ExtendedSpriteSet) method returns the ParticleProvider<T>. Use it when the provider needs the particle's sprites:

ParticleProviderRegistry.register(MY_PARTICLE, spriteSet -> new MyParticle.Provider(spriteSet));

ExtendedSpriteSet is a SpriteSet with two additional methods:

MethodReturns
getAtlas()The TextureAtlas containing the particle sprites.
getSprites()The List<TextureAtlasSprite> loaded for this particle.
Register early

Register particle providers before ClientLifecycleEvent.CLIENT_SETUP. Providers registered later can fail to be applied correctly on NeoForge, and a warning is logged.