LocationPredicate

Link to locationpredicate

Represents a predicate for a location an entity or a block may be in.

This predicate firstly ensures that the given location is inside the coordinate bounds. If the check passes, then the predicate ensures that the dimension, biome, and feature that are at the specified coordinates correctly match the values that have been specified if any. Moreover, the predicate is also able to check if the block is situated above a campfire, or validate either the block or fluid at the current location, using respectively either a BlockPredicate or a FluidPredicate. It is also able to check the light level of the current location with a LightPredicate.

By default, any location is valid for this predicate.

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.LocationPredicate;

Extending AnyDefaultingVanillaWrappingPredicate

Link to extending-anydefaultingvanillawrappingpredicate

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

Name: withBiomeName

Sets the biome in which the location should be.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withBiomeName(biome as MCResourceLocation) as LocationPredicate
ParameterTypeDescription
Parameter
biome
Type
MCResourceLocation
Description
The name of the biome.

Name: withBlockPredicate

Creates and sets the BlockPredicate that will be used to match the block at the location.

Any changes that have been made previously to the block predicate will be discarded, if any.

Returns: The predicate itself for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withBlockPredicate(builder as Consumer<BlockPredicate>) as LocationPredicate
ParameterTypeDescription
Parameter
konstruktor
Type
Consumer<BlockPredicate>
Description
A consumer that will be used to configure the BlockPredicate.

Name: withCampfireBelow

Indicates that the location must be on top of a campfire.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
// LocationPredicate.withCampfireBelow() as LocationPredicate

myLocationPredicate.withCampfireBelow();

Name: withDimension

Sets the dimension where the location should be located in.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withDimension(dimension as MCResourceLocation) as LocationPredicate
ParameterTypeDescription
Parameter
dimension
Type
MCResourceLocation
Description
The name of the dimension.

Name: withExactXPosition

Sets the value of the X position to exactly match the given <code>value</code>.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withExactXPosition(x as float) as LocationPredicate
ParameterTypeDescription
Parameter
x
Type
float
Description
The exact value the X position should assume.

Name: withExactYPosition

Sets the value of the Y position to exactly match the given <code>value</code>.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withExactYPosition(y as int) as LocationPredicate
ParameterTypeDescription
Parameter
y
Type
int
Description
The exact value the Y position should assume.

Name: withExactZPosition

Sets the value of the Z position to exactly match the given <code>value</code>.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withExactZPosition(z as int) as LocationPredicate
ParameterTypeDescription
Parameter
z
Type
int
Description
The exact value the Z position should assume.

Name: withFeatureName

Sets the name of the feature this location should be located in.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withFeatureName(feature as string) as LocationPredicate
ParameterTypeDescription
Parameter
feature
Type
string
Description
The name of the feature.

Name: withFluidPredicate

Creates and sets the FluidPredicate that will be used to match the block at the location, if present.

Any changes that have been made previously to the fluid predicate will be discarded, if any.

Returns: The predicate itself for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withFluidPredicate(builder as Consumer<FluidPredicate>) as LocationPredicate
ParameterTypeDescription
Parameter
konstruktor
Type
Consumer<FluidPredicate>
Description
A consumer that will be used to configure the FluidPredicate.

Name: withLightPredicate

Creates and sets the LightPredicate that will be used to match the light level at the location.

Any changes that have been made previously to the light level predicate will be discarded, if any.

Returns: The predicate itself for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withLightPredicate(builder as Consumer<LightPredicate>) as LocationPredicate
ParameterTypeDescription
Parameter
konstruktor
Type
Consumer<LightPredicate>
Description
A consumer that will be used to configure the LightPredicate.

Link to g-withmaximumxposition

Name: withMaximumXPosition

Sets the maximum value the X position can assume to <code>max</code>.

If the position 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 position 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>min</code> will pass the check.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMaximumXPosition(max as float) as LocationPredicate
ParameterTypeDescription
Parameter
max
Type
float
Description
The maximum value the X position can assume.

Link to g-withmaximumyposition

Name: withMaximumYPosition

Sets the maximum value the Y position can assume to <code>max</code>.

If the position 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 position 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>min</code> will pass the check.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMaximumYPosition(max as float) as LocationPredicate
ParameterTypeDescription
Parameter
max
Type
float
Description
The maximum value the Y position can assume.

Link to g-withmaximumzposition

Name: withMaximumZPosition

Sets the maximum value the Z position can assume to <code>max</code>.

If the position 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 position 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>min</code> will pass the check.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMaximumZPosition(max as float) as LocationPredicate
ParameterTypeDescription
Parameter
max
Type
float
Description
The maximum value the Z position can assume.

Link to g-withminimumxposition

Name: withMinimumXPosition

Sets the minimum value the X position can assume to <code>min</code>.

If the position 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 position 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: LocationPredicate

ZenScript
Copy
LocationPredicate.withMinimumXPosition(min as float) as LocationPredicate
ParameterTypeDescription
Parameter
min
Type
float
Description
The minimum value the X position can assume.

Link to g-withminimumyposition

Name: withMinimumYPosition

Sets the minimum value the Y position can assume to <code>min</code>.

If the position 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 position 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: LocationPredicate

ZenScript
Copy
LocationPredicate.withMinimumYPosition(min as float) as LocationPredicate
ParameterTypeDescription
Parameter
min
Type
float
Description
The minimum value the Y position can assume.

Link to g-withminimumzposition

Name: withMinimumZPosition

Sets the minimum value the Z position can assume to <code>min</code>.

If the position 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 position 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: LocationPredicate

ZenScript
Copy
LocationPredicate.withMinimumZPosition(min as float) as LocationPredicate
ParameterTypeDescription
Parameter
min
Type
float
Description
The minimum value the Z position can assume.

Name: withRangedXPosition

Sets both the minimum and maximum values the X position can assume to <code>min</code> and <code>max</code> respectively.

If the position 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: LocationPredicate

ZenScript
Copy
LocationPredicate.withRangedXPosition(min as float, max as float) as LocationPredicate
ParameterTypeDescription
Parameter
min
Type
float
Description
The minimum value the X position can assume.
Parameter
max
Type
float
Description
The maximum value the X position can assume.

Name: withRangedYPosition

Sets both the minimum and maximum values the Y position can assume to <code>min</code> and <code>max</code> respectively.

If the position 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: LocationPredicate

ZenScript
Copy
LocationPredicate.withRangedYPosition(min as float, max as float) as LocationPredicate
ParameterTypeDescription
Parameter
min
Type
float
Description
The minimum value the Y position can assume.
Parameter
max
Type
float
Description
The maximum value the Y position can assume.

Name: withRangedZPosition

Sets both the minimum and maximum values the Z position can assume to <code>min</code> and <code>max</code> respectively.

If the position 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: LocationPredicate

ZenScript
Copy
LocationPredicate.withRangedZPosition(min as float, max as float) as LocationPredicate
ParameterTypeDescription
Parameter
min
Type
float
Description
The minimum value the Z position can assume.
Parameter
max
Type
float
Description
The maximum value the Z position can assume.

Link to g-withoutcampfirebelow

Name: withoutCampfireBelow

Indicates that the location must not be on top of a campfire.

If the predicate had already been set to check the opposite condition, the setting will be overwritten.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
// LocationPredicate.withoutCampfireBelow() as LocationPredicate

myLocationPredicate.withoutCampfireBelow();