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 Summary
FieldsModifier and TypeFieldDescriptionprotected final Environmentprotected Integerprotected Point2Dprotected Stringprotected RenderTypeprotected String[] -
Constructor Summary
ConstructorsConstructorDescriptionEntityBuilder(Environment env, Supplier<T> factory) Creates an entity builder. -
Method Summary
Modifier and TypeMethodDescriptionat(double x, double y) Sets the spawn coordinates.Sets the spawn location.Sets an operation invoked after standard configuration but before insertion.spawn()Creates, configures, and adds an entity to the environment.withHealth(int health) Sets current and maximum hit points when the entity supports combat.Sets the entity name.withRenderType(RenderType renderType) Sets the entity's render layer.Sets tags to add to the entity.
-
Field Details
-
env
-
factory
-
location
-
name
-
tags
-
renderType
-
health
-
customizer
-
-
Constructor Details
-
EntityBuilder
Creates an entity builder.- Parameters:
env- The destination environment.factory- The entity factory.
-
-
Method Details
-
at
Sets the spawn coordinates.- Parameters:
x- The map x-coordinate.y- The map y-coordinate.- Returns:
- This builder.
-
at
Sets the spawn location.- Parameters:
location- The location in map coordinates;nullleaves it unchanged.- Returns:
- This builder.
-
withName
Sets the entity name.- Parameters:
name- The name to assign.- Returns:
- This builder.
-
withTags
Sets tags to add to the entity.- Parameters:
tags- The tags; null entries are ignored.- Returns:
- This builder.
-
withRenderType
Sets the entity's render layer.- Parameters:
renderType- The render type, ornullto preserve the entity default.- Returns:
- This builder.
-
withHealth
Sets current and maximum hit points when the entity supports combat.- Parameters:
health- The hit-point value.- Returns:
- This builder.
-
configure
Sets an operation invoked after standard configuration but before insertion.- Parameters:
customizer- The customizer, ornullfor none.- Returns:
- This builder.
-
spawn
Creates, configures, and adds an entity to the environment.- Returns:
- The spawned entity, or
nullif the factory returnednull.
-