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 injected
E - 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 Classes
    Modifier and Type
    Interface
    Description
    static interface 
    EntityInjection.Builder<M extends net.minecraft.world.entity.Entity & Injectable,E extends org.bukkit.entity.Entity>
    A builder used to configure and construct an EntityInjection.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplier
    Returns 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 new EntityInjection.Builder for constructing an EntityInjection.
    Returns the function that converts the Minecraft entity of type EntityInjection into a Bukkit entity of type EntityInjection.
    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.Key
    key()
    Returns the unique key representing this entity type.
    net.minecraft.world.entity.MobCategory
    Returns the category of the entity.
    @Nullable String
    Returns the model name used to identify this entity's model.
    @Nullable URL
    Returns the URL of the model associated with this entity.
    Consumer<net.minecraft.world.entity.EntityType.Builder<M>>
    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

      Class<M> 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 type EntityInjection into a Bukkit entity of type EntityInjection.
      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

      Consumer<net.minecraft.world.entity.EntityType.Builder<M>> 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. Returns null if the entity does not extend LivingEntity and 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 null if 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_entity would have the model name bestium.example_plugin.custom_entity.

      Returns:
      the generated model name, or null if 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 new EntityInjection.Builder for constructing an EntityInjection.
      Type Parameters:
      M - the type of the Minecraft entity being injected
      E - the type of the Bukkit entity the Minecraft entity can be converted to
      Parameters:
      key - a namespaced key such as my_plugin:my_custom_entity
      entityClass - the class representing your custom entity
      entityFactory - the factory used to instantiate the entity (usually CustomEntityClass::new)
      convertFunction - the factory used to create a Bukkit representation of this entity (e.g., CraftAnimals::new)
      Returns:
      a new builder instance
      See Also:
      • NamespacedKey(Plugin, String)