DistancePredicate

Represents a predicate for distance.

The predicate can effectively be used to check the distance between two coordinates in 3D-space. The distance will firstly be checked separately against the x, y, and z bounds that have been specified. If those checks succeed, then horizontal distance will be taken into consideration, measuring the distance between the two points only along the X and Z axis. Lastly, the absolute distance considering all axis will be checked.

Any of the above checks will be skipped if no value has been specified for any of them. By default, the predicate will not add any restrictions on the distance between two points.

导入相关包

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

Extending AnyDefaultingVanillaWrappingPredicate

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

方法

withMaximumAbsoluteDistance

Sets the maximum value the absolute distance should be to max.

If the absolute distance 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 absolute distance 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.

Returns: This predicate for chaining.
Return Type: DistancePredicate

ZenScript
Copy
DistancePredicate.withMaximumAbsoluteDistance(max as float) as DistancePredicate
参数类型描述
maxfloatThe maximum value the absolute distance should be.
withMaximumHorizontalDistance

Sets the maximum value the horizontal distance should be to max.

If the horizontal distance 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 horizontal distance 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.

Returns: This predicate for chaining.
Return Type: DistancePredicate

ZenScript
Copy
DistancePredicate.withMaximumHorizontalDistance(max as float) as DistancePredicate
参数类型描述
maxfloatThe maximum value the horizontal distance should be.
withMaximumX

Sets the maximum value the distance along the X axis should be to max.

If the distance 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 distance 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.

Returns: This predicate for chaining.
Return Type: DistancePredicate

ZenScript
Copy
DistancePredicate.withMaximumX(max as float) as DistancePredicate
参数类型描述
maxfloatThe maximum value the distance along the X axis should be.
withMaximumY

Sets the maximum value the distance along the Y axis should be to max.

If the distance 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 distance 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.

Returns: This predicate for chaining.
Return Type: DistancePredicate

ZenScript
Copy
DistancePredicate.withMaximumY(max as float) as DistancePredicate
参数类型描述
maxfloatThe maximum value the distance along the Y axis should be.
withMaximumZ

Sets the maximum value the distance along the Z axis should be to max.

If the distance 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 distance 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.

Returns: This predicate for chaining.
Return Type: DistancePredicate

ZenScript
Copy
DistancePredicate.withMaximumZ(max as float) as DistancePredicate
参数类型描述
maxfloatThe maximum value the distance along the Z axis should be.
withMinimumAbsoluteDistance

Sets the minimum value the absolute distance should be to min.

If the absolute distance 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 absolute distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withMinimumAbsoluteDistance(min as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the absolute distance should be.
withMinimumHorizontalDistance

Sets the minimum value the horizontal distance should be to min.

If the horizontal distance 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 horizontal distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withMinimumHorizontalDistance(min as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the horizontal distance should be.
withMinimumX

Sets the minimum value the distance along the X axis should be to min.

If the distance 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 distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withMinimumX(min as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the distance along the X axis should be.
withMinimumY

Sets the minimum value the distance along the Y axis should be to min.

If the distance 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 distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withMinimumY(min as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the distance along the Y axis should be.
withMinimumZ

Sets the minimum value the distance along the Z axis should be to min.

If the distance 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 distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withMinimumZ(min as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the distance along the Z axis should be.
withRangedAbsoluteDistance

Sets both the minimum and maximum value the absolute distance should be to min and max respectively.

If the absolute distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withRangedAbsoluteDistance(min as float, max as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the absolute distance should be.
maxfloatThe maximum value the absolute distance should be.
withRangedHorizontalDistance

Sets both the minimum and maximum value the horizontal distance should be to min and max respectively.

If the horizontal distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withRangedHorizontalDistance(min as float, max as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the horizontal distance should be.
maxfloatThe maximum value the horizontal distance should be.
withRangedX

Sets both the minimum and maximum value the distance along the X axis should be to min and max respectively.

If the distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withRangedX(min as float, max as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the distance along the X axis should be.
maxfloatThe maximum value the distance along the X axis should be.
withRangedY

Sets both the minimum and maximum value the distance along the Y axis should be to min and max respectively.

If the distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withRangedY(min as float, max as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the distance along the Y axis should be.
maxfloatThe maximum value the distance along the Y axis should be.
withRangedZ

Sets both the minimum and maximum value the distance along the Z axis should be to min and max respectively.

If the distance 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: DistancePredicate

ZenScript
Copy
DistancePredicate.withRangedZ(min as float, max as float) as DistancePredicate
参数类型描述
minfloatThe minimum value the distance along the Z axis should be.
maxfloatThe maximum value the distance along the Z axis should be.