افسونهای سفارشی بدون ماد: قالب دادهمحور افسونها
افسونها به JSON دیتاپک تبدیل شدهاند، بنابراین یک افسون سفارشی نیازی به ماد ندارد. در اینجا ساختار فایل، مؤلفههای افکت که در عمل کاری انجام میدهند و نحوه قابل دستیابی کردن آن آورده شده است.
افسونها قبلاً به صورت هاردکد بودند. اکنون آنها دادههای دیتاپک هستند، به این معنی که یک افسون کاملاً سفارشی — نام جدید، افکت جدید، نمودار هزینه جدید — یک فایل JSON است.
محل قرارگیری آن
data/<namespace>/enchantment/lightning_strike.json
مفرد enchantment/, like every other datapack category since the rename.
حداقل فایل مورد نیاز
{
"description": { "translate": "enchantment.my_pack.lightning_strike" },
"supported_items": "#minecraft:enchantable/sword",
"weight": 2,
"max_level": 3,
"min_cost": { "base": 10, "per_level_above_first": 10 },
"max_cost": { "base": 50, "per_level_above_first": 10 },
"anvil_cost": 4,
"slots": ["mainhand"]
}
همین مقدار یک افسون واقعی ایجاد میکند که در میز افسونگری ظاهر میشود و روی آیتم نمایش مییابد. هنوز کاری انجام نمیدهد — رفتار آن جداگانه است.
weightکمیابی در میز افسونگری است. وانیلا از 10 برای رایج و 1 برای بسیار
کمیاب استفاده میکند. این مقدار نسبی است، نه درصد.
slotsمشخص میکند که افسون در کجا فعال است:mainhand,offhand,armor,
head, and so on. Omit it and the enchantment never applies.
supported_itemsیک تگ آیتم یا یک فهرست میگیرد.#minecraft:enchantable/*tags
از قبل برای گروههای منطقی وجود دارند.
ایجاد عملکرد برای آن
effects attaches behaviour:
"effects": {
"minecraft:post_attack": [{
"effect": { "type": "minecraft:run_function", "function": "my_pack:strike" },
"requirements": { "condition": "minecraft:random_chance", "chance": 0.25 }
}]
}
run_function is the escape hatch — anything a function can do, the enchantment can do. The built-in effect types cover damage, knockback, durability, item drops and attributes without needing a function at all, and they are cheaper.
requirements takes any predicate, so gating on the target's type, the weather, or a random chance is one block of JSON.
نامگذاری آن
description is a text component, so a hardcoded name works:
"description": { "text": "Lightning Strike", "color": "gold" }
اما یک translate key plus a language file in a resource pack is what makes it read correctly for players in other languages — the same reason this site takes game terms from Mojang's own translations.
قابل دستیابی کردن آن
سه روش، و شما معمولاً به بیش از یکی نیاز دارید:
- میز افسونگری — خودکار پس از اینکه
weightand the cost curve are set. - جدولهای لوت —
enchant_randomlywith your enchantment listed, or
enchant_with_levels if it should compete on cost.
- معاملات روستاییها — یک کتاب افسونشده با افسون شما در آیتم معامله.
افزودن آن به #minecraft:in_enchanting_table is what makes the table offer it at all; the tag is easy to forget and produces an enchantment that exists but never appears.
فایل JSON افسون و معادل armor-trim آن را، با تگها و اسلاتهای تنظیمشده، بسازید در سازنده افسون و تزیین سفارشی.