Class FabricParticleTypes

java.lang.Object
net.fabricmc.fabric.api.particle.v1.FabricParticleTypes

public final class FabricParticleTypes extends Object
Methods for creating particle types, both simple and using an existing attribute factory.

Usage:

 public static final SimpleParticleType SIMPLE_TEST_PARTICLE = FabricParticleTypes.simple();
 public static final SimpleParticleType CUSTOM_TEST_PARTICLE = FabricParticleTypes.simple();

 @Override
 public void onInitialize() {
     Registry.register(Registry.PARTICLE_TYPE, new Identifier("testmod", "simple"), SIMPLE_TEST_PARTICLE);
     Registry.register(Registry.PARTICLE_TYPE, new Identifier("testmod", "custom"), CUSTOM_TEST_PARTICLE);
 }}
 
  • Method Details

    • simple

      public static SimpleParticleType simple()
      Creates a new, default particle type for the given id.
    • simple

      public static SimpleParticleType simple(boolean alwaysSpawn)
      Creates a new, default particle type for the given id.
      Parameters:
      alwaysSpawn - True to always spawn the particle regardless of distance.
    • complex

      public static <T extends ParticleEffect> ParticleType<T> complex(com.mojang.serialization.MapCodec<T> codec, PacketCodec<? super RegistryByteBuf,T> packetCodec)
      Creates a new particle type with a custom factory and codecs for packet/data serialization.
      Parameters:
      codec - The codec for serialization.
      packetCodec - The packet codec for network serialization.
    • complex

      public static <T extends ParticleEffect> ParticleType<T> complex(boolean alwaysSpawn, com.mojang.serialization.MapCodec<T> codec, PacketCodec<? super RegistryByteBuf,T> packetCodec)
      Creates a new particle type with a custom factory and codecs for packet/data serialization.
      Parameters:
      alwaysSpawn - True to always spawn the particle regardless of distance.
      codec - The codec for serialization.
      packetCodec - The packet codec for network serialization.
    • complex

      public static <T extends ParticleEffect> ParticleType<T> complex(Function<ParticleType<T>,com.mojang.serialization.MapCodec<T>> codecGetter, Function<ParticleType<T>,PacketCodec<? super RegistryByteBuf,T>> packetCodecGetter)
      Creates a new particle type with a custom factory and codecs for packet/data serialization. This method is useful when two different ParticleTypes share the same ParticleEffect implementation.
      Parameters:
      codecGetter - A function that, given the newly created type, returns the codec for serialization.
      packetCodecGetter - A function that, given the newly created type, returns the packet codec for network serialization.
    • complex

      public static <T extends ParticleEffect> ParticleType<T> complex(boolean alwaysSpawn, Function<ParticleType<T>,com.mojang.serialization.MapCodec<T>> codecGetter, Function<ParticleType<T>,PacketCodec<? super RegistryByteBuf,T>> packetCodecGetter)
      Creates a new particle type with a custom factory and codecs for packet/data serialization. This method is useful when two different ParticleTypes share the same ParticleEffect implementation.
      Parameters:
      alwaysSpawn - True to always spawn the particle regardless of distance.
      codecGetter - A function that, given the newly created type, returns the codec for serialization.
      packetCodecGetter - A function that, given the newly created type, returns the packet codec for network serialization.