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

twine / BossBuilder

Class: BossBuilder โ€‹

Defined in: twine/src/boss/builder.ts:90

Builds a boss fight: a mob with health-based phases, weighted abilities on cooldowns, and a bossbar.

const king = defineBoss(Wither({ customName: "Bone King" }), Pos(0, 70, 0)) .arena({ kind: "region", center: [0, 70, 0], radius: 30 }) .bossbar(Component("Bone King"), "purple") .phase("one") .ability("slam", { cooldown: 60, weight: 3, body: (ctx) => ... }) .phase("two", { at: 50, bar: { color: "red", name: Component("Enraged") } }) .ability("beam", { cooldown: 40, body: (ctx) => ... }) .onVictory((ctx) => ctx.loot().giveLoot(Selector.self(), reward));

@Module({ name: "keep", imports: [king.toModule("bone_king")] })

The arena is a normal area trigger: entering starts the fight, and the arena emptying is a loss.

Constructors โ€‹

Constructor โ€‹

new BossBuilder(nbt, spawn): BossBuilder

Defined in: twine/src/boss/builder.ts:97

Parameters โ€‹

nbt โ€‹

IdentifiedEntityNbt

spawn โ€‹

PosValue

Returns โ€‹

BossBuilder

Methods โ€‹

ability() โ€‹

ability(name, opts): this

Defined in: twine/src/boss/builder.ts:132

Adds an ability to the last declared phase. To reuse one, add it to each phase with a shared body.

Parameters โ€‹

name โ€‹

string

opts โ€‹

AbilityOpts

Returns โ€‹

this


arena() โ€‹

arena(trigger): this

Defined in: twine/src/boss/builder.ts:103

Where the fight happens - the same AreaTrigger any area module takes.

Parameters โ€‹

trigger โ€‹

AreaTrigger

Returns โ€‹

this


bossbar() โ€‹

bossbar(name, color?): this

Defined in: twine/src/boss/builder.ts:109

Show a bar while the fight runs, tracking the boss's health.

Parameters โ€‹

name โ€‹

ComponentValue

color? โ€‹

BossbarColor

Returns โ€‹

this


onDefeat() โ€‹

onDefeat(body): this

Defined in: twine/src/boss/builder.ts:152

The arena emptied with the boss still alive. Runs as each participant.

Parameters โ€‹

body โ€‹

BossBody

Returns โ€‹

this


onVictory() โ€‹

onVictory(body): this

Defined in: twine/src/boss/builder.ts:146

Runs when the boss dies, as each participant.

Parameters โ€‹

body โ€‹

BossBody

Returns โ€‹

this


phase() โ€‹

phase(label, opts?): this

Defined in: twine/src/boss/builder.ts:115

Declares a phase. The first one declared is where the fight starts.

Parameters โ€‹

label โ€‹

string

opts? โ€‹

PhaseOpts = {}

Returns โ€‹

this


toModule() โ€‹

toModule(name, opts?): ConfiguredModule

Defined in: twine/src/boss/builder.ts:158

Compile to a drop-in ConfiguredModule (name = module / objective / tag id).

Parameters โ€‹

name โ€‹

string

opts? โ€‹

BossModuleOpts = {}

Returns โ€‹

ConfiguredModule

Released under the MIT License ยท Credits
These docs were written with AI; the layout and every page have been reviewed by a human.