Package cz.jeme.bestium.api.inject
Interface EntityInjector
@NullMarked
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.<T extends net.minecraft.world.entity.Entity & Injectable>
@Unmodifiable Map<Class<T>, EntityInjection<T, ?>> Returns an unmodifiable view of all registered entity injections.phase()Returns the current phase of the entity injection lifecycle.voidregister(Supplier<EntityInjection<?, ?>> injectionSupplier) Registers a prepared entity injection for later application.<T extends net.minecraft.world.entity.Entity & Injectable>
@Unmodifiable Map<Class<T>, net.minecraft.world.entity.EntityType<T>> types()Returns an unmodifiable view of all generated entity types.
-
Method Details
-
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:
-
injections
<T extends net.minecraft.world.entity.Entity & Injectable> @Unmodifiable Map<Class<T>,EntityInjection<T, injections()?>> Returns an unmodifiable view of all registered entity injections.The returned map contains entity classes as keys and their corresponding
EntityInjectioninstances as values.- Type Parameters:
T- the entity type- 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:
-
types
<T extends net.minecraft.world.entity.Entity & Injectable> @Unmodifiable Map<Class<T>,net.minecraft.world.entity.EntityType<T>> types()Returns an unmodifiable view of all generated entity types.The returned map contains entity classes as keys and their corresponding
EntityTypeinstances as values.- Type Parameters:
T- the entity type- 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:
-
phase
EntityInjector.Phase phase()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
-