Interface Selector.Builder
-
- All Superinterfaces:
AbstractBuilder<Selector>
,Buildable.Builder<Selector>
,Builder<Selector,Selector.Builder>
,ResettableBuilder<Selector,Selector.Builder>
- Enclosing interface:
- Selector
public static interface Selector.Builder extends Builder<Selector,Selector.Builder>
Creates aSelector
based on the provided criteria.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Selector.Builder
addAdvancement(Advancement advancement)
Adds anAdvancement
constraint to this selector, requiring that the advancement must be granted to be selected.Selector.Builder
addAdvancementCriterion(Advancement advancement, AdvancementCriterion criterion)
Adds anAdvancementCriterion
constraint to this selector, requiring that the criterion on the givenAdvancement
must be granted to be selected.Selector.Builder
addEntityType(Supplier<EntityType<?>> type, boolean inherit)
Adds anEntityType
constraint to this selector, requiring that all selected entities must be of the given type.Selector.Builder
addEntityType(EntityType<?> type, boolean inherit)
Adds anEntityType
constraint to this selector, requiring that all selected entities must be of the given type.Selector.Builder
addFilter(Predicate<Entity> filter)
Applies a custom filter to the selector that must also be met by anyentities
that may otherwise be selected by this selector.Selector.Builder
addGameMode(Supplier<? extends GameMode> mode)
Adds aGameMode
constraint to the selector, requiring players be in the given game mode.Selector.Builder
addGameMode(GameMode mode)
Adds aGameMode
constraint to the selector, requiring players be in the given game modeSelector.Builder
addName(String name)
Adds a name constraint to the selector, requiring that entities have a specific name.Selector.Builder
addNotAdvancement(Advancement advancement)
Adds anAdvancement
constraint to this selector, requiring that the advancement must NOT be granted to be selected.Selector.Builder
addNotAdvancementCriterion(Advancement advancement, AdvancementCriterion criterion)
Adds anAdvancementCriterion
constraint to this selector, requiring that the criterion on the givenAdvancement
must not be granted to be selected.Selector.Builder
addNotEntityType(Supplier<EntityType<?>> type)
Adds anEntityType
constraint to this selector, requiring that all selected entities must not be of the given type.Selector.Builder
addNotEntityType(EntityType<?> type)
Adds anEntityType
constraint to this selector, requiring that all selected entities must not be of the given type.Selector.Builder
addNotGameMode(Supplier<? extends GameMode> mode)
Adds aGameMode
constraint to the selector, requiring that players are not in the given game modeSelector.Builder
addNotGameMode(GameMode mode)
Adds aGameMode
constraint to the selector, requiring that players are not in the given game modeSelector.Builder
addNotName(String name)
Adds a name constraint to the selector, requiring that entities do not have a specific name.Selector.Builder
addNotTag(String tag)
Adds a tag constraint to the selector, requiring that entities do not have a given tag.Selector.Builder
addNotTeam(Team team)
Adds aTeam
constraint to the selector, requiring that players are not in a specific teamSelector.Builder
addObjective(Objective objective, Range<Integer> range)
Adds anObjective
constraint to the selector, requiring that players have a given score in an objective in a given range (inclusive).Selector.Builder
addTag(String tag)
Adds a tag constrain to the selector, requiring that entities have a given tag.Selector.Builder
addTeam(Team team)
Adds aTeam
constraint to the selector, requiring that players are in a specific teamSelector.Builder
anyTeam()
Adds aTeam
constraint to the selector, requiring that players are in any teamSelector.Builder
applySelectorType(Supplier<? extends SelectorType> selectorType)
Applies the defaults associated with a givenSelectorType
Selector.Builder
applySelectorType(SelectorType selectorType)
Applies the defaults associated with a givenSelectorType
Selector
build()
Creates aSelector
based on this builder.Selector.Builder
dataView(DataView view)
Adds anDataView
as an NBT style constraint.Selector.Builder
distance(Range<Double> range)
Sets the minimum and/or maximum distance from the target location that this selector will look.Selector.Builder
experienceLevel(Range<Integer> range)
Adds an experience level constraint to the selector, specifying that a player's level must be in the provided range (inclusive).Selector.Builder
includeSelf()
If the selector's source is anEntity
and this is called, the source is eligible to be selected if all other criteria are met.Selector.Builder
limit(int limit)
Limits the number ofentities
returned by the selector.Selector.Builder
noTeam()
Adds aTeam
constraint to the selector, requiring that players are not in any teamSelector.Builder
pitch(Range<Double> range)
Adds a pitch constraint to the selector, requiring that entities have a pitch (x_rotation) within the given range, inclusive.Selector.Builder
sortAlgorithm(Supplier<? extends SelectorSortAlgorithm> algorithm)
Sets the sorting algorithm to use when returning entities from the selector.Selector.Builder
sortAlgorithm(SelectorSortAlgorithm algorithm)
Sets the sorting algorithm to use when returning entities from the selector.Selector.Builder
volume(Vector3d corner1, Vector3d corner2)
Sets the volume that entities can be selected from.Selector.Builder
yaw(Range<Double> range)
Adds a yaw constraint to the selector, requiring that entities have a yaw (y_rotation) within the given range, inclusive.
-
-
-
Method Detail
-
applySelectorType
Selector.Builder applySelectorType(Supplier<? extends SelectorType> selectorType)
Applies the defaults associated with a givenSelectorType
- Parameters:
selectorType
- TheSelectorType
- Returns:
- This builder, for chaining
-
applySelectorType
Selector.Builder applySelectorType(SelectorType selectorType)
Applies the defaults associated with a givenSelectorType
- Parameters:
selectorType
- TheSelectorType
- Returns:
- This builder, for chaining
-
includeSelf
Selector.Builder includeSelf()
If the selector's source is anEntity
and this is called, the source is eligible to be selected if all other criteria are met.- Returns:
- This builder, for chaining.
-
limit
Selector.Builder limit(int limit)
Limits the number ofentities
returned by the selector.- Parameters:
limit
- The maximum number of entities to return- Returns:
- This builder, for chaining
-
distance
Selector.Builder distance(Range<Double> range)
Sets the minimum and/or maximum distance from the target location that this selector will look.- Parameters:
range
- The range- Returns:
- This builder, for chaining
-
volume
Selector.Builder volume(Vector3d corner1, Vector3d corner2)
Sets the volume that entities can be selected from. Entities that have any part of their hitbox within this two specified corners will be eligible to be selected.- Parameters:
corner1
- The first cornercorner2
- The second corner (may be equal to the first to select entities at a specific point instead)- Returns:
- This builder, for chaining
-
sortAlgorithm
Selector.Builder sortAlgorithm(Supplier<? extends SelectorSortAlgorithm> algorithm)
Sets the sorting algorithm to use when returning entities from the selector.- Parameters:
algorithm
- TheSelectorSortAlgorithm
- Returns:
- This builder, for chaining
-
sortAlgorithm
Selector.Builder sortAlgorithm(SelectorSortAlgorithm algorithm)
Sets the sorting algorithm to use when returning entities from the selector.- Parameters:
algorithm
- TheSelectorSortAlgorithm
- Returns:
- This builder, for chaining
-
addAdvancement
Selector.Builder addAdvancement(Advancement advancement)
Adds anAdvancement
constraint to this selector, requiring that the advancement must be granted to be selected.- Parameters:
advancement
- The advancement that players must have.- Returns:
- This builder, for chaining
-
addNotAdvancement
Selector.Builder addNotAdvancement(Advancement advancement)
Adds anAdvancement
constraint to this selector, requiring that the advancement must NOT be granted to be selected.- Parameters:
advancement
- The advancement that players must not have.- Returns:
- This builder, for chaining
-
addAdvancementCriterion
Selector.Builder addAdvancementCriterion(Advancement advancement, AdvancementCriterion criterion)
Adds anAdvancementCriterion
constraint to this selector, requiring that the criterion on the givenAdvancement
must be granted to be selected.- Parameters:
advancement
- The advancementcriterion
- The criterion the player must have- Returns:
- This builder, for chaining
-
addNotAdvancementCriterion
Selector.Builder addNotAdvancementCriterion(Advancement advancement, AdvancementCriterion criterion)
Adds anAdvancementCriterion
constraint to this selector, requiring that the criterion on the givenAdvancement
must not be granted to be selected.- Parameters:
advancement
- The advancementcriterion
- The criterion the player must not have- Returns:
- This builder, for chaining
-
dataView
Selector.Builder dataView(DataView view)
Adds anDataView
as an NBT style constraint.- Parameters:
view
- The data view- Returns:
- This builder, for chaining
-
addEntityType
Selector.Builder addEntityType(Supplier<EntityType<?>> type, boolean inherit)
Adds anEntityType
constraint to this selector, requiring that all selected entities must be of the given type.If
inherit
is true, entities may also be a subtype of the given type.- Parameters:
type
- The typeinherit
- Whether subtypes will also be selected- Returns:
- This builder, for chaining
-
addEntityType
Selector.Builder addEntityType(EntityType<?> type, boolean inherit)
Adds anEntityType
constraint to this selector, requiring that all selected entities must be of the given type.If
inherit
is true, entities may also be a subtype of the given type.- Parameters:
type
- The typeinherit
- Whether subtypes will also be selected- Returns:
- This builder, for chaining
-
addNotEntityType
Selector.Builder addNotEntityType(Supplier<EntityType<?>> type)
Adds anEntityType
constraint to this selector, requiring that all selected entities must not be of the given type.- Parameters:
type
- The type- Returns:
- This builder, for chaining
-
addNotEntityType
Selector.Builder addNotEntityType(EntityType<?> type)
Adds anEntityType
constraint to this selector, requiring that all selected entities must not be of the given type.- Parameters:
type
- The type- Returns:
- This builder, for chaining
-
experienceLevel
Selector.Builder experienceLevel(Range<Integer> range)
Adds an experience level constraint to the selector, specifying that a player's level must be in the provided range (inclusive).- Parameters:
range
- The range- Returns:
- This builder, for chaining
-
addGameMode
Selector.Builder addGameMode(Supplier<? extends GameMode> mode)
Adds aGameMode
constraint to the selector, requiring players be in the given game mode.Cannot be used with
addNotGameMode(GameMode)
.- Parameters:
mode
- The gamemode- Returns:
- This builder, for chaining
-
addGameMode
Selector.Builder addGameMode(GameMode mode)
Adds aGameMode
constraint to the selector, requiring players be in the given game modeCannot be used with
addNotGameMode(GameMode)
.- Parameters:
mode
- The gamemode- Returns:
- This builder, for chaining
-
addNotGameMode
Selector.Builder addNotGameMode(Supplier<? extends GameMode> mode)
Adds aGameMode
constraint to the selector, requiring that players are not in the given game modeCannot be used with
addGameMode(GameMode)
.- Parameters:
mode
- The gamemode- Returns:
- This builder, for chaining
-
addNotGameMode
Selector.Builder addNotGameMode(GameMode mode)
Adds aGameMode
constraint to the selector, requiring that players are not in the given game modeCannot be used with
addGameMode(GameMode)
.- Parameters:
mode
- The gamemode- Returns:
- This builder, for chaining
-
anyTeam
Selector.Builder anyTeam()
Adds aTeam
constraint to the selector, requiring that players are in any team- Returns:
- This builder, for chaining
-
noTeam
Selector.Builder noTeam()
Adds aTeam
constraint to the selector, requiring that players are not in any team- Returns:
- This builder, for chaining
-
addTeam
Selector.Builder addTeam(Team team)
Adds aTeam
constraint to the selector, requiring that players are in a specific teamCannot be used with
addNotTeam(Team)
- Parameters:
team
- The specific team- Returns:
- This builder, for chaining
-
addNotTeam
Selector.Builder addNotTeam(Team team)
Adds aTeam
constraint to the selector, requiring that players are not in a specific teamCannot be used with
addTeam(Team)
- Parameters:
team
- The specific team- Returns:
- This builder, for chaining
-
addName
Selector.Builder addName(String name)
Adds a name constraint to the selector, requiring that entities have a specific name.Cannot be used with
addNotName(String)
.- Parameters:
name
- The name- Returns:
- This builder, for chaining
-
addNotName
Selector.Builder addNotName(String name)
Adds a name constraint to the selector, requiring that entities do not have a specific name.Cannot be used with
addName(String)
.- Parameters:
name
- The name- Returns:
- This builder, for chaining
-
addObjective
Selector.Builder addObjective(Objective objective, Range<Integer> range)
Adds anObjective
constraint to the selector, requiring that players have a given score in an objective in a given range (inclusive).- Parameters:
objective
- The objective to check againstrange
- The range- Returns:
- This builder, for chaining
-
addTag
Selector.Builder addTag(String tag)
Adds a tag constrain to the selector, requiring that entities have a given tag.Cannot be used with
addNotTag(String)
.- Parameters:
tag
- The tag- Returns:
- This builder, for chaining
-
addNotTag
Selector.Builder addNotTag(String tag)
Adds a tag constraint to the selector, requiring that entities do not have a given tag.Cannot be used with
addTag(String)
.- Parameters:
tag
- The tag- Returns:
- This builder, for chaining
-
pitch
Selector.Builder pitch(Range<Double> range)
Adds a pitch constraint to the selector, requiring that entities have a pitch (x_rotation) within the given range, inclusive.The pitch is in degrees, where 0 is considered parallel to the ground, -90 is straight up, and 90 is straight down.
- Parameters:
range
- The range- Returns:
- This builder, for chaining
-
yaw
Selector.Builder yaw(Range<Double> range)
Adds a yaw constraint to the selector, requiring that entities have a yaw (y_rotation) within the given range, inclusive.The yaw is in degrees, where 0 is considered due south. The angle is measured clockwise, so 90 is west, 180 is north and 270 is east.
- Parameters:
range
- The range- Returns:
- This builder, for chaining
-
addFilter
Selector.Builder addFilter(Predicate<Entity> filter)
Applies a custom filter to the selector that must also be met by anyentities
that may otherwise be selected by this selector.- Parameters:
filter
- APredicate
used for filtering- Returns:
- This builder, for chaining
-
build
Selector build() throws IllegalStateException
Creates aSelector
based on this builder.- Specified by:
build
in interfaceAbstractBuilder<Selector>
- Specified by:
build
in interfaceBuildable.Builder<Selector>
- Returns:
- A
Selector
- Throws:
IllegalStateException
- if the builder could not create a selector
-
-