Appearance
helix / ItemModel
Class: ItemModel
Defined in: core/values/item-model.ts:248
The client item model - the tagged union under an item definition's model field (assets/<ns>/items/<name>.json), selecting how a stack renders. Mirrors the full vanilla schema (misode's assets/item/ generator): a flat ItemModel.model, or one of the branching arms (composite / condition / select / range_dispatch), the terminals (empty / bundle/selected_item), or a special block-entity model. Every arm has a .raw() sibling escape hatch; registered via dp.itemDefinition(name, model) (or emitted by dp.model for the flat case). All model-resource fields accept a ModelRef or a <ns>:path.
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.ts:345
Returns
Record<string, unknown>
bundleSelectedItem()
staticbundleSelectedItem():ItemModel
Defined in: core/values/item-model.ts:331
Render the bundle's currently-selected item.
Returns
ItemModel
composite()
staticcomposite(models):ItemModel
Defined in: core/values/item-model.ts:264
Render every sub-model on top of one another.
Parameters
models
ItemModel[]
Returns
ItemModel
condition()
staticcondition(property,onTrue,onFalse,opts?):ItemModel
Defined in: core/values/item-model.ts:273
Boolean branch on property (see CONDITION_PROPERTIES); opts carries that property's extra fields (e.g. { component } for has_component, { keybind } for keybind_down, { index } for custom_model_data).
Parameters
property
string
onTrue
ItemModel
onFalse
ItemModel
opts?
Record<string, unknown> = {}
Returns
ItemModel
empty()
staticempty():ItemModel
Defined in: core/values/item-model.ts:326
Render nothing.
Returns
ItemModel
model()
staticmodel(ref,tints?):ItemModel
Defined in: core/values/item-model.ts:256
Flat sprite/model with optional per-layer tints - the common case.
Parameters
ref
tints?
Returns
ItemModel
rangeDispatch()
staticrangeDispatch(property,entries,opts?):ItemModel
Defined in: core/values/item-model.ts:310
Numeric threshold dispatch on property (see RANGE_DISPATCH_PROPERTIES). opts.scale multiplies the raw value; opts.fallback renders below the lowest threshold; any other key is a property-specific field.
Parameters
property
string
entries
opts?
fallback?
ItemModel
scale?
number
Returns
ItemModel
raw()
staticraw(json):ItemModel
Defined in: core/values/item-model.ts:341
Verbatim item-model JSON escape hatch (wins over the typed arms).
Parameters
json
Record<string, unknown>
Returns
ItemModel
select()
staticselect(property,cases,fallback?,opts?):ItemModel
Defined in: core/values/item-model.ts:291
Match property (see SELECT_PROPERTIES) against cases; opts carries that property's extra fields (e.g. { block_state_property } for block_state).
Parameters
property
string
cases
fallback?
ItemModel
opts?
Record<string, unknown> = {}
Returns
ItemModel
special()
staticspecial(base,model):ItemModel
Defined in: core/values/item-model.ts:336
A hardcoded block-entity model (base is the model providing the transforms).
Parameters
base
model
Returns
ItemModel