Package cz.jeme.bestium.api.inject
Interface EntityInjection<M extends net.minecraft.world.entity.Entity & Injectable,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
@NullMarked
public sealed interface EntityInjection<M extends net.minecraft.world.entity.Entity & Injectable,E extends org.bukkit.entity.Entity>
Represents all necessary metadata and configuration for injecting a custom
Entity into the game.
Created using builder(Key, Class, EntityType.EntityFactory, ConvertFunction).
After an instance is created, it can be injected into the server runtime using EntityInjector.register(Supplier) )}.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceEntityInjection.Builder<M extends net.minecraft.world.entity.Entity & Injectable,E extends org.bukkit.entity.Entity> A builder used to configure and construct anEntityInjection. -
Method Summary
Modifier and TypeMethodDescription@Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplierReturns the attribute supplier used to define default attributes for this entity.net.minecraft.world.entity.EntityType<?> Returns the backing Minecraft entity type used for client-side rendering and hitbox size.static <M extends net.minecraft.world.entity.Entity & Injectable,E extends org.bukkit.entity.Entity>
EntityInjection.Builder<M, E> builder(net.kyori.adventure.key.Key key, Class<M> entityClass, net.minecraft.world.entity.EntityType.EntityFactory<M> entityFactory, ConvertFunction<M, E> convertFunction) Creates a newEntityInjection.Builderfor constructing anEntityInjection.Returns the function that converts the Minecraft entity of typeEntityInjectioninto a Bukkit entity of typeEntityInjection.Returns the class of the custom entity.net.minecraft.world.entity.EntityType.EntityFactory<M> Returns the factory used to create new instances of this entity.net.kyori.adventure.key.Keykey()Returns the unique key representing this entity type.net.minecraft.world.entity.MobCategoryReturns the category of the entity.@Nullable StringReturns the model name used to identify this entity's model.@Nullable URLmodelUrl()Returns the URL of the model associated with this entity.Returns the type builder customizer used to modify entity properties.
-
Method Details
-
key
net.kyori.adventure.key.Key key()Returns the unique key representing this entity type.- Returns:
- the namespaced key
-
entityClass
Returns the class of the custom entity.- Returns:
- the entity class
-
entityFactory
net.minecraft.world.entity.EntityType.EntityFactory<M> entityFactory()Returns the factory used to create new instances of this entity.- Returns:
- the entity factory
-
convertFunction
ConvertFunction<M,E> convertFunction()Returns the function that converts the Minecraft entity of typeEntityInjectioninto a Bukkit entity of typeEntityInjection.- Returns:
- the convert function
-
backingType
net.minecraft.world.entity.EntityType<?> backingType()Returns the backing Minecraft entity type used for client-side rendering and hitbox size.- Returns:
- the backing type
-
mobCategory
net.minecraft.world.entity.MobCategory mobCategory()Returns the category of the entity.- Returns:
- the mob category
-
typeCustomizer
Returns the type builder customizer used to modify entity properties.- Returns:
- the builder customizer
-
attributes
@Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplier attributes()Returns the attribute supplier used to define default attributes for this entity. Returnsnullif the entity does not extendLivingEntityand therefore does not have attributes.- Returns:
- the attribute supplier or
null
-
modelUrl
@Nullable URL modelUrl()Returns the URL of the model associated with this entity.- Returns:
- the model URL, or
nullif none was set
-
modelName
@Nullable String modelName()Returns the model name used to identify this entity's model.The model name is automatically generated based on the entity's key, using the following format:
bestium.<namespace>.<value>.For example, an entity with the key
example_plugin:custom_entitywould have the model namebestium.example_plugin.custom_entity.- Returns:
- the generated model name, or
nullif no model URL was set - See Also:
-
builder
static <M extends net.minecraft.world.entity.Entity & Injectable,E extends org.bukkit.entity.Entity> EntityInjection.Builder<M,E> builder(net.kyori.adventure.key.Key key, Class<M> entityClass, net.minecraft.world.entity.EntityType.EntityFactory<M> entityFactory, ConvertFunction<M, E> convertFunction) Creates a newEntityInjection.Builderfor constructing anEntityInjection.- Type Parameters:
M- the type of the Minecraft entity being injectedE- the type of the Bukkit entity the Minecraft entity can be converted to- Parameters:
key- a namespaced key such asmy_plugin:my_custom_entityentityClass- the class representing your custom entityentityFactory- the factory used to instantiate the entity (usuallyCustomEntityClass::new)convertFunction- the factory used to create a Bukkit representation of this entity (e.g.,CraftAnimals::new)- Returns:
- a new builder instance
- See Also:
-