PlayerPredicate

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.

Importing the class

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.

import crafttweaker.api.predicate.PlayerPredicate;

Extending AnyDefaultingVanillaWrappingPredicate

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

Methods

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.

Return Type: PlayerPredicate

PlayerPredicate.withAdvancementPredicate(advancement as string, builder as Consumer<AdvancementPredicate>) as PlayerPredicate
ParameterTypeDescription
advancementstringThe advancement that should be checked.
constructorConsumer<AdvancementPredicate>A consumer to configure the AdvancementPredicate for the given advancement.

withBoundedExperienceLevel

Sets both the minimum and maximum value the experience level should be to min and max 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 min or max will pass the check.

Return Type: PlayerPredicate

PlayerPredicate.withBoundedExperienceLevel(min as int, max as int) as PlayerPredicate
ParameterTypeDescription
minintThe minimum value the experience level should be.
maxintThe maximum value the experience level should be.

withBoundedStatistic

Sets both the minimum and maximum value the statistic should be to minValue and maxValue 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 min or max will pass the check.

Return Type: PlayerPredicate

PlayerPredicate.withBoundedStatistic(type as MCResourceLocation, name as MCResourceLocation, minValue as int, maxValue as int) as PlayerPredicate
ParameterTypeDescription
typeUbicación MCResourceThe statistic's base type.
nameUbicación MCResourceThe statistic's unique identifier.
minValueintThe minimum value the statistic should be.
maxValueintThe maximum value the statistic should be.

withExactExperienceLevel

Sets the experience level to exactly match the given value.

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

Return Type: PlayerPredicate

PlayerPredicate.withExactExperienceLevel(level as int) as PlayerPredicate
ParameterTypeDescription
levelintThe exact value the experience level should be.

withExactStatistic

Sets the statistic to exactly match the given value.

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

Return Type: PlayerPredicate

PlayerPredicate.withExactStatistic(type as MCResourceLocation, name as MCResourceLocation, value as int) as PlayerPredicate
ParameterTypeDescription
typeUbicación MCResourceThe statistic's base type.
nameUbicación MCResourceThe statistic's unique identifier.
valueintThe exact value the statistic should be.

withGameMode

Sets the GameMode the player has to be in.

Return Type: PlayerPredicate

PlayerPredicate.withGameMode(mode as GameMode) as PlayerPredicate
ParameterTypeDescription
modeGameModeThe game mode.

withLockedRecipe

Adds the recipe name 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.

Return Type: PlayerPredicate

PlayerPredicate.withLockedRecipe(name as string) as PlayerPredicate
ParameterTypeDescription
namestringThe name of the recipe that needs to be locked.

withMaximumExperienceLevel

Sets the maximum value the experience level should be to max.

If the experience level had already some bounds specified, then the maximum value of the bound will be overwritten with the value specified in max. 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 max will pass the check.

Return Type: PlayerPredicate

PlayerPredicate.withMaximumExperienceLevel(max as int) as PlayerPredicate
ParameterTypeDescription
maxintThe maximum value the experience level should be.

withMaximumStatistic

Sets the maximum value the statistic should be to max.

If the statistic had already some bounds specified, then the maximum value of the bound will be overwritten with the value specified in max. 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 max will pass the check.

Return Type: PlayerPredicate

PlayerPredicate.withMaximumStatistic(type as MCResourceLocation, name as MCResourceLocation, max as int) as PlayerPredicate
ParameterTypeDescription
typeUbicación MCResourceThe statistic's base type.
nameUbicación MCResourceThe statistic's unique identifier.
maxintThe maximum value the statistic should be.

withMinimumExperienceLevel

Sets the minimum value the experience level should be to min.

If the experience level had already some bounds specified, then the minimum value of the bound will be overwritten with the value specified in min. 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 min will pass the check.

Return Type: PlayerPredicate

PlayerPredicate.withMinimumExperienceLevel(min as int) as PlayerPredicate
ParameterTypeDescription
minintThe minimum value the experience level should be.

withMinimumStatistic

Sets the minimum value the statistic should be to min.

If the statistic had already some bounds specified, then the minimum value of the bound will be overwritten with the value specified in min. 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 min will pass the check.

Return Type: PlayerPredicate

PlayerPredicate.withMinimumStatistic(type as MCResourceLocation, name as MCResourceLocation, min as int) as PlayerPredicate
ParameterTypeDescription
typeUbicación MCResourceThe statistic's base type.
nameUbicación MCResourceThe statistic's unique identifier.
minintThe minimum value the statistic should be.

withUnlockedRecipe

Adds the recipe name 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.

Return Type: PlayerPredicate

PlayerPredicate.withUnlockedRecipe(name as string) as PlayerPredicate
ParameterTypeDescription
namestringThe name of the recipe that needs to be unlocked.