The Best Resource for Minecraft
The Best Resource for Minecraft

Mga custom na enchantment nang walang mod: ang data-driven enchantment format

Mga custom na enchantment nang walang mod: ang data-driven enchantment format

Naging datapack JSON na ang mga enchantment, kaya hindi na kailangan ng mod para sa custom na enchantment. Narito ang itsura ng file, ang mga effect component na talagang may ginagawa, at kung paano ito makukuha.

Dati ay hardcoded ang mga enchantment. Ngayon ay datapack data na ang mga ito, na nangangahulugang ang isang tunay na custom na enchantment — bagong pangalan, bagong effect, bagong cost curve — ay isa nang JSON file.

Kung saan ito matatagpuan

data/<namespace>/enchantment/lightning_strike.json

Pang-isahan enchantment/, like every other datapack category since the rename.

Ang minimum na file

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

Sapat na iyon para magkaroon ng totoong enchantment na lumalabas sa mesa at makikita sa item. Wala pa itong ginagawa — hiwalay ang gawi nito.

  • weight ang rarity sa enchanting table. Gumagamit ang Vanilla ng 10 para sa karaniwan, 1 para sa napaka-

bihira. Ito ay relatibo, hindi isang porsyento.

  • slots ang nagpapasya kung saan aktibo ang enchantment: mainhand, offhand, armor,

head, and so on. Omit it and the enchantment never applies.

  • supported_items ay tumatanggap ng item tag o listahan. #minecraft:enchantable/* tags

ay umiiral na para sa mga nararapat na grupo.

Pagpapagana rito

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.

Pagpapangalan dito

description is a text component, so a hardcoded name works:

"description": { "text": "Lightning Strike", "color": "gold" }

ngunit ang isang 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.

Paggawa nitong makukuha

Tatlong paraan, at karaniwan ay gugustuhin mo ang higit sa isa:

  • Enchanting table — awtomatiko kapag weight and the cost curve are set.
  • Mga loot tableenchant_randomly with your enchantment listed, or

enchant_with_levels if it should compete on cost.

  • Mga villager trade — isang enchanted book na may enchantment mo sa item ng trade.

Pagdaragdag nito sa #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.

Buuin ang enchantment JSON at ang katapat nitong armor-trim, kasama ang mga naitakdang tag at slot, sa Custom Enchantment & Trim Builder.

Subukan ang tool: Custom Enchantment & Trim Builder →