Appearance
Resource-pack models
Model definitions build the resource pack, and attaching one to an item sets its item_model component.
ts
const shooterModel = dp.model("web_shooter", Model.item(dp.texture("item/web_shooter")));| Registrar | Emits (resource pack) | Returns |
|---|---|---|
dp.model(name, def) | models/item/<name> + items/<name> | ModelRef |
dp.blockModel(name, def) | models/block/<name> | ModelRef |
dp.blockState(block, def) | blockstates/<block> | - |
dp.itemDefinition(name, model) | items/<name> (conditions, selects...) | ModelRef |
dp.addAssets(dir) | a directory copied as-is | - |
Model.item, Model.cubeAll and Model.cubeColumn cover common shapes; .parent, .texture and .raw(json) cover the rest.
Give an item a model
ts
import { Datapack, v26_2, Selector, Item, Model } from "helix";
const dp = new Datapack("gear", v26_2);
const shooterModel = dp.model("web_shooter", Model.item(dp.texture("item/web_shooter")));
dp.createFunction("give_shooter").build((ctx) => {
ctx.playerGive(
Selector.nearest(),
Item.CARROT_ON_A_STICK.named("Web Shooter").model(shooterModel),
);
});Compiled output - the real files helix emits for the code above:
txt
give @p minecraft:carrot_on_a_stick[custom_name={"text":"Web Shooter"},item_model="gear:web_shooter"] 1txt
{
"pack": {
"description": "gear\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}Write the resource pack
dp.writeResourcePack(path) writes assets/; dp.writeDatapack(path) doesn't include it.
WARNING
Before 1.21.4 there's no item_model. Pass a fallback number, dp.model(name, def, legacyModelData), or the build throws.
Change a block's look
There are no new blocks in vanilla, so dp.blockState overrides an existing block. dp.blockModel registers the model its variants point at.
See also
- Items
ItemModelbuilders in the API reference