Interface EntityManager


@NonExtendable public interface EntityManager
Handles the post-initialization, lifecycle and other logic and helper methods for Bestium entities.
  • Method Details

    • getManager

      static EntityManager getManager()
      Retrieves the Bestium EntityManager instance, which handles the management and lifecycle of custom Bestium entities.
      Returns:
      the EntityManager instance
    • isInjected

      default boolean isInjected(Entity entity)
      Checks whether the given Bukkit Entity is an injected entity.
      Parameters:
      entity - the Bukkit Entity to check
      Returns:
      true if the entity was injected by Bestium, false otherwise
    • isInjected

      default boolean isInjected(net.minecraft.world.entity.Entity entity)
      Checks whether the given Minecraft Entity is an injected entity.
      Parameters:
      entity - the Minecraft Entity to check
      Returns:
      true if the entity was injected by Bestium, false otherwise
    • isInjected

      boolean isInjected(net.minecraft.world.entity.EntityType<?> type)
      Checks whether the given EntityType is an injected entity type.
      Parameters:
      type - the EntityType to check
      Returns:
      true if the entity type was injected by Bestium, false otherwise
    • getInjection

      default @Nullable EntityInjection<?,?> getInjection(Entity entity)
      Retrieves the Bestium EntityInjection of the injected Bukkit Entity, or null if not injected.
      Parameters:
      entity - the Bukkit Entity to retrieve the injection from
      Returns:
      the EntityInjection used to inject the entity type, or null if the entity is not an injected entity
    • getInjection

      @Nullable EntityInjection<?,?> getInjection(net.minecraft.world.entity.Entity entity)
      Retrieves the Bestium EntityInjection of the injected Minecraft Entity, or null if not injected.
      Parameters:
      entity - the Minecraft Entity to retrieve the injection from
      Returns:
      the EntityInjection used to inject the entity type, or null if the entity is not an injected entity
    • requireInjection

      default EntityInjection<?,?> requireInjection(Entity entity)
      Retrieves the Bestium EntityInjection of the injected Bukkit Entity.

      Throws an IllegalArgumentException if the entity is not an injected entity.

      Parameters:
      entity - the Bukkit Entity for which the injection is required
      Returns:
      the EntityInjection used to inject the entity type
      Throws:
      IllegalArgumentException - if the given entity is not an injected entity
    • requireInjection

      default EntityInjection<?,?> requireInjection(net.minecraft.world.entity.Entity entity)
      Retrieves the Bestium EntityInjection of the injected Minecraft Entity.

      Throws an IllegalArgumentException if the given entity is not an injected entity.

      Parameters:
      entity - the Minecraft Entity for which the injection is required
      Returns:
      the EntityInjection associated with the given entity
      Throws:
      IllegalArgumentException - if the provided entity is not an injected entity
    • spawn

      <T extends net.minecraft.world.entity.Entity> @Nullable T spawn(Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason, Consumer<T> consumer)
      Spawns a custom injected entity of the specified class at the given location.
      Type Parameters:
      T - the type of the entity
      Parameters:
      location - the location where the entity should spawn
      entityClass - the class of the injected entity to spawn
      entitySpawnReason - the Minecraft EntitySpawnReason to use when spawning
      creatureSpawnReason - the Bukkit CreatureSpawnEvent.SpawnReason to use when triggering events
      consumer - a consumer that is called after the entity is created but before it is added to the world
      Returns:
      the spawned entity instance, or null if spawning failed
      Throws:
      IllegalArgumentException - if the given class is not a registered injected entity
    • spawn

      default <T extends net.minecraft.world.entity.Entity> @Nullable T spawn(Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason)
      Spawns a custom injected entity with default initialization logic.
      Type Parameters:
      T - the type of the entity
      Parameters:
      location - the location where the entity should spawn
      entityClass - the class of the injected entity to spawn
      entitySpawnReason - the Minecraft EntitySpawnReason to use when spawning
      creatureSpawnReason - the Bukkit CreatureSpawnEvent.SpawnReason to use when triggering events
      Returns:
      the spawned entity instance, or null if spawning failed
      Throws:
      IllegalArgumentException - if the given class is not a registered injected entity
      See Also:
    • getBackingType

      @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(net.minecraft.world.entity.EntityType<?> type)
      Retrieves the backing type of a given injected entity type.
      Parameters:
      type - the EntityType to retrieve the backing type for
      Returns:
      the backing EntityType, or null if type is not injected
    • getBackingType

      default @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(net.minecraft.world.entity.Entity entity)
      Retrieves the backing EntityType of the given Minecraft Entity.
      Parameters:
      entity - the Minecraft Entity to retrieve the backing type for
      Returns:
      the backing EntityType, or null if the entity's type is not injected
    • getBackingType

      default @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(Entity entity)
      Retrieves the backing EntityType of the given Bukkit Entity.
      Parameters:
      entity - the Bukkit Entity to retrieve the backing type for
      Returns:
      the backing EntityType, or null if the entity's type is not injected