# DistancePredicate

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

## 导入类

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 Copy``import crafttweaker.api.predicate.DistancePredicate;`

## Extending AnyDefaultingVanillaWrappingPredicate

Link to extending-anydefaultingvanillawrappingpredicate

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

## 使用方式

Link to 使用方式

Name: `withMaximumAbsoluteDistance`

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

If the absolute distance 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 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 <code>max</code> will pass the check.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMaximumAbsoluteDistance(max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 max | 类型 浮点数 | 描述 The maximum value the absolute distance should be. |

Name: `withMaximumHorizontalDistance`

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

If the horizontal distance 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 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 <code>max</code> will pass the check.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMaximumHorizontalDistance(max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 max | 类型 浮点数 | 描述 The maximum value the horizontal distance should be. |

Name: `withMaximumX`

Sets the maximum value the distance along the X axis should be to <code>max</code>.

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

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMaximumX(max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 max | 类型 浮点数 | 描述 The maximum value the distance along the X axis should be. |

Name: `withMaximumY`

Sets the maximum value the distance along the Y axis should be to <code>max</code>.

If the distance 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 distance didn't have any bounds set, the maximum is set, leaving the lower end unbounded.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMaximumY(max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 max | 类型 浮点数 | 描述 The maximum value the distance along the Y axis should be. |

Name: `withMaximumZ`

Sets the maximum value the distance along the Z axis should be to <code>max</code>.

If the distance 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 distance didn't have any bounds set, the maximum is set, leaving the lower end unbounded.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMaximumZ(max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 max | 类型 浮点数 | 描述 The maximum value the distance along the Z axis should be. |

Name: `withMinimumAbsoluteDistance`

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

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

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMinimumAbsoluteDistance(min as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the absolute distance should be. |

Name: `withMinimumHorizontalDistance`

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

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

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMinimumHorizontalDistance(min as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the horizontal distance should be. |

Name: `withMinimumX`

Sets the minimum value the distance along the X axis should be to <code>min</code>.

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

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMinimumX(min as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the distance along the X axis should be. |

Name: `withMinimumY`

Sets the minimum value the distance along the Y axis should be to <code>min</code>.

If the distance 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 distance didn't have any bounds set, the minimum is set, leaving the upper end unbounded.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMinimumY(min as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the distance along the Y axis should be. |

Name: `withMinimumZ`

Sets the minimum value the distance along the Z axis should be to <code>min</code>.

If the distance 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 distance didn't have any bounds set, the minimum is set, leaving the upper end unbounded.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withMinimumZ(min as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the distance along the Z axis should be. |

Name: `withRangedAbsoluteDistance`

Sets both the minimum and maximum value the absolute distance should be to <code>min</code> and <code>max</code> 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 <code>min</code> or <code>max</code> will pass the check.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withRangedAbsoluteDistance(min as float, max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the absolute distance should be. |

参数 max | 类型 浮点数 | 描述 The maximum value the absolute distance should be. |

Name: `withRangedHorizontalDistance`

Sets both the minimum and maximum value the horizontal distance should be to <code>min</code> and <code>max</code> 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 <code>min</code> or <code>max</code> will pass the check.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withRangedHorizontalDistance(min as float, max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the horizontal distance should be. |

参数 max | 类型 浮点数 | 描述 The maximum value the horizontal distance should be. |

Name: `withRangedX`

Sets both the minimum and maximum value the distance along the X axis should be to <code>min</code> and <code>max</code> 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 <code>min</code> or <code>max</code> will pass the check.

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withRangedX(min as float, max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the distance along the X axis should be. |

参数 max | 类型 浮点数 | 描述 The maximum value the distance along the X axis should be. |

Name: `withRangedY`

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

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

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withRangedY(min as float, max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the distance along the Y axis should be. |

参数 max | 类型 浮点数 | 描述 The maximum value the distance along the Y axis should be. |

Name: `withRangedZ`

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

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

Returns: This predicate for chaining.

Return Type: DistancePredicate

`ZenScript Copy``DistancePredicate.withRangedZ(min as float, max as float) as DistancePredicate`

参数 | 类型 | 描述 |
---|---|---|

参数 min | 类型 浮点数 | 描述 The minimum value the distance along the Z axis should be. |

参数 max | 类型 浮点数 | 描述 The maximum value the distance along the Z axis should be. |