Class ParticleDescriptionProvider

java.lang.Object
net.neoforged.neoforge.client.data.ParticleDescriptionProvider
All Implemented Interfaces:
net.minecraft.data.DataProvider
Direct Known Subclasses:
DataGeneratorTest.ParticleDescriptions

public abstract class ParticleDescriptionProvider extends Object implements net.minecraft.data.DataProvider
A data provider for ParticleDescriptions.

To use this provider, extend this class and implement addDescriptions(). Then, register an instance using DataGenerator.addProvider(boolean, Factory) via the GatherDataEvent on the mod event bus.

A description can be added to a ParticleType which uses a sprite or sprite set.


 @Override
 protected void addDescriptions() {
     // Single sprite
     this.sprite(ParticleTypes.DRIPPING_LAVA, ResourceLocation.withDefaultNamespace("drip_hang"));

     // Multiple sprites
     this.spriteSet(ParticleTypes.CLOUD, ResourceLocation.withDefaultNamespace("generic"), 8, true);
 }
 

A particle description holds a list of textures used when rendering the particle to the screen. All registered particle descriptions are stitched together into a texture atlas called TextureAtlas.LOCATION_PARTICLES. A ParticleType whose particle uses the texture atlas, typically via the ParticleRenderType, can then reference the necessary texture during rendering.

Particles with a particle description must have their particle providers attached to a ParticleType as a sprite or sprite set consumer.

See Also:
  • DataProvider
  • ParticleDescription
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.data.DataProvider

    net.minecraft.data.DataProvider.Factory<T extends net.minecraft.data.DataProvider>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Map<net.minecraft.resources.ResourceLocation,List<String>>
     
    private final net.minecraft.data.PackOutput.PathProvider
     

    Fields inherited from interface net.minecraft.data.DataProvider

    FIXED_ORDER_FIELDS, INDENT_WIDTH, KEY_COMPARATOR, LOGGER
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ParticleDescriptionProvider(net.minecraft.data.PackOutput output)
    Creates an instance of the data provider.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Registers the particle descriptions generated by sprite(ParticleType, ResourceLocation) or one of the sprite set methods.
     
    run(net.minecraft.data.CachedOutput cache)
     
    protected void
    sprite(net.minecraft.core.particles.ParticleType<?> type, net.minecraft.resources.ResourceLocation texture)
    Creates a new particle description that contains a single texture for the associated ParticleType.
    protected void
    spriteSet(net.minecraft.core.particles.ParticleType<?> type, Iterable<net.minecraft.resources.ResourceLocation> textures)
    Creates a new particle description that contains multiple textures for the associated ParticleType.
    protected void
    spriteSet(net.minecraft.core.particles.ParticleType<?> type, net.minecraft.resources.ResourceLocation baseName, int numOfTextures, boolean reverse)
    Creates a new particle description that contains multiple textures for the associated ParticleType.
    protected void
    spriteSet(net.minecraft.core.particles.ParticleType<?> type, net.minecraft.resources.ResourceLocation texture, net.minecraft.resources.ResourceLocation... textures)
    Creates a new particle description that contains multiple textures for the associated ParticleType.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • particlesPath

      private final net.minecraft.data.PackOutput.PathProvider particlesPath
    • descriptions

      @VisibleForTesting protected final Map<net.minecraft.resources.ResourceLocation,List<String>> descriptions
  • Constructor Details

    • ParticleDescriptionProvider

      protected ParticleDescriptionProvider(net.minecraft.data.PackOutput output)
      Creates an instance of the data provider.
      Parameters:
      output - the expected root directory the data generator outputs to
  • Method Details

    • addDescriptions

      protected abstract void addDescriptions()
      Registers the particle descriptions generated by sprite(ParticleType, ResourceLocation) or one of the sprite set methods.
    • sprite

      protected void sprite(net.minecraft.core.particles.ParticleType<?> type, net.minecraft.resources.ResourceLocation texture)
      Creates a new particle description that contains a single texture for the associated ParticleType.

      Particle types with this description should be attached to a particle provider via RegisterParticleProvidersEvent.registerSprite(ParticleType, ParticleProvider.Sprite).

      Parameters:
      type - the particle type the textures are applied for
      texture - the texture to render for the particle type
      Throws:
      NullPointerException - if the particle type is not registered
      IllegalArgumentException - if a texture does not have an associated PNG file, or the particle type has already been provided
    • spriteSet

      protected void spriteSet(net.minecraft.core.particles.ParticleType<?> type, net.minecraft.resources.ResourceLocation baseName, int numOfTextures, boolean reverse)
      Creates a new particle description that contains multiple textures for the associated ParticleType. The textures are generated from a common name and appended with a number representing the state of the animation.
      
       minecraft:generic_0
       minecraft:generic_1
       minecraft:generic_2
       // ...
       

      Particle types with this description should be attached to a particle provider via RegisterParticleProvidersEvent.registerSpriteSet(ParticleType, ParticleEngine.SpriteParticleRegistration).

      Parameters:
      type - the particle type the textures are applied for
      baseName - the common name of all the textures
      numOfTextures - the number of textures within the set
      reverse - when true, the textures will be listed in descending order
      Throws:
      NullPointerException - if the particle type is not registered
      IllegalArgumentException - if a texture does not have an associated PNG file, or the particle type has already been provided
    • spriteSet

      protected void spriteSet(net.minecraft.core.particles.ParticleType<?> type, net.minecraft.resources.ResourceLocation texture, net.minecraft.resources.ResourceLocation... textures)
      Creates a new particle description that contains multiple textures for the associated ParticleType. The textures are passed as varargs with at least one texture present.

      Particle types with this description should be attached to a particle provider via RegisterParticleProvidersEvent.registerSpriteSet(ParticleType, ParticleEngine.SpriteParticleRegistration).

      Parameters:
      type - the particle type the textures are applied for
      texture - the first texture in the description
      textures - a list of subsequent textures to render for the particle type
      Throws:
      NullPointerException - if the particle type is not registered
      IllegalArgumentException - if a texture does not have an associated PNG file, or the particle type has already been provided
    • spriteSet

      protected void spriteSet(net.minecraft.core.particles.ParticleType<?> type, Iterable<net.minecraft.resources.ResourceLocation> textures)
      Creates a new particle description that contains multiple textures for the associated ParticleType. The textures are passed as an iterable.

      Particle types with this description should be attached to a particle provider via RegisterParticleProvidersEvent.registerSpriteSet(ParticleType, ParticleEngine.SpriteParticleRegistration).

      Parameters:
      type - the particle type the textures are applied for
      textures - a list of textures to render for the particle type
      Throws:
      NullPointerException - if the particle type is not registered
      IllegalArgumentException - if there are no textures provided, a texture does not have an associated PNG file, or the particle type has already been provided
    • run

      public CompletableFuture<?> run(net.minecraft.data.CachedOutput cache)
      Specified by:
      run in interface net.minecraft.data.DataProvider
    • getName

      public String getName()
      Specified by:
      getName in interface net.minecraft.data.DataProvider