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 enumRepresents the lifecycle phases of the entity injection process. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanHelper 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 injectedEntityTypeassociated 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 EntityInjectorinjector()Returns the main entity injector instance, which handles the registration and management of custom entities within Bestium.voidregister(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
EntityInjectioninstances as values.- Returns:
- an unmodifiable map of entity classes to their registered injections
- Throws:
IllegalStateException- if the injector is still in theEntityInjector.Phase.REGISTRATIONorEntityInjector.Phase.PRE_INJECTIONphase- 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
EntityInjectionassociated with the specified entity class, ornullif 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
Keys as keys and their correspondingEntityInjectioninstances as values.- Returns:
- an unmodifiable map of entity keys to their registered injections
- Throws:
IllegalStateException- if the injector is still in theEntityInjector.Phase.REGISTRATIONorEntityInjector.Phase.PRE_INJECTIONphase- 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
EntityTypeinstances 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.INJECTEDphase- 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 injectedEntityTypeassociated 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
EntityTypeassociated with the specified entity class, ornullif no type is found
-
getKeyedTypes
Returns an unmodifiable view of all generated entity types.The returned map contains entity
Keys as keys and their correspondingEntityTypeinstances 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.INJECTEDphase- 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:
trueif the injector is currently in theEntityInjector.Phase.REGISTRATIONphase,falseotherwise
-