For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server/classes/BlockVolume.md.

Class: BlockVolume

block

Beta

BlockVolume 是一个简单对象,描述世界中位于方块坐标处的给定大小(以方块计)的 3D 矩形区域。 注意这些向量分量不保证按任何顺序排列,因此不等同于「min」与「max」值。 此外,这些向量位置不可与 BlockLocation 互换。 如需将此体积表示为 BlockLocation 范围,可使用 getBoundingBox 实用函数。

此体积类保留初始设置的角点索引顺序。 类比编辑器中分配每个角点的场景——当你移动角点时(可能反转边界的 min/max 关系), 原本位于顶部/左侧的角点就会变成底部/右侧。 因此手动编辑此类体积时,需在编辑过程中维持角点的标识——BlockVolume 实用函数正是为此而设计。

另请注意:此处测量的是「方块大小」(端点到端点)。普通 AABB (0,0,0) 到 (0,0,0) 大小通常为 (0,0,0); 但因为按方块计数,BlockVolume 的大小或跨度实际为 (1,1,1)。

A BlockVolume is a simple interface to an object which represents a 3D rectangle of a given size (in blocks) at a world block location. Note that these are not analogous to "min" and "max" values, in that the vector components are not guaranteed to be in any order. In addition, these vector positions are not interchangeable with BlockLocation. If you want to get this volume represented as range of of BlockLocations, you can use the getBoundingBox utility function. This volume class will maintain the ordering of the corner indexes as initially set. imagine that each corner is assigned in Editor - as you move the corner around (potentially inverting the min/max relationship of the bounds) - what you had originally selected as the top/left corner would traditionally become the bottom/right. When manually editing these kinds of volumes, you need to maintain the identity of the corner as you edit - the BlockVolume utility functions do this.

Important to note that this measures block sizes (to/from) - a normal AABB (0,0,0) to (0,0,0) would traditionally be of size (0,0,0) However, because we're measuring blocks - the size or span of a BlockVolume would actually be (1,1,1)

Extends

Constructors

Constructor

new BlockVolume(from, to): BlockVolume

Beta

Parameters

from

Vector3

to

Vector3

Returns

BlockVolume

Overrides

BlockVolumeBase.constructor

Properties

from

from: Vector3

Beta

Remarks

表示 3D 矩形中一个角点的世界方块位置。

A world block location that represents a corner in a 3D rectangle


to

to: Vector3

Beta

Remarks

表示 3D 矩形中对角角点的世界方块位置。

A world block location that represents the opposite corner in a 3D rectangle

Methods

doesLocationTouchFaces()

doesLocationTouchFaces(pos): boolean

Beta

Parameters

pos

Vector3

要测试的世界方块位置。

The world block location to test

Returns

boolean

如果该位置在内部或距离超过 0 个方块,则返回 false。 如果该位置直接接触 BlockVolume 的外表面,则返回 true

If the location is either inside or more than 0 blocks away, the function will return false. If the location is directly contacting the outer surface of the BlockVolume, the function will return true.

Remarks

检查给定位置是否直接与 BlockVolume 的外表面相邻。

Check to see if the given location is directly adjacent to the outer surface of a BlockVolume.


doesVolumeTouchFaces()

doesVolumeTouchFaces(other): boolean

Beta

Parameters

other

BlockVolume

要测试的体积。

The volume to test

Returns

boolean

如果两个方块体积的外表面在任何点接触且直接相邻,返回 true

If the outer faces of both block volumes touch and are directly adjacent at any point, return true.

Remarks

检查两个方块体积是否直接相邻且两个面接触。

Check to see if a two block volumes are directly adjacent and two faces touch.


getBlockLocationIterator()

getBlockLocationIterator(): BlockLocationIterator

Beta

Returns

BlockLocationIterator

Remarks

获取一个 BlockLocationIterator,表示指定体积内的所有方块世界位置。

Fetch a BlockLocationIterator that represents all of the block world locations within the specified volume

Inherited from

BlockVolumeBase.getBlockLocationIterator


getBoundingBox()

getBoundingBox(): BlockBoundingBox

Beta

Returns

BlockBoundingBox

Remarks

返回一个 BlockBoundingBox 对象,表示体积的有效最小和最大坐标。

Return a BlockBoundingBox object which represents the validated min and max coordinates of the volume

Throws

This function can throw errors.

Inherited from

BlockVolumeBase.getBoundingBox


getCapacity()

getCapacity(): number

Beta

Returns

number

Remarks

返回 BlockVolume 的容量(体积)(WDH)。

Return the capacity (volume) of the BlockVolume (WDH)

Inherited from

BlockVolumeBase.getCapacity


getClosest()

getClosest(count, location): Vector3[]

Beta

Parameters

count

number

要返回的最接近位置的数量。

Number of closest positions to return

location

Vector3

测量距离的位置。

Position to measure distance from

Returns

Vector3[]

Remarks

返回体积内最接近给定位置的方块位置列表,按距离排序(最近优先)。

Returns a list of block positions within the volume that are closest to a given location, sorted by distance (nearest first)

Throws

This function can throw errors.

ArgumentOutOfBoundsError

Inherited from

BlockVolumeBase.getClosest


getFarthest()

getFarthest(count, location): Vector3[]

Beta

Parameters

count

number

要返回的最远位置的数量。

Number of farthest positions to return

location

Vector3

测量距离的位置。

Position to measure distance from

Returns

Vector3[]

Remarks

返回体积内距离给定位置最远的方块位置列表,按距离排序(最远优先)。

Returns a list of block positions within the volume that are farthest from a given location, sorted by distance (farthest first)

Throws

This function can throw errors.

ArgumentOutOfBoundsError

Inherited from

BlockVolumeBase.getFarthest


getMax()

getMax(): Vector3

Beta

Returns

Vector3

Remarks

获取体积的最大角点位置(保证 >= min)。

Get the largest corner position of the volume (guaranteed to be >= min)

Throws

This function can throw errors.

Inherited from

BlockVolumeBase.getMax


getMin()

getMin(): Vector3

Beta

Returns

Vector3

Remarks

获取体积的最小角点位置(保证 <= max)。

Get the smallest corner position of the volume (guaranteed to be <= max)

Throws

This function can throw errors.

Inherited from

BlockVolumeBase.getMin


getSpan()

getSpan(): Vector3

Beta

Returns

Vector3

Remarks

获取一个 Vector3 对象,其中每个分量表示沿该轴的方块数量。

Get a Vector3 object where each component represents the number of blocks along that axis

Inherited from

BlockVolumeBase.getSpan


intersects()

intersects(other): BlockVolumeIntersection

Beta

Parameters

other

BlockVolume

Returns

BlockVolumeIntersection

Remarks

返回表示两个 BlockVolume 对象之间交集的枚举。

Return an enumeration which represents the intersection between two BlockVolume objects


isInside()

isInside(location): boolean

Beta

Parameters

location

Vector3

Returns

boolean

Remarks

检查给定的世界方块位置是否在 BlockVolume 内部。

Check to see if a given world block location is inside a BlockVolume

Inherited from

BlockVolumeBase.isInside


translate()

translate(delta): void

Beta

Parameters

delta

Vector3

移动的方块数量。

Amount of blocks to move by

Returns

void

Remarks

按指定量移动 BlockVolume

Move a BlockVolume by a specified amount

Inherited from

BlockVolumeBase.translate

同领域相关