EnchantmentPredicate

Link to enchantmentpredicate

Represents the predicate for an MCEnchantment.

The predicate can be used to check various properties of a specific enchantment, such as its level.

This predicate must specify an enchantment to apply to. By default, the enchantment check will pass irregardless of the enchantment's level.

Importing the class

Link to 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.

ZenScript
Copy
import crafttweaker.api.predicate.EnchantmentPredicate;

Extending AnyDefaultingVanillaWrappingPredicate

Link to extending-anydefaultingvanillawrappingpredicate

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

Name: withEnchantment

Sets the enchantment that needs to be present, and whose data needs to be checked.

This parameter is <strong>required</strong>.

Returns: This predicate for chaining.
Return Type: EnchantmentPredicate

ZenScript
Copy
EnchantmentPredicate.withEnchantment(enchantment as MCEnchantment) as EnchantmentPredicate
ParameterTypeDescription
Parameter
enchantment
Type
MCEnchantment
Description
The enchantment that needs to be present.

Name: withExactLevel

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

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

Returns: This predicate for chaining.
Return Type: EnchantmentPredicate

ZenScript
Copy
EnchantmentPredicate.withExactLevel(value as int) as EnchantmentPredicate
ParameterTypeDescription
Parameter
value
Type
int
Description
The exact value the level should be.

Name: withMaximumLevel

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

If the 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 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: EnchantmentPredicate

ZenScript
Copy
EnchantmentPredicate.withMaximumLevel(max as int) as EnchantmentPredicate
ParameterTypeDescription
Parameter
max
Type
int
Description
The maximum value the level should be.

Name: withMinimumLevel

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

If the 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 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: EnchantmentPredicate

ZenScript
Copy
EnchantmentPredicate.withMinimumLevel(min as int) as EnchantmentPredicate
ParameterTypeDescription
Parameter
min
Type
int
Description
The minimum value the level should be.

Name: withRangedLevel

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

If the 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: EnchantmentPredicate

ZenScript
Copy
EnchantmentPredicate.withRangedLevel(min as int, max as int) as EnchantmentPredicate
ParameterTypeDescription
Parameter
min
Type
int
Description
The minimum value the level should be.
Parameter
max
Type
int
Description
The maximum value the level should be.