Class ParticleDescriptionProvider
- All Implemented Interfaces:
DataProvider
ParticleDescription
s.
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, new ResourceLocation("drip_hang"));
// Multiple sprites
this.spriteSet(ParticleTypes.CLOUD, new ResourceLocation("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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.data.DataProvider
DataProvider.Factory<T extends DataProvider>
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<ResourceLocation,
List<String>> protected final ExistingFileHelper
private final PackOutput.PathProvider
Fields inherited from interface net.minecraft.data.DataProvider
FIXED_ORDER_FIELDS, KEY_COMPARATOR, LOGGER
-
Constructor Summary
ModifierConstructorDescriptionprotected
ParticleDescriptionProvider
(PackOutput output, ExistingFileHelper fileHelper) Creates an instance of the data provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
Registers the particle descriptions generated bysprite(ParticleType, ResourceLocation)
or one of thesprite set methods
.getName()
run
(CachedOutput cache) protected void
sprite
(ParticleType<?> type, ResourceLocation texture) Creates a new particle description that contains a single texture for the associatedParticleType
.protected void
spriteSet
(ParticleType<?> type, Iterable<ResourceLocation> textures) Creates a new particle description that contains multiple textures for the associatedParticleType
.protected void
spriteSet
(ParticleType<?> type, ResourceLocation baseName, int numOfTextures, boolean reverse) Creates a new particle description that contains multiple textures for the associatedParticleType
.protected void
spriteSet
(ParticleType<?> type, ResourceLocation texture, ResourceLocation... textures) Creates a new particle description that contains multiple textures for the associatedParticleType
.
-
Field Details
-
particlesPath
-
fileHelper
-
descriptions
-
-
Constructor Details
-
ParticleDescriptionProvider
Creates an instance of the data provider.- Parameters:
output
- the expected root directory the data generator outputs tofileHelper
- the helper used to validate a texture's existence
-
-
Method Details
-
addDescriptions
protected abstract void addDescriptions()Registers the particle descriptions generated bysprite(ParticleType, ResourceLocation)
or one of thesprite set methods
. -
sprite
Creates a new particle description that contains a single texture for the associatedParticleType
.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 fortexture
- the texture to render for the particle type- Throws:
NullPointerException
- if the particle type is not registeredIllegalArgumentException
- if a texture does not have an associated PNG file, or the particle type has already been provided
-
spriteSet
protected void spriteSet(ParticleType<?> type, ResourceLocation baseName, int numOfTextures, boolean reverse) Creates a new particle description that contains multiple textures for the associatedParticleType
. 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 forbaseName
- the common name of all the texturesnumOfTextures
- the number of textures within the setreverse
- whentrue
, the textures will be listed in descending order- Throws:
NullPointerException
- if the particle type is not registeredIllegalArgumentException
- if a texture does not have an associated PNG file, or the particle type has already been provided
-
spriteSet
protected void spriteSet(ParticleType<?> type, ResourceLocation texture, ResourceLocation... textures) Creates a new particle description that contains multiple textures for the associatedParticleType
. 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 fortexture
- the first texture in the descriptiontextures
- a list of subsequent textures to render for the particle type- Throws:
NullPointerException
- if the particle type is not registeredIllegalArgumentException
- if a texture does not have an associated PNG file, or the particle type has already been provided
-
spriteSet
Creates a new particle description that contains multiple textures for the associatedParticleType
. 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 fortextures
- a list of textures to render for the particle type- Throws:
NullPointerException
- if the particle type is not registeredIllegalArgumentException
- if there are no textures provided, a texture does not have an associated PNG file, or the particle type has already been provided
-
run
- Specified by:
run
in interfaceDataProvider
-
getName
- Specified by:
getName
in interfaceDataProvider
-