Skip to content

helix / Selector

Class: Selector

Defined in: core/frontend/nodes/selector.ts:36

Extended by

Constructors

Constructor

new Selector(base): Selector

Defined in: core/frontend/nodes/selector.ts:51

Parameters

base

string

Returns

Selector

Methods

build()

build(): SelectorNode

Defined in: core/frontend/nodes/selector.ts:170

Returns

SelectorNode


distance()

distance(range): this

Defined in: core/frontend/nodes/selector.ts:124

Restrict to entities within a distance range of the execution position (distance=<range>). Pass a Range so e.g. ..6 (within 6 blocks) or 2.. is modelled as a value, not a hand-built distance=..6 string.

Parameters

range

Range

Returns

this


gamemode()

gamemode(mode): this

Defined in: core/frontend/nodes/selector.ts:142

Restrict to a game mode (gamemode=survival|creative|adventure|spectator). Prefer the typed Gamemode.SURVIVAL over a bare string.

Parameters

mode

Gamemode

Returns

this


limit()

limit(n): this

Defined in: core/frontend/nodes/selector.ts:83

Parameters

n

number

Returns

this


name()

name(name): this

Defined in: core/frontend/nodes/selector.ts:96

Parameters

name

string

Returns

this


nbt()

nbt(nbt): this

Defined in: core/frontend/nodes/selector.ts:151

Restrict to entities matching nbt (nbt={…}). Pass an Nbt value rather than a hand-built SNBT string so it renders version-aware at codegen.

Parameters

nbt

NbtValue

Returns

this


predicate()

predicate(ref): this

Defined in: core/frontend/nodes/selector.ts:163

Restrict to entities passing a registered predicate (predicate=<id>). Accepts a PredicateRef (from dp.predicate(...)), an Id, or a raw id string. This is the cheap, engine-evaluated stand-in for inlining an nbt={…} match into the selector - register the check once as a Predicate, reference it everywhere. Repeatable to AND several predicates.

Parameters

ref

string | IdValue | PredicateRef

Returns

this


render()

render(version?): string

Defined in: core/frontend/nodes/selector.ts:203

CommandValue form. Most selector args are version-neutral, but an nbt={…} arm renders its Nbt version-aware, so the codegen version is threaded through here. Lets a Selector be passed to any concept-typed entity argument (entity, score_holder, ...).

Parameters

version?

VersionProfile

Returns

string


run()

run(fn): (ctx) => void

Defined in: core/frontend/nodes/selector.ts:207

Parameters

fn

(ctx) => void

Returns

(ctx) => void


score()

score(objective, range): this

Defined in: core/frontend/nodes/selector.ts:73

Parameters

objective

Objective

range

Range

Returns

this


sort()

sort(order): this

Defined in: core/frontend/nodes/selector.ts:88

Order multi-match results (sort=). Prefer the typed Sort.NEAREST over a bare string.

Parameters

order

Sort

Returns

this


tag()

tag(name): this

Defined in: core/frontend/nodes/selector.ts:78

Parameters

name

string

Returns

this


team()

team(name): this

Defined in: core/frontend/nodes/selector.ts:92

Parameters

name

string

Returns

this


toString()

toString(): string

Defined in: core/frontend/nodes/selector.ts:193

The selector's command-string form, so a Selector can be passed directly as an argument to any command method (which stringify their args).

Returns

string


volume()

volume(from, to): this

Defined in: core/frontend/nodes/selector.ts:107

Restrict to entities whose hitbox overlaps the axis-aligned box between two corners (x=…,y=…,z=…,dx=…,dy=…,dz=…). Corner order doesn't matter - the lower corner and absolute spans are derived. Replaces hand-built volume selector strings.

Parameters

from

readonly [number, number, number]

to

readonly [number, number, number]

Returns

this


xRotation()

xRotation(range): this

Defined in: core/frontend/nodes/selector.ts:130

Restrict by vertical look angle (x_rotation=<range>).

Parameters

range

Range

Returns

this


yRotation()

yRotation(range): this

Defined in: core/frontend/nodes/selector.ts:136

Restrict by horizontal look angle (y_rotation=<range>).

Parameters

range

Range

Returns

this


allEntities()

static allEntities(): Selector

Defined in: core/frontend/nodes/selector.ts:56

Returns

Selector


allPlayers()

static allPlayers(): Selector

Defined in: core/frontend/nodes/selector.ts:53

Returns

Selector


nearest()

static nearest(): Selector

Defined in: core/frontend/nodes/selector.ts:59

Returns

Selector


random()

static random(): Selector

Defined in: core/frontend/nodes/selector.ts:62

Returns

Selector


self()

static self(): Selector

Defined in: core/frontend/nodes/selector.ts:65

Returns

Selector


uuid()

static uuid(id): Selector

Defined in: core/frontend/nodes/selector.ts:69

A selector that is a bare entity UUID or player name (its own base form).

Parameters

id

string

Returns

Selector

Released under the MIT License · Credits