Package cz.jeme.bestium.api
Interface EntityManager
@NonExtendable
public interface EntityManager
Handles the post-initialization, lifecycle and other logic and helper methods for Bestium entities.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(net.minecraft.world.entity.Entity entity) Retrieves the backingEntityTypeof the given MinecraftEntity.@Nullable net.minecraft.world.entity.EntityType<?> getBackingType(net.minecraft.world.entity.EntityType<?> type) Retrieves the backing type of a given injected entity type.default @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(Entity entity) Retrieves the backingEntityTypeof the given BukkitEntity.@Nullable EntityInjection<?, ?> getInjection(net.minecraft.world.entity.Entity entity) default @Nullable EntityInjection<?, ?> getInjection(Entity entity) static EntityManagerRetrieves the BestiumEntityManagerinstance, which handles the management and lifecycle of custom Bestium entities.default booleanisInjected(net.minecraft.world.entity.Entity entity) Checks whether the given MinecraftEntityis an injected entity.booleanisInjected(net.minecraft.world.entity.EntityType<?> type) Checks whether the givenEntityTypeis an injected entity type.default booleanisInjected(Entity entity) Checks whether the given BukkitEntityis an injected entity.default EntityInjection<?, ?> requireInjection(net.minecraft.world.entity.Entity entity) Retrieves the BestiumEntityInjectionof the injected MinecraftEntity.default EntityInjection<?, ?> requireInjection(Entity entity) Retrieves the BestiumEntityInjectionof the injected BukkitEntity.default <T extends net.minecraft.world.entity.Entity>
@Nullable Tspawn(Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason) Spawns a custom injected entity with default initialization logic.<T extends net.minecraft.world.entity.Entity>
@Nullable Tspawn(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.
-
Method Details
-
getManager
Retrieves the BestiumEntityManagerinstance, which handles the management and lifecycle of custom Bestium entities.- Returns:
- the
EntityManagerinstance
-
isInjected
Checks whether the given BukkitEntityis an injected entity.- Parameters:
entity- the BukkitEntityto check- Returns:
trueif the entity was injected by Bestium,falseotherwise
-
isInjected
default boolean isInjected(net.minecraft.world.entity.Entity entity) Checks whether the given MinecraftEntityis an injected entity.- Parameters:
entity- the MinecraftEntityto check- Returns:
trueif the entity was injected by Bestium,falseotherwise
-
isInjected
boolean isInjected(net.minecraft.world.entity.EntityType<?> type) Checks whether the givenEntityTypeis an injected entity type.- Parameters:
type- theEntityTypeto check- Returns:
trueif the entity type was injected by Bestium,falseotherwise
-
getInjection
- Parameters:
entity- the BukkitEntityto retrieve the injection from- Returns:
- the
EntityInjectionused to inject the entity type, ornullif the entity is not an injected entity
-
getInjection
- Parameters:
entity- the MinecraftEntityto retrieve the injection from- Returns:
- the
EntityInjectionused to inject the entity type, ornullif the entity is not an injected entity
-
requireInjection
Retrieves the BestiumEntityInjectionof the injected BukkitEntity.Throws an
IllegalArgumentExceptionif the entity is not an injected entity.- Parameters:
entity- the BukkitEntityfor which the injection is required- Returns:
- the
EntityInjectionused to inject the entity type - Throws:
IllegalArgumentException- if the given entity is not an injected entity
-
requireInjection
Retrieves the BestiumEntityInjectionof the injected MinecraftEntity.Throws an
IllegalArgumentExceptionif the given entity is not an injected entity.- Parameters:
entity- the MinecraftEntityfor which the injection is required- Returns:
- the
EntityInjectionassociated 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 spawnentityClass- the class of the injected entity to spawnentitySpawnReason- the MinecraftEntitySpawnReasonto use when spawningcreatureSpawnReason- the BukkitCreatureSpawnEvent.SpawnReasonto use when triggering eventsconsumer- a consumer that is called after the entity is created but before it is added to the world- Returns:
- the spawned entity instance, or
nullif 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 spawnentityClass- the class of the injected entity to spawnentitySpawnReason- the MinecraftEntitySpawnReasonto use when spawningcreatureSpawnReason- the BukkitCreatureSpawnEvent.SpawnReasonto use when triggering events- Returns:
- the spawned entity instance, or
nullif 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- theEntityTypeto retrieve the backing type for- Returns:
- the backing
EntityType, ornullif type is not injected
-
getBackingType
default @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(net.minecraft.world.entity.Entity entity) Retrieves the backingEntityTypeof the given MinecraftEntity.- Parameters:
entity- the MinecraftEntityto retrieve the backing type for- Returns:
- the backing
EntityType, ornullif the entity's type is not injected
-
getBackingType
Retrieves the backingEntityTypeof the given BukkitEntity.- Parameters:
entity- the BukkitEntityto retrieve the backing type for- Returns:
- the backing
EntityType, ornullif the entity's type is not injected
-