मॉड्स के बिना कस्टम एन्चांटमेंट्स: डेटा-संचालित एन्चांटमेंट फ़ॉर्मेट
एन्चांटमेंट्स डेटा पैक 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 और इसके आर्मर-ट्रिम समकक्ष को इसमें बनाएँ कस्टम एन्चांटमेंट और ट्रिम बिल्डर.