Class: Selection
The Selection represents a volume in space, which may potentially be made up of one or more block locations. These block locations do not need to be contiguous, and a Selection represent an irregular shape. It's important to note that a Selection is only a representation of the volume shape space - and does NOT represent the actual contents of the space.
Constructors
new Selection()
private
new Selection():Selection
Returns
Properties
isEmpty
readonly
isEmpty:boolean
Remarks
Returns a boolean representing whether or not there are any volumes pushed to the selection stack
Throws
This property can throw when used.
visible
visible:
boolean
Remarks
Set whether or not the selection volume is visible to the client user. NOTE: Use this option carefully - Selection volumes are generally server-only, but marking a volume as visible causes the volume (and all volume operations) to be synchronized with the client game which can potentially generate excessive network traffic.
This property can't be edited in read-only mode.
Methods
clear()
clear():
void
Returns
void
Remarks
Clear the contents of the Selection
This function can't be called in read-only mode.
Throws
This function can throw errors.
getBlockLocationIterator()
getBlockLocationIterator():
BlockLocationIterator
Returns
BlockLocationIterator
Remarks
Fetch a block iterator which can be used to step across the Selection shape. Each call to the iterator will return the next block location within the Selection bounds which is actually selected. Block iteration is not guaranteed to be contiguous - it is possible to create irregular selection shapes by adding volumes to a selection which may or may not be contiguous or adjacent to other volumes within the selection. The Block iterator will return only selected volume locations
This function can't be called in read-only mode.
getBoundingBox()
getBoundingBox():
BoundingBox
Returns
BoundingBox
Remarks
Return a bounding rectangle that contains all of the volumes within the selection (the bounding rectangle does NOT represent the shape of the selection, only the largest rectangle that will fit all of the volumes)
This function can't be called in read-only mode.
Throws
This function can throw errors.
getFillColor()
getFillColor():
RGBA
Returns
RGBA
Remarks
Return the color of the on-screen selection container hull
This function can't be called in read-only mode.
Throws
This function can throw errors.
getOutlineColor()
getOutlineColor():
RGBA
Returns
RGBA
Remarks
Return the color of the on-screen selection container outline
This function can't be called in read-only mode.
Throws
This function can throw errors.
getVolumeOrigin()
getVolumeOrigin():
Vector3
Returns
Vector3
Remarks
Get the origin of the CompoundBlockVolume that makes up the block component part of selection
This function can't be called in read-only mode.
moveBy()
moveBy(
delta
):Vector3
Parameters
Parameter | Type | Description |
---|---|---|
delta | Vector3 | The amount by which to move |
Returns
Vector3
Return the newly moved position
Remarks
Translate a selection by a given amount (this causes all of the volumes within the selection to be moved by the specified offset)
This function can't be called in read-only mode.
Throws
This function can throw errors.
moveTo()
moveTo(
location
):Vector3
Parameters
Parameter | Type | Description |
---|---|---|
location | Vector3 | The world location to which to relocate the selection |
Returns
Vector3
Return the newly moved position
Remarks
Move the selection to an absolute world location (causing all of the volumes within the selection to be moved to a location relative to the world location)
This function can't be called in read-only mode.
Throws
This function can throw errors.
peekLastVolume()
peekLastVolume(
forceRelativity
?):CompoundBlockVolumeItem
Parameters
Parameter | Type | Description |
---|---|---|
forceRelativity ? | CompoundBlockVolumePositionRelativity | See the description for @minecraft-server/CompoundBlockVolume.peekLastVolume |
Returns
CompoundBlockVolumeItem
Returns undefined if the stack is empty
Remarks
Fetch the volume information of the last compound volume that was pushed to the volume stack without affecting the stack itself
This function can't be called in read-only mode.
popVolume()
popVolume():
void
Returns
void
Remarks
Remove the volume information that was last pushed to the volume stack. This will reduce the stack item length by 1
This function can't be called in read-only mode.
Throws
This function can throw errors.
pushVolume()
pushVolume(
item
):void
Parameters
Parameter | Type | Description |
---|---|---|
item | CompoundBlockVolumeItem | Item to push to the stack |
Returns
void
Remarks
Push a compound volume item (a volume and action pair) to the volume stack.
This function can't be called in read-only mode.
Throws
This function can throw errors.
set()
set(
other
):void
Parameters
Parameter | Type | Description |
---|---|---|
other | Selection | CompoundBlockVolume | @minecraft-server/CompoundBlockVolume - set the block component part of this selection to the specified compound block volume. This will completely replace all block volume definitions in the selection. @Selection - replace the selection with the specified selection |
Returns
void
Remarks
Replace the contents of the current selection with a new specified selection. This operation will delete the current contents and copy the contents of the new selection to the target selection - it does this by content, not by reference.
This function can't be called in read-only mode.
Throws
This function can throw errors.
setFillColor()
setFillColor(
color
):void
Parameters
Parameter | Type |
---|---|
color | RGBA |
Returns
void
Remarks
Set the color of the hull of the selection object if it is visible.
This function can't be called in read-only mode.
Throws
This function can throw errors.
setOutlineColor()
setOutlineColor(
color
):void
Parameters
Parameter | Type |
---|---|
color | RGBA |
Returns
void
Remarks
Set the color of the outline around the selection object if it is visible
This function can't be called in read-only mode.
Throws
This function can throw errors.