Represents a predicate for a player, as a specialization of EntityPredicate.

This predicate can be used to check various properties of the player entity, such as the game mode, experience, unlocked advancements and recipes, or statistics.

By default, the entity passes the checks without caring about the entity type. If at least one of the properties is set, then the entity must be a player to pass the checks.

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.predicate.PlayerPredicate;

Extending AnyDefaultingVanillaWrappingPredicate

Link to extending-anydefaultingvanillawrappingpredicate

PlayerPredicate extends AnyDefaultingVanillaWrappingPredicate. That means all methods available in AnyDefaultingVanillaWrappingPredicate are also available in PlayerPredicate

Link to g-withadvancementpredicate

Name: withAdvancementPredicate

Adds an advancement to the ones that should be checked, along with the AdvancementPredicate that should be used to validate it.

If the same advancement had already been added to the map with a different predicate, then the previous configuration is replaced. Otherwise the addition completes normally.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withAdvancementPredicate(advancement as string, builder as Consumer<AdvancementPredicate>) as PlayerPredicate
参数类型描述
参数
advancement
类型
string
描述
The advancement that should be checked.
参数
生成器
类型
Consumer<AdvancementPredicate>
描述
A consumer to configure the AdvancementPredicate for the given advancement.

Link to g-withboundedexperiencelevel

Name: withBoundedExperienceLevel

Sets both the minimum and maximum value the experience level should be to <code>min</code> and <code>max</code> respectively.

If the experience level had already some bounds specified, then they will be overwritten with the new values.

Both minimum and maximum values are inclusive, meaning that a value that is equal to either <code>min</code> or <code>max</code> will pass the check.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withBoundedExperienceLevel(min as int, max as int) as PlayerPredicate
参数类型描述
参数
min
类型
int
描述
The minimum value the experience level should be.
参数
max
类型
int
描述
The maximum value the experience level should be.

Link to g-withboundedstatistic

Name: withBoundedStatistic

Sets both the minimum and maximum value the statistic should be to <code>minValue</code> and <code>maxValue</code> respectively.

If the statistic had already some bounds specified, then they will be overwritten with the new values.

Both minimum and maximum values are inclusive, meaning that a value that is equal to either <code>min</code> or <code>max</code> will pass the check.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withBoundedStatistic(type as MCResourceLocation, name as MCResourceLocation, minValue as int, maxValue as int) as PlayerPredicate
参数类型描述
参数
类型
类型
MCResourceLocation
描述
The statistic's base type.
参数
name(名称)
类型
MCResourceLocation
描述
The statistic's unique identifier.
参数
minValue
类型
int
描述
The minimum value the statistic should be.
参数
maxValue
类型
int
描述
The maximum value the statistic should be.

Link to g-withexactexperiencelevel

Name: withExactExperienceLevel

Sets the experience level to exactly match the given <code>value</code>.

If the experience level had already some bounds specified, then they will be overwritten with the new value.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withExactExperienceLevel(level as int) as PlayerPredicate
参数类型描述
参数
level
类型
int
描述
The exact value the experience level should be.

Name: withExactStatistic

Sets the statistic to exactly match the given <code>value</code>.

If the statistic had already some bounds specified, then they will be overwritten with the new value.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withExactStatistic(type as MCResourceLocation, name as MCResourceLocation, value as int) as PlayerPredicate
参数类型描述
参数
类型
类型
MCResourceLocation
描述
The statistic's base type.
参数
name(名称)
类型
MCResourceLocation
描述
The statistic's unique identifier.
参数
类型
int
描述
The exact value the statistic should be.

Name: withGameMode

Sets the GameMode the player has to be in.

Returns: This player for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withGameMode(mode as GameMode) as PlayerPredicate
参数类型描述
参数
mode
类型
GameMode
描述
The game mode.

Name: withLockedRecipe

Adds the recipe <code>name</code> to the list of recipes that have to be locked.

If the predicate had already been set to check for this recipe's unlocked status, the setting is overwritten.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withLockedRecipe(name as string) as PlayerPredicate
参数类型描述
参数
name(名称)
类型
string
描述
The name of the recipe that needs to be locked.

Link to g-withmaximumexperiencelevel

Name: withMaximumExperienceLevel

Sets the maximum value the experience level should be to <code>max</code>.

If the experience level had already some bounds specified, then the maximum value of the bound will be overwritten with the value specified in <code>max</code>. On the other hand, if the experience level didn't have any bounds set, the maximum is set, leaving the lower end unbounded.

The maximum value is inclusive, meaning that a value that is equal to <code>max</code> will pass the check.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withMaximumExperienceLevel(max as int) as PlayerPredicate
参数类型描述
参数
max
类型
int
描述
The maximum value the experience level should be.

Link to g-withmaximumstatistic

Name: withMaximumStatistic

Sets the maximum value the statistic should be to <code>max</code>.

If the statistic had already some bounds specified, then the maximum value of the bound will be overwritten with the value specified in <code>max</code>. On the other hand, if the statistic didn't have any bounds set, the maximum is set, leaving the upper end unbounded.

The maximum value is inclusive, meaning that a value that is equal to <code>max</code> will pass the check.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withMaximumStatistic(type as MCResourceLocation, name as MCResourceLocation, max as int) as PlayerPredicate
参数类型描述
参数
类型
类型
MCResourceLocation
描述
The statistic's base type.
参数
name(名称)
类型
MCResourceLocation
描述
The statistic's unique identifier.
参数
max
类型
int
描述
The maximum value the statistic should be.

Link to g-withminimumexperiencelevel

Name: withMinimumExperienceLevel

Sets the minimum value the experience level should be to <code>min</code>.

If the experience level had already some bounds specified, then the minimum value of the bound will be overwritten with the value specified in <code>min</code>. On the other hand, if the experience level didn't have any bounds set, the minimum is set, leaving the upper end unbounded.

The minimum value is inclusive, meaning that a value that is equal to <code>min</code> will pass the check.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withMinimumExperienceLevel(min as int) as PlayerPredicate
参数类型描述
参数
min
类型
int
描述
The minimum value the experience level should be.

Link to g-withminimumstatistic

Name: withMinimumStatistic

Sets the minimum value the statistic should be to <code>min</code>.

If the statistic had already some bounds specified, then the minimum value of the bound will be overwritten with the value specified in <code>min</code>. On the other hand, if the statistic didn't have any bounds set, the minimum is set, leaving the upper end unbounded.

The minimum value is inclusive, meaning that a value that is equal to <code>min</code> will pass the check.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withMinimumStatistic(type as MCResourceLocation, name as MCResourceLocation, min as int) as PlayerPredicate
参数类型描述
参数
类型
类型
MCResourceLocation
描述
The statistic's base type.
参数
name(名称)
类型
MCResourceLocation
描述
The statistic's unique identifier.
参数
min
类型
int
描述
The minimum value the statistic should be.

Name: withUnlockedRecipe

Adds the recipe <code>name</code> to the list of recipes that have to be unlocked.

If the predicate had already been set to check for this recipe's locked status, the setting is overwritten.

Returns: This predicate for chaining.
Return Type: PlayerPredicate

ZenScript
Copy
PlayerPredicate.withUnlockedRecipe(name as string) as PlayerPredicate
参数类型描述
参数
name(名称)
类型
string
描述
The name of the recipe that needs to be unlocked.