Package cz.jeme.bestium.api.inject
Interface EntityInjector
@NonExtendable
public interface EntityInjector
Responsible for injecting custom entities into the Minecraft server runtime.
Handles registration of custom
Entity
types, assigns attributes,
registers them into both the Minecraft and Bukkit registries, and ensures proper
data fixer and type mapping.
After registration, the system becomes frozen and no further entities can be registered.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Represents the lifecycle phases of the entity injection process. -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Helper method that returns whether injection registrations are still allowed.default <T extends net.minecraft.world.entity.Entity>
@Nullable EntityInjection<T, ?> getInjection
(Class<T> entityClass) Retrieves the registered entity injection for the specified entity class.@Unmodifiable Map
<Class<? extends net.minecraft.world.entity.Entity>, EntityInjection<?, ?>> Returns an unmodifiable view of all registered entity injections.@Unmodifiable Map
<Key, EntityInjection<?, ?>> Returns an unmodifiable view of all registered entity injections.Returns an unmodifiable view of all generated entity types.getPhase()
Returns the current phase of the entity injection lifecycle.default <T extends net.minecraft.world.entity.Entity>
@Nullable net.minecraft.world.entity.EntityType<T> Retrieves the injectedEntityType
associated with the specified entity class.@Unmodifiable Map
<Class<? extends net.minecraft.world.entity.Entity>, net.minecraft.world.entity.EntityType<?>> getTypes()
Returns an unmodifiable view of all generated entity types.static EntityInjector
injector()
Returns the main entity injector instance, which handles the registration and management of custom entities within Bestium.void
register
(Supplier<EntityInjection<?, ?>> injectionSupplier) Registers a prepared entity injection for later application.
-
Method Details
-
injector
Returns the main entity injector instance, which handles the registration and management of custom entities within Bestium.- Returns:
- the injector instance
-
register
Registers a prepared entity injection for later application.Should be called before the registration phase ends.
- Parameters:
injectionSupplier
- supplier that provides the entity injection to register- Throws:
IllegalStateException
- if the injector is already frozen and no more entities can be registered- See Also:
-
getInjections
@Unmodifiable Map<Class<? extends net.minecraft.world.entity.Entity>,EntityInjection<?, getInjections()?>> Returns an unmodifiable view of all registered entity injections.The returned map contains entity classes as keys and their corresponding
EntityInjection
instances as values.- Returns:
- an unmodifiable map of entity classes to their registered injections
- Throws:
IllegalStateException
- if the injector is still in theEntityInjector.Phase.REGISTRATION
orEntityInjector.Phase.PRE_INJECTION
phase- See Also:
-
getInjection
@Nullable default <T extends net.minecraft.world.entity.Entity> @Nullable EntityInjection<T,?> getInjection(Class<T> entityClass) Retrieves the registered entity injection for the specified entity class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
- the class of the entity for which the injection is to be retrieved- Returns:
- the
EntityInjection
associated with the specified entity class, ornull
if no injection is registered for the class
-
getKeyedInjections
@Unmodifiable Map<Key,EntityInjection<?, getKeyedInjections()?>> Returns an unmodifiable view of all registered entity injections.The returned map contains entity
Key
s as keys and their correspondingEntityInjection
instances as values.- Returns:
- an unmodifiable map of entity keys to their registered injections
- Throws:
IllegalStateException
- if the injector is still in theEntityInjector.Phase.REGISTRATION
orEntityInjector.Phase.PRE_INJECTION
phase- See Also:
-
getTypes
@Unmodifiable Map<Class<? extends net.minecraft.world.entity.Entity>,net.minecraft.world.entity.EntityType<?>> getTypes()Returns an unmodifiable view of all generated entity types.The returned map contains entity classes as keys and their corresponding
EntityType
instances as values.- Returns:
- an unmodifiable map of entity classes to their generated entity types
- Throws:
IllegalStateException
- if the injector is in any other than theEntityInjector.Phase.INJECTED
phase- See Also:
-
getType
@Nullable default <T extends net.minecraft.world.entity.Entity> @Nullable net.minecraft.world.entity.EntityType<T> getType(Class<T> entityClass) Retrieves the injectedEntityType
associated with the specified entity class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
- the class of the entity for which the type is to be retrieved- Returns:
- the injected
EntityType
associated with the specified entity class, ornull
if no type is found
-
getKeyedTypes
Returns an unmodifiable view of all generated entity types.The returned map contains entity
Key
s as keys and their correspondingEntityType
instances as values.- Returns:
- an unmodifiable map of entity keys to their generated entity types
- Throws:
IllegalStateException
- if the injector is in any other than theEntityInjector.Phase.INJECTED
phase- See Also:
-
getPhase
EntityInjector.Phase getPhase()Returns the current phase of the entity injection lifecycle.- Returns:
- the current
EntityInjector.Phase
-
canRegister
default boolean canRegister()Helper method that returns whether injection registrations are still allowed.- Returns:
true
if the injector is currently in theEntityInjector.Phase.REGISTRATION
phase,false
otherwise
-