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 Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Represents the lifecycle phases of the entity injection process.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Helper 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.
    Returns the current phase of the entity injection lifecycle.
    void
    register(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>>
    Returns an unmodifiable view of all generated entity types.
  • Method Details

    • register

      void register(Supplier<EntityInjection<?,?>> injectionSupplier)
      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 EntityInjection instances 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 the EntityInjector.Phase.REGISTRATION or EntityInjector.Phase.PRE_INJECTION phase
      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 EntityType instances 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 the EntityInjector.Phase.INJECTED phase
      See Also:
    • 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:
      true if the injector is currently in the EntityInjector.Phase.REGISTRATION phase, false otherwise