Interface EntityInjection.Builder<M extends net.minecraft.world.entity.Entity,E extends Entity>
- Type Parameters:
M
- the type of the Minecraft entity being injectedE
- the type of the Bukkit entity the Minecraft entity can be converted to
- All Superinterfaces:
AbstractBuilder<EntityInjection<M,
E>>
- Enclosing interface:
EntityInjection<M extends net.minecraft.world.entity.Entity,
E extends Entity>
EntityInjection
.-
Method Summary
Modifier and TypeMethodDescriptionaddVariant
(UnboundEntityVariant variant) Adds a single entity variant providing a model to this entity injection.default EntityInjection.Builder
<M, E> addVariants
(UnboundEntityVariant first, UnboundEntityVariant second, UnboundEntityVariant... rest) Adds two or more entity variants providing models to this entity injection.default EntityInjection.Builder
<M, E> addVariants
(Collection<UnboundEntityVariant> variants) Adds a collection of entity variants providing models to this entity injection.build()
Builds theEntityInjection
instance.Gets the craft entity factory.@Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplier
Gets the attribute supplier, ornull
if this entity is not aLivingEntity
.getDisplayName
(Locale locale) Retrieves the display name of this entity for the specified locale.Gets the entity class.net.minecraft.world.entity.EntityType.EntityFactory
<M> Gets the entity factory.getKey()
Gets the entity key.net.minecraft.world.entity.MobCategory
Gets the mob category.Returns theSpawnRule
responsible for choosing in which biomes, how often and in what group sizes this entity naturally spawns.Gets the type builder customizer.Returns theVariantRule
for this entity.@Unmodifiable Set
<UnboundEntityVariant> Returns an unmodifiable set of entity variants added to this entity injection.default EntityInjection.Builder
<M, E> setComputedSpawnRule
(Supplier<SpawnRule> spawnRuleSupplier) Computes and then sets theSpawnRule
responsible for choosing in which biomes, how often and in what group sizes this entity naturally spawns.default EntityInjection.Builder
<M, E> setComputedVariantRule
(Supplier<VariantRule> variantRuleSupplier) Computes and then sets theVariantRule
responsible for picking theBoundEntityVariant
when this entity spawns into the world.setDefaultAttributes
(net.minecraft.world.entity.ai.attributes.AttributeSupplier attributes) Sets the default attributes for this entity.default EntityInjection.Builder
<M, E> setDefaultAttributes
(net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder builder) Sets the default attributes for this entity.default EntityInjection.Builder
<M, E> setDisplayName
(String displayName) Sets the display name for theLocale.US
locale.default EntityInjection.Builder
<M, E> setDisplayName
(Locale locale, String displayName) Sets the display name for the specifiedLocale
.setDisplayName
(Locale locale, Component displayName) default EntityInjection.Builder
<M, E> setDisplayName
(Component displayName) setDisplayNames
(Map<Locale, Component> displayNames) setMobCategory
(net.minecraft.world.entity.MobCategory category) Sets the mob category of the entity.setSpawnRule
(SpawnRule spawnRule) Sets theSpawnRule
responsible for choosing in which biomes, how often and in what group sizes this entity naturally spawns.setTypeCustomizer
(Consumer<net.minecraft.world.entity.EntityType.Builder<M>> typeBuilder) Sets a customizer for the entity type builder.setVariantRule
(VariantRule variantRule) Sets theVariantRule
responsible for picking theBoundEntityVariant
when this entity spawns into the world.setVariants
(Collection<UnboundEntityVariant> variants) Replaces all entity variants providing models for this entity injection with the given collection.
-
Method Details
-
getKey
Key getKey()Gets the entity key.- Returns:
- the key
-
getEntityClass
Gets the entity class.- Returns:
- the class
-
getEntityFactory
net.minecraft.world.entity.EntityType.EntityFactory<M> getEntityFactory()Gets the entity factory.- Returns:
- the factory
-
getConvertFunction
ConvertFunction<M,E> getConvertFunction()Gets the craft entity factory.- Returns:
- the factory
-
setMobCategory
Sets the mob category of the entity.Defaults to:
MobCategory.MISC
.- Parameters:
category
- the mob category- Returns:
- this builder
-
getMobCategory
net.minecraft.world.entity.MobCategory getMobCategory()Gets the mob category.- Returns:
- the category
-
setTypeCustomizer
EntityInjection.Builder<M,E> setTypeCustomizer(Consumer<net.minecraft.world.entity.EntityType.Builder<M>> typeBuilder) Sets a customizer for the entity type builder.For example, to define passenger attachments use:
EntityType.Builder.passengerAttachments(Vec3...)
.Defaults to: an empty
Consumer
.- Parameters:
typeBuilder
- the builder customizer- Returns:
- this builder
-
getTypeCustomizer
Gets the type builder customizer.- Returns:
- the builder consumer
-
setDefaultAttributes
EntityInjection.Builder<M,E> setDefaultAttributes(net.minecraft.world.entity.ai.attributes.AttributeSupplier attributes) Sets the default attributes for this entity. Only valid for entities extendingLivingEntity
.Defaults to:
LivingEntity.createLivingAttributes()
if this entity is aLivingEntity
otherwise tonull
.- Parameters:
attributes
- the attributes- Returns:
- this builder
- Throws:
UnsupportedOperationException
- if the entity is not a LivingEntity- See Also:
-
setDefaultAttributes
default EntityInjection.Builder<M,E> setDefaultAttributes(net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder builder) Sets the default attributes for this entity. Only valid for entities extendingLivingEntity
.Defaults to:
LivingEntity.createLivingAttributes()
if this entity is aLivingEntity
otherwise tonull
.- Parameters:
builder
- the builder used to construct the attributes- Returns:
- this builder
- Throws:
UnsupportedOperationException
- if the entity is not a LivingEntity- See Also:
-
getDefaultAttributes
@Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplier getDefaultAttributes()Gets the attribute supplier, ornull
if this entity is not aLivingEntity
.- Returns:
- the attributes or
null
-
setVariants
Replaces all entity variants providing models for this entity injection with the given collection.This operation discards any previously added variants, whether added via this or other methods. The order of variants in the provided collection matters: the default variant chosen by a spawning entity will be the first variant in this collection.
The collection must not contain variants with duplicate IDs. If duplicates exist, they will be silently eliminated with undefined behavior.
Defaults to: no variants
- Parameters:
variants
- the collection of unbound entity variants to set- Returns:
- this builder
- See Also:
-
addVariant
Adds a single entity variant providing a model to this entity injection.If this is the first variant added, it will be used as the default variant when a spawning entity is choosing a model.
If a variant with the same ID already exists, this method will ignore the new variant silently.
- Parameters:
variant
- the unbound entity variant to add- Returns:
- this builder
- See Also:
-
addVariants
Adds a collection of entity variants providing models to this entity injection.The order of variants in the collection matters: if this is the first time variants are added, the first element will be used as the default variant when a spawning entity is choosing a variant.
Variants with IDs that duplicate existing variants in the injection will be ignored. If there are duplicate IDs within the provided collection itself, the first variant encountered with that ID will be prioritized.
- Parameters:
variants
- the collection of unbound entity variants to add- Returns:
- this builder
- See Also:
-
addVariants
default EntityInjection.Builder<M,E> addVariants(UnboundEntityVariant first, UnboundEntityVariant second, UnboundEntityVariant... rest) Adds two or more entity variants providing models to this entity injection.The order of variants matters: if this is the first time variants are added, the first argument will be the default variant selected when a spawning entity is choosing a model.
Variants with duplicate IDs compared to already added variants will be ignored. For duplicates within the arguments themselves, the first variant with the ID will be prioritized.
- Parameters:
first
- the first unbound entity variant to addsecond
- the second unbound entity variant to addrest
- additional unbound entity variants to add- Returns:
- this builder
- See Also:
-
getVariants
@Unmodifiable Set<UnboundEntityVariant> getVariants()Returns an unmodifiable set of entity variants added to this entity injection.The returned set preserves the order in which variants were added.
- Returns:
- an unmodifiable, ordered set of added entity variants
-
setVariantRule
Sets theVariantRule
responsible for picking theBoundEntityVariant
when this entity spawns into the world.Defaults to:
VariantRule.first()
- Parameters:
variantRule
- the variant rule- Returns:
- this builder
-
setComputedVariantRule
default EntityInjection.Builder<M,E> setComputedVariantRule(Supplier<VariantRule> variantRuleSupplier) Computes and then sets theVariantRule
responsible for picking theBoundEntityVariant
when this entity spawns into the world.This method may be useful when additional logic needs to run before returning the variant rule.
Defaults to:
VariantRule.first()
- Parameters:
variantRuleSupplier
- the supplier providing the variant rule- Returns:
- this builder
-
setDisplayNames
- Parameters:
displayNames
- a map of locales to display name components- Returns:
- this builder
-
setDisplayName
- Parameters:
locale
- the locale for which the display name component is being setdisplayName
- the component to be used as the display name- Returns:
- this builder
-
setDisplayName
Sets the display name for the specifiedLocale
.- Parameters:
locale
- the locale for which the display name is being setdisplayName
- the display name to set- Returns:
- this builder
-
setDisplayName
- Parameters:
displayName
- the display name component to set- Returns:
- this builder
-
setDisplayName
Sets the display name for theLocale.US
locale.- Parameters:
displayName
- the display name to set- Returns:
- this builder
-
getDisplayNames
Returns a map of display names, where eachLocale
corresponds to aComponent
that serves as the display name.- Returns:
- an unmodifiable map of locales to display name components
-
getDisplayName
Retrieves the display name of this entity for the specified locale.- Parameters:
locale
- the locale for which the display name should be retrieved- Returns:
- the display name entity, or
null
if no display name for provided locale was set
-
getVariantRule
VariantRule getVariantRule()Returns theVariantRule
for this entity.- Returns:
- the variant rule
-
setSpawnRule
Sets theSpawnRule
responsible for choosing in which biomes, how often and in what group sizes this entity naturally spawns.Defaults to:
SpawnRule.never()
- Parameters:
spawnRule
- the spawn rule for this entity- Returns:
- this builder
-
getSpawnRule
SpawnRule getSpawnRule()Returns theSpawnRule
responsible for choosing in which biomes, how often and in what group sizes this entity naturally spawns.- Returns:
- the spawn rule for this entity
-
setComputedSpawnRule
Computes and then sets theSpawnRule
responsible for choosing in which biomes, how often and in what group sizes this entity naturally spawns.This method may be useful when additional logic needs to run before returning the spawn rule.
Defaults to:
SpawnRule.never()
- Parameters:
spawnRuleSupplier
- the supplier providing the spawn rule- Returns:
- this builder
-
build
EntityInjection<M,E> build()Builds theEntityInjection
instance.- Specified by:
build
in interfaceAbstractBuilder<M extends net.minecraft.world.entity.Entity>
- Returns:
- the built entity injection instance
- Throws:
IllegalArgumentException
- if the entity is a living entity and no attributes were provided
-