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.

Importare la Classe

Link to importare-la-classe

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
ParametroTipoDescrizione
Parametro
biome
Tipo
MCResourceLocation
Descrizione
The name of the biome.

Link to withBlockPredicate

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
ParametroTipoDescrizione
Parametro
costruttore
Tipo
Consumer<BlockPredicate>
Descrizione
A consumer that will be used to configure the BlockPredicate.

Link to withCampfireBelow

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
ParametroTipoDescrizione
Parametro
dimension
Tipo
MCResourceLocation
Descrizione
The name of the dimension.

Link to withExactXPosition

Name: withExactXPosition

Sets the value of the X position to exactly match the given value.

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
ParametroTipoDescrizione
Parametro
x
Tipo
float
Descrizione
The exact value the X position should assume.

Link to withExactYPosition

Name: withExactYPosition

Sets the value of the Y position to exactly match the given value.

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
ParametroTipoDescrizione
Parametro
y
Tipo
int
Descrizione
The exact value the Y position should assume.

Link to withExactZPosition

Name: withExactZPosition

Sets the value of the Z position to exactly match the given value.

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
ParametroTipoDescrizione
Parametro
z
Tipo
int
Descrizione
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
ParametroTipoDescrizione
Parametro
feature
Tipo
string
Descrizione
The name of the feature.

Link to withFluidPredicate

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
ParametroTipoDescrizione
Parametro
costruttore
Tipo
Consumer<FluidPredicate>
Descrizione
A consumer that will be used to configure the FluidPredicate.

Link to withLightPredicate

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
ParametroTipoDescrizione
Parametro
costruttore
Tipo
Consumer<LightPredicate>
Descrizione
A consumer that will be used to configure the LightPredicate.

Link to withMaximumXPosition

Name: withMaximumXPosition

Sets the maximum value the X position can assume to max.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMaximumXPosition(max as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
max
Tipo
float
Descrizione
The maximum value the X position can assume.

Link to withMaximumYPosition

Name: withMaximumYPosition

Sets the maximum value the Y position can assume to max.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMaximumYPosition(max as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
max
Tipo
float
Descrizione
The maximum value the Y position can assume.

Link to withMaximumZPosition

Name: withMaximumZPosition

Sets the maximum value the Z position can assume to max.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMaximumZPosition(max as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
max
Tipo
float
Descrizione
The maximum value the Z position can assume.

Link to withMinimumXPosition

Name: withMinimumXPosition

Sets the minimum value the X position can assume to min.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMinimumXPosition(min as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
min
Tipo
float
Descrizione
The minimum value the X position can assume.

Link to withMinimumYPosition

Name: withMinimumYPosition

Sets the minimum value the Y position can assume to min.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMinimumYPosition(min as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
min
Tipo
float
Descrizione
The minimum value the Y position can assume.

Link to withMinimumZPosition

Name: withMinimumZPosition

Sets the minimum value the Z position can assume to min.

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

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withMinimumZPosition(min as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
min
Tipo
float
Descrizione
The minimum value the Z position can assume.

Link to withRangedXPosition

Name: withRangedXPosition

Sets both the minimum and maximum values the X position can assume to min and max 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 min or max will pass the check.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withRangedXPosition(min as float, max as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
min
Tipo
float
Descrizione
The minimum value the X position can assume.
Parametro
max
Tipo
float
Descrizione
The maximum value the X position can assume.

Link to withRangedYPosition

Name: withRangedYPosition

Sets both the minimum and maximum values the Y position can assume to min and max 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 min or max will pass the check.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withRangedYPosition(min as float, max as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
min
Tipo
float
Descrizione
The minimum value the Y position can assume.
Parametro
max
Tipo
float
Descrizione
The maximum value the Y position can assume.

Link to withRangedZPosition

Name: withRangedZPosition

Sets both the minimum and maximum values the Z position can assume to min and max 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 min or max will pass the check.

Returns: This predicate for chaining.
Return Type: LocationPredicate

ZenScript
Copy
LocationPredicate.withRangedZPosition(min as float, max as float) as LocationPredicate
ParametroTipoDescrizione
Parametro
min
Tipo
float
Descrizione
The minimum value the Z position can assume.
Parametro
max
Tipo
float
Descrizione
The maximum value the Z position can assume.

Link to 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();