Custom model data: pagbibigay sa isang item ng maraming model nang walang pinapalitan
Pinalitan ng sistemang item-model ang lumang predicate na CustomModelData. Narito ang layout ng folder, ang JSON na nagma-map ng mga value sa mga model, at kung bakit lumalabas ang iyong texture bilang kulay-ube na cube.
Nagbibigay-daan ang mga custom item model sa isang server na mamigay ng isang "magic wand" na isa palang carrot on a stick na may ibang model. Nagbago ang mekanismo, at inilalarawan pa rin ng karamihan sa mga tutorial ang luma.
Ang nagbago
Lumang paraan — a predicate block inside the base item's model file, keyed on custom_model_data as a number:
{ "predicate": { "custom_model_data": 1 }, "model": "item/wand" }
Kasalukuyang paraan — isang items/ definition that selects a model:
assets/minecraft/items/carrot_on_a_stick.json
{
"model": {
"type": "minecraft:range_dispatch",
"property": "minecraft:custom_model_data",
"fallback": { "type": "minecraft:model", "model": "minecraft:item/carrot_on_a_stick" },
"entries": [
{ "threshold": 1, "model": { "type": "minecraft:model", "model": "minecraft:item/wand" } }
]
}
}
Ang fallback is what a plain carrot on a stick still looks like. Without it, every unmodified one in the world turns into your wand.
Ang layout ng folder
pack.mcmeta
assets/minecraft/
├── items/carrot_on_a_stick.json the dispatch
├── models/item/wand.json the model
└── textures/item/wand.png the texture
models/item/wand.json at its simplest:
{ "parent": "minecraft:item/generated", "textures": { "layer0": "minecraft:item/wand" } }
Pansining ang texture path ay may walang textures/ prefix and no .png — iyon ang nag-iisang pinakakaraniwang dahilan ng isang kulay-ube at itim na cube.
Pagbibigay ng item
/give @p carrot_on_a_stick[custom_model_data={floats:[1]}]
Tumatanggap na ang component ng isang object na may mga typed list ngayon, hindi simpleng integer. custom_model_data=1 is the old syntax and silently does nothing.
Kung bakit ito lumalabas bilang kulay-ube na cube
Ayon sa pagkakasunod-sunod ng posibilidad:
- Mali ang texture path — kabilang ang
textures/or.png, or the file is not where the
sinasabi ng path.
- Case ng filename — case-sensitive ang laro kahit na hindi case-sensitive ang iyong OS.
pack_formattoo low — naglo-load ang pack ngunit angitems/folder is ignored. Match
ang format sa bersyong ginagamit mo.
- Maling na-zip —
pack.mcmetamust be at the root ng zip, hindi sa loob ng isang
folder sa loob ng zip.
Iba pang selector
range_dispatch on a number is only one option. You can also dispatch on minecraft:display_context (different model in hand versus in a frame), minecraft:using_item, or minecraft:selected — which is how a bow shows a drawn state.
Bumuo ng dispatch JSON, ang model file at ang give command nang magkakasama sa Mga Tool sa Custom Model & Item Component.