Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

helix / Selector

Class: Selector โ€‹

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

A typed entity selector, e.g. Selector.allEntities().type(EntityType.ZOMBIE).tag("boss"). Builders change it in place, so don't reuse one local across clauses.

Extends โ€‹

  • SelectorFilters

Extended by โ€‹

Constructors โ€‹

Constructor โ€‹

new Selector(base): Selector

Defined in: core/frontend/nodes/selector/filters.ts:33

Parameters โ€‹

base โ€‹

string

Returns โ€‹

Selector

Inherited from โ€‹

SelectorFilters.constructor

Properties โ€‹

advancementMap โ€‹

protected advancementMap: Map<string, boolean>

Defined in: core/frontend/nodes/selector/filters.ts:31

Inherited from โ€‹

SelectorFilters.advancementMap


base โ€‹

protected base: string

Defined in: core/frontend/nodes/selector/filters.ts:33

Inherited from โ€‹

SelectorFilters.base


distanceRange? โ€‹

protected optional distanceRange?: Range

Defined in: core/frontend/nodes/selector/filters.ts:21

Inherited from โ€‹

SelectorFilters.distanceRange


entityTypeValue? โ€‹

protected optional entityTypeValue?: string

Defined in: core/frontend/nodes/selector/filters.ts:29

Inherited from โ€‹

SelectorFilters.entityTypeValue


gamemodeValue? โ€‹

protected optional gamemodeValue?: string

Defined in: core/frontend/nodes/selector/filters.ts:27

Inherited from โ€‹

SelectorFilters.gamemodeValue


limitValue? โ€‹

protected optional limitValue?: number

Defined in: core/frontend/nodes/selector/filters.ts:16

Inherited from โ€‹

SelectorFilters.limitValue


lowered โ€‹

protected readonly lowered: true = true

Defined in: core/values/value.ts:14

Tells lowered values apart from plain objects (e.g. NBT compounds).

Inherited from โ€‹

SelectorFilters.lowered


nameValue? โ€‹

protected optional nameValue?: string

Defined in: core/frontend/nodes/selector/filters.ts:19

Inherited from โ€‹

SelectorFilters.nameValue


nbtValue? โ€‹

protected optional nbtValue?: NbtValue

Defined in: core/frontend/nodes/selector/filters.ts:23

Inherited from โ€‹

SelectorFilters.nbtValue


notGamemodes โ€‹

protected readonly notGamemodes: string[] = []

Defined in: core/frontend/nodes/selector/filters.ts:28

Inherited from โ€‹

SelectorFilters.notGamemodes


originValue? โ€‹

protected optional originValue?: readonly [number, number, number]

Defined in: core/frontend/nodes/selector/filters.ts:22

Inherited from โ€‹

SelectorFilters.originValue


predicateIds โ€‹

protected predicateIds: string[] = []

Defined in: core/frontend/nodes/selector/filters.ts:24

Inherited from โ€‹

SelectorFilters.predicateIds


scores โ€‹

protected scores: Map<Objective, Range>

Defined in: core/frontend/nodes/selector/filters.ts:14

Inherited from โ€‹

SelectorFilters.scores


sortValue? โ€‹

protected optional sortValue?: Sort

Defined in: core/frontend/nodes/selector/filters.ts:17

Inherited from โ€‹

SelectorFilters.sortValue


tags โ€‹

protected tags: string[] = []

Defined in: core/frontend/nodes/selector/filters.ts:15

Inherited from โ€‹

SelectorFilters.tags


teamValue? โ€‹

protected optional teamValue?: string

Defined in: core/frontend/nodes/selector/filters.ts:18

Inherited from โ€‹

SelectorFilters.teamValue


volumeBox? โ€‹

protected optional volumeBox?: SelectorVolume

Defined in: core/frontend/nodes/selector/filters.ts:20

Inherited from โ€‹

SelectorFilters.volumeBox


xRotationRange? โ€‹

protected optional xRotationRange?: Range

Defined in: core/frontend/nodes/selector/filters.ts:25

Inherited from โ€‹

SelectorFilters.xRotationRange


yBandValue? โ€‹

protected optional yBandValue?: object

Defined in: core/frontend/nodes/selector/filters.ts:30

dy โ€‹

dy: number

y โ€‹

y: number

Inherited from โ€‹

SelectorFilters.yBandValue


yRotationRange? โ€‹

protected optional yRotationRange?: Range

Defined in: core/frontend/nodes/selector/filters.ts:26

Inherited from โ€‹

SelectorFilters.yRotationRange

Accessors โ€‹

postEffects โ€‹

Get Signature โ€‹

get postEffects(): PostEffectsRef

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

These players' camera post effects. See PostEffectsRef.

Returns โ€‹

PostEffectsRef

Methods โ€‹

advancement() โ€‹

advancement(advancement, done?): this

Defined in: core/frontend/nodes/selector/filters.ts:179

Matches players who have (or, with done = false, haven't) completed advancement.

Parameters โ€‹

advancement โ€‹

Advancement

done? โ€‹

boolean = true

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.advancement


advancements() โ€‹

advancements(done): this

Defined in: core/frontend/nodes/selector/filters.ts:172

Matches players by advancement progress (advancements={<id>=true}). Repeat to add more; a later value for the same id wins.

Parameters โ€‹

done โ€‹

Record<string, boolean>

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.advancements


attribute() โ€‹

attribute(attr): AttributeRef

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

This entity's attr attribute. See AttributeRef.

Parameters โ€‹

attr โ€‹

Attribute

Returns โ€‹

AttributeRef


distance() โ€‹

distance(range): this

Defined in: core/frontend/nodes/selector/filters.ts:118

Matches entities within range of the execution position (distance=).

Parameters โ€‹

range โ€‹

Range

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.distance


forEach() โ€‹

forEach(body): void

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

Runs body as and at each matched entity.

Parameters โ€‹

body โ€‹

(ctx) => void

Returns โ€‹

void


gamemode() โ€‹

gamemode(mode): this

Defined in: core/frontend/nodes/selector/filters.ts:145

Matches a game mode. Prefer Gamemode.SURVIVAL over a string.

Parameters โ€‹

mode โ€‹

Gamemode

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.gamemode


killWithPassengers() โ€‹

killWithPassengers(): void

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

Kills the matched entities and everything riding them, since a killed vehicle only drops its passengers.

Returns โ€‹

void


limit() โ€‹

limit(n): this

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

At most n entities (limit=).

Parameters โ€‹

n โ€‹

number

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.limit


name() โ€‹

name(name): this

Defined in: core/frontend/nodes/selector/filters.ts:76

Matches entities with this name (name=).

Parameters โ€‹

name โ€‹

string

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.name


nbt() โ€‹

nbt(nbt): this

Defined in: core/frontend/nodes/selector/filters.ts:185

Matches entities with nbt. Renders for the target version.

Parameters โ€‹

nbt โ€‹

NbtValue

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.nbt


near() โ€‹

near(pos, range): this

Defined in: core/frontend/nodes/selector/filters.ts:111

Matches entities within range of a fixed point (x=,y=,z=,distance=). Unlike a bare distance, it doesn't depend on where the command runs, and the engine only searches nearby chunks.

Parameters โ€‹

pos โ€‹

readonly [number, number, number]

range โ€‹

Range

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.near


notGamemode() โ€‹

notGamemode(mode): this

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

Excludes a game mode (gamemode=!creative). Repeat to exclude several.

Parameters โ€‹

mode โ€‹

Gamemode

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.notGamemode


notPredicate() โ€‹

notPredicate(ref): this

Defined in: core/frontend/nodes/selector/filters.ts:200

Matches entities failing a predicate (predicate=!<id>). Repeat to exclude several.

Parameters โ€‹

ref โ€‹

string | IdValue | PredicateRef

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.notPredicate


notTag() โ€‹

notTag(name): this

Defined in: core/frontend/nodes/selector/filters.ts:50

Excludes entities with a tag (tag=!name). Repeat to exclude several.

Parameters โ€‹

name โ€‹

string

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.notTag


notTeam() โ€‹

notTeam(name): this

Defined in: core/frontend/nodes/selector/filters.ts:71

Excludes members of a team (team=!name).

Parameters โ€‹

name โ€‹

string

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.notTeam


on() โ€‹

on(relation, body): void

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

Runs body as each entity relation of the matched ones, without moving.

Parameters โ€‹

relation โ€‹

Relation

body โ€‹

(ctx) => void

Returns โ€‹

void


predicate() โ€‹

predicate(ref): this

Defined in: core/frontend/nodes/selector/filters.ts:194

Matches entities passing a predicate (predicate=<id>). Repeat to require several. Cheaper than inline nbt={...}.

Parameters โ€‹

ref โ€‹

string | IdValue | PredicateRef

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.predicate


run() โ€‹

run(fn): (ctx) => void

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

A body that runs fn's commands as each matched entity, one execute as per command.

Parameters โ€‹

fn โ€‹

(ctx) => void

Returns โ€‹

(ctx) => void


score() โ€‹

score(objective, range): this

Defined in: core/frontend/nodes/selector/filters.ts:38

Matches entities whose objective score is in range (scores={...}).

Parameters โ€‹

objective โ€‹

Objective

range โ€‹

Range

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.score


slot() โ€‹

slot(slot): ItemSlotRef

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

One item slot on this entity. See ItemSlotRef.

Parameters โ€‹

slot โ€‹

SlotRange

Returns โ€‹

ItemSlotRef


sort() โ€‹

sort(order): this

Defined in: core/frontend/nodes/selector/filters.ts:61

Orders results (sort=). Prefer Sort.NEAREST over a string.

Parameters โ€‹

order โ€‹

Sort

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.sort


span() โ€‹

span(dx, dy, dz): this

Defined in: core/frontend/nodes/selector/filters.ts:101

Matches entities overlapping a dx/dy/dz box from the execution position. Vanilla adds 1 to each span, so span(0, 0, 0) is a 1-block cube.

Parameters โ€‹

dx โ€‹

number

dy โ€‹

number

dz โ€‹

number

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.span


tag() โ€‹

tag(name): this

Defined in: core/frontend/nodes/selector/filters.ts:44

Matches entities with a tag (tag=name). Repeat to require several.

Parameters โ€‹

name โ€‹

string

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.tag


team() โ€‹

team(name): this

Defined in: core/frontend/nodes/selector/filters.ts:66

Matches members of a team (team=).

Parameters โ€‹

name โ€‹

string

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.team


toString() โ€‹

toString(): string

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

The selector as text, so it can be passed to any command method.

Returns โ€‹

string


type() โ€‹

type(entityType): this

Defined in: core/frontend/nodes/selector/filters.ts:157

Matches one entity type, or a tag via EntityType("#ns:tag") / dp.entityTypeTag.

Parameters โ€‹

entityType โ€‹

EntityType

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.type


typeOf() โ€‹

typeOf(other): this

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

Matches the same entity type as other, if it has one.

Parameters โ€‹

other โ€‹

SelectorFilters

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.typeOf


volume() โ€‹

volume(from, to): this

Defined in: core/frontend/nodes/selector/filters.ts:82

Matches entities whose hitbox overlaps the box between two corners, in any order.

Parameters โ€‹

from โ€‹

readonly [number, number, number]

to โ€‹

readonly [number, number, number]

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.volume


xRotation() โ€‹

xRotation(range): this

Defined in: core/frontend/nodes/selector/filters.ts:133

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

Parameters โ€‹

range โ€‹

Range

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.xRotation


yBand() โ€‹

yBand(y, dy): this

Defined in: core/frontend/nodes/selector/filters.ts:127

A vertical band (y=<y>,dy=<dy>). dy is a signed offset, as in vanilla, not a min/max.

Parameters โ€‹

y โ€‹

number

dy โ€‹

number

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.yBand


yRotation() โ€‹

yRotation(range): this

Defined in: core/frontend/nodes/selector/filters.ts:139

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

Parameters โ€‹

range โ€‹

Range

Returns โ€‹

this

Inherited from โ€‹

SelectorFilters.yRotation


allEntities() โ€‹

static allEntities(): Selector

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

Every entity (@e). Add .type(...) so the game doesn't scan them all.

Returns โ€‹

Selector


allPlayers() โ€‹

static allPlayers(): Selector

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

Every player (@a).

Returns โ€‹

Selector


nearest() โ€‹

static nearest(): Selector

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

The nearest player (@p).

Returns โ€‹

Selector


random() โ€‹

static random(): Selector

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

A random player (@r).

Returns โ€‹

Selector


self() โ€‹

static self(): Selector

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

The entity running the command (@s).

Returns โ€‹

Selector


uuid() โ€‹

static uuid(id): Selector

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

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
These docs were written with AI; the layout and every page have been reviewed by a human.