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 backingEntityType
of 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 backingEntityType
of the given BukkitEntity
.@Nullable EntityInjection
<?, ?> getInjection
(net.minecraft.world.entity.Entity entity) default @Nullable EntityInjection
<?, ?> getInjection
(Entity entity) static EntityManager
Retrieves the BestiumEntityManager
instance, which handles the management and lifecycle of custom Bestium entities.default boolean
isInjected
(net.minecraft.world.entity.Entity entity) Checks whether the given MinecraftEntity
is an injected entity.boolean
isInjected
(net.minecraft.world.entity.EntityType<?> type) Checks whether the givenEntityType
is an injected entity type.default boolean
isInjected
(Entity entity) Checks whether the given BukkitEntity
is an injected entity.default EntityInjection
<?, ?> requireInjection
(net.minecraft.world.entity.Entity entity) Retrieves the BestiumEntityInjection
of the injected MinecraftEntity
.default EntityInjection
<?, ?> requireInjection
(Entity entity) Retrieves the BestiumEntityInjection
of 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 BestiumEntityManager
instance, which handles the management and lifecycle of custom Bestium entities.- Returns:
- the
EntityManager
instance
-
isInjected
Checks whether the given BukkitEntity
is an injected entity.- Parameters:
entity
- the BukkitEntity
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 MinecraftEntity
is an injected entity.- Parameters:
entity
- the MinecraftEntity
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 givenEntityType
is an injected entity type.- Parameters:
type
- theEntityType
to check- Returns:
true
if the entity type was injected by Bestium,false
otherwise
-
getInjection
- Parameters:
entity
- the BukkitEntity
to retrieve the injection from- Returns:
- the
EntityInjection
used to inject the entity type, ornull
if the entity is not an injected entity
-
getInjection
- Parameters:
entity
- the MinecraftEntity
to retrieve the injection from- Returns:
- the
EntityInjection
used to inject the entity type, ornull
if the entity is not an injected entity
-
requireInjection
Retrieves the BestiumEntityInjection
of the injected BukkitEntity
.Throws an
IllegalArgumentException
if the entity is not an injected entity.- Parameters:
entity
- the BukkitEntity
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
Retrieves the BestiumEntityInjection
of the injected MinecraftEntity
.Throws an
IllegalArgumentException
if the given entity is not an injected entity.- Parameters:
entity
- the MinecraftEntity
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 spawnentityClass
- the class of the injected entity to spawnentitySpawnReason
- the MinecraftEntitySpawnReason
to use when spawningcreatureSpawnReason
- the BukkitCreatureSpawnEvent.SpawnReason
to 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
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 spawnentityClass
- the class of the injected entity to spawnentitySpawnReason
- the MinecraftEntitySpawnReason
to use when spawningcreatureSpawnReason
- the BukkitCreatureSpawnEvent.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
- theEntityType
to retrieve the backing type for- Returns:
- the backing
EntityType
, ornull
if type is not injected
-
getBackingType
default @Nullable net.minecraft.world.entity.EntityType<?> getBackingType(net.minecraft.world.entity.Entity entity) Retrieves the backingEntityType
of the given MinecraftEntity
.- Parameters:
entity
- the MinecraftEntity
to retrieve the backing type for- Returns:
- the backing
EntityType
, ornull
if the entity's type is not injected
-
getBackingType
Retrieves the backingEntityType
of the given BukkitEntity
.- Parameters:
entity
- the BukkitEntity
to retrieve the backing type for- Returns:
- the backing
EntityType
, ornull
if the entity's type is not injected
-