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.
导入类
Link to 导入类
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 Copyimport 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
使用方式
Link to 使用方式
Name: withBiomeName
Sets the biome in which the location should be.
Returns: This predicate for chaining.
Return Type: LocationPredicate
ZenScript CopyLocationPredicate.withBiomeName(biome as MCResourceLocation) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 biome | 类型 MCResourceLocation | 描述 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 CopyLocationPredicate.withBlockPredicate(builder as Consumer<BlockPredicate>) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 生成器 | 类型 Consumer<BlockPredicate> | 描述 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 CopyLocationPredicate.withDimension(dimension as MCResourceLocation) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 dimension | 类型 MCResourceLocation | 描述 The name of the dimension. |
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 CopyLocationPredicate.withExactXPosition(x as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 float | 描述 The exact value the X position should assume. |
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 CopyLocationPredicate.withExactYPosition(y as int) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 y | 类型 int | 描述 The exact value the Y position should assume. |
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 CopyLocationPredicate.withExactZPosition(z as int) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 z | 类型 int | 描述 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 CopyLocationPredicate.withFeatureName(feature as string) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 feature | 类型 string | 描述 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 CopyLocationPredicate.withFluidPredicate(builder as Consumer<FluidPredicate>) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 生成器 | 类型 Consumer<FluidPredicate> | 描述 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 CopyLocationPredicate.withLightPredicate(builder as Consumer<LightPredicate>) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 生成器 | 类型 Consumer<LightPredicate> | 描述 A consumer that will be used to configure the LightPredicate. |
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 CopyLocationPredicate.withMaximumXPosition(max as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 max | 类型 float | 描述 The maximum value the X position can assume. |
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 CopyLocationPredicate.withMaximumYPosition(max as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 max | 类型 float | 描述 The maximum value the Y position can assume. |
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 CopyLocationPredicate.withMaximumZPosition(max as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 max | 类型 float | 描述 The maximum value the Z position can assume. |
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 CopyLocationPredicate.withMinimumXPosition(min as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 min | 类型 float | 描述 The minimum value the X position can assume. |
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 CopyLocationPredicate.withMinimumYPosition(min as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 min | 类型 float | 描述 The minimum value the Y position can assume. |
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 CopyLocationPredicate.withMinimumZPosition(min as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 min | 类型 float | 描述 The minimum value the Z position can assume. |
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 CopyLocationPredicate.withRangedXPosition(min as float, max as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 min | 类型 float | 描述 The minimum value the X position can assume. |
参数 max | 类型 float | 描述 The maximum value the X position can assume. |
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 CopyLocationPredicate.withRangedYPosition(min as float, max as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 min | 类型 float | 描述 The minimum value the Y position can assume. |
参数 max | 类型 float | 描述 The maximum value the Y position can assume. |
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 CopyLocationPredicate.withRangedZPosition(min as float, max as float) as LocationPredicate
参数 | 类型 | 描述 |
---|---|---|
参数 min | 类型 float | 描述 The minimum value the Z position can assume. |
参数 max | 类型 float | 描述 The maximum value the Z position can assume. |
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();