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 injected
E - 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 Details

    • getKey

      net.kyori.adventure.key.Key getKey()
      Gets the entity key.
      Returns:
      the key
    • getEntityClass

      Class<M> 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

      EntityInjection.Builder<M,E> setBackingType(net.minecraft.world.entity.EntityType<?> backingType)
      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

      EntityInjection.Builder<M,E> setMobCategory(net.minecraft.world.entity.MobCategory category)
      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

      Consumer<net.minecraft.world.entity.EntityType.Builder<M>> 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 extending LivingEntity.

      Defaults to LivingEntity.createLivingAttributes() if this entity is a LivingEntity otherwise to null.

      Parameters:
      attributes - the attributes
      Returns:
      this builder
      Throws:
      UnsupportedOperationException - if the entity is not a LivingEntity
      See Also:
      • AttributeSupplier.Builder
    • 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 extending LivingEntity.

      Defaults to LivingEntity.createLivingAttributes() if this entity is a LivingEntity otherwise to null.

      Parameters:
      builder - the builder used to construct the attributes
      Returns:
      this builder
      Throws:
      UnsupportedOperationException - if the entity is not a LivingEntity
      See Also:
      • AttributeSupplier.Builder
    • getDefaultAttributes

      @Nullable net.minecraft.world.entity.ai.attributes.AttributeSupplier getDefaultAttributes()
      Gets the attribute supplier, or null if this entity is not a LivingEntity.
      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 resource
      resource - 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

      default EntityInjection.Builder<M,E> setModel(File file)
      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

      EntityInjection.Builder<M,E> setModel(URL url)
      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 null if none was set