Appearance
helix / ItemDataSchema
Class: ItemDataSchema<T> โ
Defined in: core/values/item-data.ts:32
An item's custom_data, typed by T, so a wrong key or value fails to compile.
const Bow = ItemData<{ pick?: number }>(Item.CROSSBOW); Bow.is({ pick: 1 }) // item predicate Bow.set({ pick: 1 }) // loot function for an item modifier Bow.on(Path.Player.held(Slot.MAINHAND), "pick") // path on a holder Bow.model({ pick: 1 }, picked) // item-model condition Bow.switchModel("pick", [0, 1, 2], (k) => ...) // a model per value Bow.in(Selector.self(), Slot.MAINHAND) // the held item, to check and edit
Type Parameters โ
T โ
T extends object
Constructors โ
Constructor โ
new ItemDataSchema<
T>(item):ItemDataSchema<T>
Defined in: core/values/item-data.ts:33
Parameters โ
item โ
Returns โ
ItemDataSchema<T>
Properties โ
item โ
readonlyitem:ItemValue
Defined in: core/values/item-data.ts:33
Methods โ
in() โ
in(
who,slot):HeldData<T>
Defined in: core/values/item-data.ts:56
The item in who's slot, or a container block's, to check and edit. See HeldData.
Parameters โ
who โ
slot โ
Returns โ
HeldData<T>
is() โ
is(
match):ItemValue
Defined in: core/values/item-data.ts:36
The item, when its custom_data holds match. A copy, so the base item is left as it was.
Parameters โ
match โ
DataMatch<T>
Returns โ
key() โ
key(
key):NbtPathValue
Defined in: core/values/item-data.ts:46
key inside custom_data, as for storage that copy_custom_data reads from.
Parameters โ
key โ
keyof T & string
Returns โ
model() โ
model(
match,onTrue,onFalse?):ItemModel
Defined in: core/values/item-data.ts:61
Draws onTrue when the stack's custom_data holds match, onFalse otherwise.
Parameters โ
match โ
DataMatch<T>
onTrue โ
onFalse? โ
ItemModel = ...
Returns โ
on() โ
on(
item,key):NbtPathValue
Defined in: core/values/item-data.ts:51
key in the custom_data of the item at item, e.g. Path.Player.held(Slot.OFFHAND).
Parameters โ
item โ
key โ
keyof T & string
Returns โ
set() โ
set(
data):LootFunction
Defined in: core/values/item-data.ts:41
Merges data into the stack's custom_data.
Parameters โ
data โ
Partial<T>
Returns โ
switchModel() โ
switchModel<
K>(key,values,model):ItemModel
Defined in: core/values/item-data.ts:72
Draws model(value) for the value of key the stack holds, out of values. The first value also draws for a stack without key, since a model condition can't see a missing key.
Type Parameters โ
K โ
K extends string
Parameters โ
key โ
K
values โ
readonly NonNullable<T[K]>[]
model โ
(value) => ItemModel