Package cz.jeme.bestium.api.inject
Interface EntityInjection.Builder<M extends net.minecraft.world.entity.Entity,E extends org.bukkit.entity.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:
net.kyori.adventure.builder.AbstractBuilder<EntityInjection<M,E>>
- Enclosing interface:
EntityInjection<M extends net.minecraft.world.entity.Entity,E extends org.bukkit.entity.Entity>
public static sealed interface EntityInjection.Builder<M extends net.minecraft.world.entity.Entity,E extends org.bukkit.entity.Entity>
extends net.kyori.adventure.builder.AbstractBuilder<EntityInjection<M,E>>
A builder used to configure and construct an
EntityInjection.-
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.entity.EntityType<?> Gets the backing entity type.Gets the craft entity factory.@Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplierGets the attribute supplier, ornullif this entity is not aLivingEntity.Gets the entity class.net.minecraft.world.entity.EntityType.EntityFactory<M> Gets the entity factory.net.kyori.adventure.key.KeygetKey()Gets the entity key.net.minecraft.world.entity.MobCategoryGets the mob category.@Nullable URLGets the URL of the model associated with this entity.Gets the type builder customizer.setBackingType(net.minecraft.world.entity.EntityType<?> backingType) Sets the backing type for rendering and size fallback.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.setMobCategory(net.minecraft.world.entity.MobCategory category) Sets the mob category of the entity.default EntityInjection.Builder<M, E> Sets the model for this entity using a resource bundled in the plugin's JAR.default EntityInjection.Builder<M, E> Sets the model for this entity using a local file on the filesystem.Sets the model for this entity using the given URL.setTypeCustomizer(Consumer<net.minecraft.world.entity.EntityType.Builder<M>> typeBuilder) Sets a customizer for the entity type builder.Methods inherited from interface net.kyori.adventure.builder.AbstractBuilder
build
-
Method Details
-
getKey
net.kyori.adventure.key.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
-
setBackingType
Sets the backing type for rendering and size fallback.Defaults to
EntityType.SILVERFISH.- Parameters:
backingType- the fallback entity type- Returns:
- this builder
-
getBackingType
net.minecraft.world.entity.EntityType<?> getBackingType()Gets the backing entity type.- Returns:
- the fallback type
-
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 aLivingEntityotherwise 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 aLivingEntityotherwise 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, ornullif this entity is not aLivingEntity.- Returns:
- the attributes or
null
-
setModel
default EntityInjection.Builder<M,E> setModel(io.papermc.paper.plugin.bootstrap.PluginBootstrap bootstrapper, String resource) Sets the model for this entity using a resource bundled in the plugin's JAR.The resource path must be '
/'-separated (e.g.,models/my_entity.bbmodel).This method attempts to load the resource using the bootstrapper's class loader.
- Parameters:
bootstrapper- the plugin bootstrapper whose class loader will be used to load the resourceresource- the path to the resource inside the plugin's JAR- Returns:
- this builder
- Throws:
NullPointerException- if the resource cannot be found in the JAR file
-
setModel
Sets the model for this entity using a local file on the filesystem.- Parameters:
file- the file containing the model- Returns:
- this builder
- Throws:
IllegalArgumentException- if the file's URL is invalid
-
setModel
Sets the model for this entity using the given URL.- Parameters:
url- the URL pointing to the model file- Returns:
- this builder
-
getModelUrl
@Nullable URL getModelUrl()Gets the URL of the model associated with this entity.- Returns:
- the model URL, or
nullif none was set
-