~~REDIRECT>https://docs.fabricmc.net/develop/rendering/particles/creating-particles~~ ====== Adding Particles ====== Particles are textures used for special events and additional VFX. They are used on explosions, torches, dripping water and more! ===== Adding Simple Particles ===== Simple Particles might only use Minecraft's own particle Factories. This means all behavior must be equal to an already-existing particle in vanilla. For this example, we'll do a green-variant of ''FlameParticle'' - the particle used for the top of torches. ==== Initial register ==== First, register your particle in your ''ModInitializer'': public class ExampleMod implements ModInitializer { // instance of our particle public static final SimpleParticleType GREEN_FLAME = FabricParticleTypes.simple(); @Override public void onInitialize() { Registry.register(Registries.PARTICLE_TYPE, Identifier.fromNamespaceAndPath("modid", "green_flame"), GREEN_FLAME); } } ==== Client-side register ==== Now, we need to register it client-side. Create a class that implements ''ClientModInitializer'' (if one does not exist already): public class ExampleModClient implements ClientModInitializer { @Override public void onInitializeClient() { /* Registers our particle client-side. * First argument is our particle's instance, created previously on ExampleMod. * Second argument is the particle's factory. The factory controls how the particle behaves. * In this example, we'll use FlameParticle's Factory.*/ ParticleFactoryRegistry.getInstance().register(ExampleMod.GREEN_FLAME, FlameParticle.Provider::new); } } ==== Model & Texture ==== Our particle is now properly implemented... //code-wise//. Before starting the game, you'll need to create two files: the particle's **model** and **texture**. { "textures": [ "modid:green_flame" ] } This will tell Minecraft which textures are used for our particle. Since we're using FlameParticle's Factory, we'll use only one particle, just as the former. **TIP:** you can use Minecraft's own textures! Now, add your particle's textures to the following path: src/main/resources/assets/modid/textures/particle/ Recommended texture size is **16x16** pixels. If you did everything correctly, your particle should now work flawlessly! You might test it using the command ''/particle modid:green_flame ~ ~ ~''. ===== Adding Complex Particles ===== WIP The sourcecode for this tutorial is available here: [[https://github.com/Luligabi1/ParticleExampleMod|ParticleExampleMod]]