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

helix / ItemModel

Class: ItemModel โ€‹

Defined in: core/values/item-model/item-model.ts:39

An item model: how a stack renders, under an item definition's model field.

A flat ItemModel.model or a branching arm (composite, condition, select, range_dispatch), plus empty, bundle/selected_item and special. Each has a .raw(). Register with dp.itemDefinition(name, model).

ItemModel.rangeDispatch("minecraft:damage", [ { threshold: 0, model: ItemModel.model("ns:item/sword") }, { threshold: 0.5, model: ItemModel.model("ns:item/sword_cracked") }, ])

Methods โ€‹

toJson() โ€‹

toJson(): Record<string, unknown>

Defined in: core/values/item-model/item-model.ts:138

Returns โ€‹

Record<string, unknown>


bundleSelectedItem() โ€‹

static bundleSelectedItem(): ItemModel

Defined in: core/values/item-model/item-model.ts:121

Render the bundle's currently-selected item.

Returns โ€‹

ItemModel


composite() โ€‹

static composite(models): ItemModel

Defined in: core/values/item-model/item-model.ts:55

Render every sub-model on top of one another.

Parameters โ€‹

models โ€‹

ItemModel[]

Returns โ€‹

ItemModel


condition() โ€‹

static condition(property, onTrue, onFalse, opts?): ItemModel

Defined in: core/values/item-model/item-model.ts:64

Branches on a boolean property. opts holds its extra fields, e.g. { component }.

Parameters โ€‹

property โ€‹

string

onTrue โ€‹

ItemModel

onFalse โ€‹

ItemModel

opts? โ€‹

Record<string, unknown> = {}

Returns โ€‹

ItemModel


empty() โ€‹

static empty(): ItemModel

Defined in: core/values/item-model/item-model.ts:116

Render nothing.

Returns โ€‹

ItemModel


model() โ€‹

static model(ref, tints?): ItemModel

Defined in: core/values/item-model/item-model.ts:47

Flat sprite/model with optional per-layer tints - the common case.

Parameters โ€‹

ref โ€‹

ModelResource

tints? โ€‹

TintSource[]

Returns โ€‹

ItemModel


rangeDispatch() โ€‹

static rangeDispatch(property, entries, opts?): ItemModel

Defined in: core/values/item-model/item-model.ts:97

Picks a model by numeric threshold on property. opts.scale scales the value, opts.fallback renders below the lowest threshold.

Parameters โ€‹

property โ€‹

string

entries โ€‹

RangeEntry[]

opts? โ€‹
fallback? โ€‹

ItemModel

scale? โ€‹

number

Returns โ€‹

ItemModel


raw() โ€‹

static raw(json): ItemModel

Defined in: core/values/item-model/item-model.ts:134

Verbatim item-model JSON escape hatch (wins over the typed arms).

Parameters โ€‹

json โ€‹

Record<string, unknown>

Returns โ€‹

ItemModel


select() โ€‹

static select(property, cases, fallback?, opts?): ItemModel

Defined in: core/values/item-model/item-model.ts:79

Matches property against cases. opts holds its extra fields.

Parameters โ€‹

property โ€‹

string

cases โ€‹

SelectCase[]

fallback? โ€‹

ItemModel

opts? โ€‹

Record<string, unknown> = {}

Returns โ€‹

ItemModel


special() โ€‹

static special(base, model): ItemModel

Defined in: core/values/item-model/item-model.ts:126

A hardcoded block-entity model (base is the model providing the transforms).

Parameters โ€‹

base โ€‹

ModelResource

model โ€‹

SpecialModel

Returns โ€‹

ItemModel

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