Class ScriptedSpawner.EntityBuilder<T extends IEntity>

Type Parameters:
T - The entity type.
Direct Known Subclasses:
ScriptedSpawner.CreatureBuilder, ScriptedSpawner.PropBuilder
Enclosing class:
ScriptedSpawner

public static class ScriptedSpawner.EntityBuilder<T extends IEntity>

Configures an entity before adding it to an environment.

Builders are reusable when their factory creates a fresh entity for every invocation.

  • Field Details

  • Constructor Details

    • EntityBuilder

      public EntityBuilder(Environment env, Supplier<T> factory)
      Creates an entity builder.
      Parameters:
      env - The destination environment.
      factory - The entity factory.
  • Method Details

    • at

      public ScriptedSpawner.EntityBuilder<T> at(double x, double y)
      Sets the spawn coordinates.
      Parameters:
      x - The map x-coordinate.
      y - The map y-coordinate.
      Returns:
      This builder.
    • at

      public ScriptedSpawner.EntityBuilder<T> at(Point2D location)
      Sets the spawn location.
      Parameters:
      location - The location in map coordinates; null leaves it unchanged.
      Returns:
      This builder.
    • withName

      public ScriptedSpawner.EntityBuilder<T> withName(String name)
      Sets the entity name.
      Parameters:
      name - The name to assign.
      Returns:
      This builder.
    • withTags

      public ScriptedSpawner.EntityBuilder<T> withTags(String... tags)
      Sets tags to add to the entity.
      Parameters:
      tags - The tags; null entries are ignored.
      Returns:
      This builder.
    • withRenderType

      public ScriptedSpawner.EntityBuilder<T> withRenderType(RenderType renderType)
      Sets the entity's render layer.
      Parameters:
      renderType - The render type, or null to preserve the entity default.
      Returns:
      This builder.
    • withHealth

      public ScriptedSpawner.EntityBuilder<T> withHealth(int health)
      Sets current and maximum hit points when the entity supports combat.
      Parameters:
      health - The hit-point value.
      Returns:
      This builder.
    • configure

      public ScriptedSpawner.EntityBuilder<T> configure(Consumer<T> customizer)
      Sets an operation invoked after standard configuration but before insertion.
      Parameters:
      customizer - The customizer, or null for none.
      Returns:
      This builder.
    • spawn

      public T spawn()
      Creates, configures, and adds an entity to the environment.
      Returns:
      The spawned entity, or null if the factory returned null.