The Best Resource for Minecraft
The Best Resource for Minecraft

Custom model data: دادن چندین مدل به یک آیتم بدون جایگزینی چیزی

Custom model data: دادن چندین مدل به یک آیتم بدون جایگزینی چیزی

سیستم item-model جایگزین پردیکیت قدیمی CustomModelData شد. در اینجا چیدمان پوشه، فایل JSON که مقادیر را به مدل‌ها نگاشت می‌کند و دلیل نمایش تکسچر شما به شکل مکعب بنفش آمده است.

مدل‌های سفارشی آیتم به سرور اجازه می‌دهند یک «چوب جادویی» ارائه دهد که در واقع یک carrot on a stick با مدلی متفاوت است. این سازوکار تغییر کرده و بیشتر آموزش‌ها هنوز روش قدیمی را توضیح می‌دهند.

آنچه تغییر کرد

روش قدیمی — 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" }

روش فعلی — یک 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" } }
    ]
  }
}

این fallback is what a plain carrot on a stick still looks like. Without it, every unmodified one in the world turns into your wand.

چیدمان پوشه

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" } }

توجه کنید که مسیر تکسچر نباشد textures/ prefix and no .png — این شایع‌ترین دلیل نمایش یک مکعب بنفش و مشکی است.

دادن آیتم

/give @p carrot_on_a_stick[custom_model_data={floats:[1]}]

این کامپوننت اکنون یک آبجکت با فهرست‌های نوع‌دار می‌گیرد، نه صرفاً یک عدد صحیح ساده. custom_model_data=1 is the old syntax and silently does nothing.

چرا به شکل یک مکعب بنفش نمایش داده می‌شود

به ترتیب احتمال:

  1. مسیر تکسچر اشتباه است — شامل textures/ or .png, or the file is not where the

مسیر می‌گوید.

  1. حساسیت به حروف بزرگ و کوچک در نام فایل — بازی به بزرگی و کوچکی حروف حساس است، حتی اگر سیستم‌عامل شما نباشد.
  2. pack_format too low — پک بارگیری می‌شود اما items/ folder is ignored. Match

فرمت متناسب با نسخه‌ای که در آن هستید.

  1. زیپ کردن اشتباهpack.mcmeta must be at the ریشه فایل zip، نه داخل یک

پوشه درون فایل zip.

سایر سلکتورها

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.

فایل JSON توزیع، فایل مدل و دستور give را با هم بسازید در ابزارهای مدل سفارشی و کامپوننت آیتم.

امتحان ابزار: Custom Model & Item Component Tools →