Class ParticleDescriptionProvider
- All Implemented Interfaces:
net.minecraft.data.DataProvider
- Direct Known Subclasses:
DataGeneratorTest.ParticleDescriptions
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, 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:
-
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
FieldsModifier and TypeFieldDescriptionprivate final net.minecraft.data.PackOutput.PathProvider
Fields inherited from interface net.minecraft.data.DataProvider
FIXED_ORDER_FIELDS, INDENT_WIDTH, KEY_COMPARATOR, LOGGER
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ParticleDescriptionProvider
(net.minecraft.data.PackOutput output) 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
(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 associatedParticleType
.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 associatedParticleType
.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 associatedParticleType
.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 associatedParticleType
.
-
Field Details
-
particlesPath
private final net.minecraft.data.PackOutput.PathProvider particlesPath -
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 bysprite(ParticleType, ResourceLocation)
or one of thesprite 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 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(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 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(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 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
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 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 interfacenet.minecraft.data.DataProvider
-
getName
- Specified by:
getName
in interfacenet.minecraft.data.DataProvider
-