Your First Enchant
On this page(6)
This tutorial builds Frost Nova: a ring of frost bursts around the target and hits every mob near it. You write the file, add its menu tiles, reload, give yourself a level and test it.
You need operator access, a placed zone (the shipped barn works) and a sword.
Step 1: Create the file
Create plugins/SnDungeons/modules/sword/enchants/frost-nova.yml. The file name is the enchant
id: lowercase letters, digits and -, at most 56 characters, extension .yml.
modules/sword/enchants/frost-nova.yml
# Shown in messages, menus and the {enchant} variable.
display-name: '&b&lFrost Nova'
# Checked when the file loads; the menus use their own tile material.
icon: PACKED_ICE
description:
- "&7A ring of frost bursts around"
- "&7your target and hits every mob near it."
# Levels 1 to 500. The chance climbs evenly from 1% at level 1 to 6% at 500.
max-level: 500
chance: { min: 1, max: 6 }
trigger: swing
# 3 seconds before it can proc again for that player.
cooldown-ticks: 60
# Level L to L+1 costs 100 + 40 x L souls (the first level costs 100).
cost: { currency: souls, starting-cost: 100, increase-cost-by: 40 }
actions:
# A flat ring of snowflakes on the ground around the target.
- type: particle
particle: SNOWFLAKE
shape: circle
at: '{target_pos}'
offset: '0, 0.2, 0'
radius: 4
count: 40
- type: sound
sound: BLOCK_GLASS_BREAK
at: '{target_pos}'
volume: 0.8
pitch: '{random:1.2:1.6}'
# Every mob within 4 blocks of the target, nearest first, at most 8.
- type: damage
amount: '{damage} * (3 + {level} / 100)'
area:
center: '{target_pos}'
radius: 4
max-mobs: 8
# From level 250 on, a floating text shows the hit.
- type: entity
display: { text: '&b&lFROST NOVA', billboard: center }
at: '{target_top}'
offset: '0, 0.3, 0'
lifetime: 20
movement: { type: rise, speed: 0.04 }
requirement: '{level} >= 250'What each part does:
| Part | Meaning |
|---|---|
chance: { min: 1, max: 6 } | 1% at level 1, 6% at level 500, evenly in between |
trigger: swing | It rolls on every automatic swing (the killing one too) |
cooldown-ticks: 60 | 60 ticks (3 seconds) per player after each proc |
{damage} | The damage of the swing that procced, boosters included |
{level} | The player's level of this enchant |
requirement | The action runs only while the expression is not 0 |
Step 2: Add the tiles to the enchants menu
The enchants menu lists only the tiles declared in its files. Page 1 (enchants.yml) is full, so
this goes on page 2: modules/sword/guis/enchants-2.yml.
2a. Free a cell. Give the new enchant a letter in the layout:. The shipped page 2 uses a to
h, so change the third row from "#h#######" to "#hi######".
2b. Add three items under items:, in this order. The menu shows the first item whose
view-requirements pass, so the two states go before the default tile.
modules/sword/guis/enchants-2.yml (under items:)
frost-nova-maxed:
material: PACKED_ICE
glow: true
display-name: "&b&lFrost Nova &r&f&lEnchant"
lore:
- "&7A ring of frost bursts around"
- "&7your target and hits every mob near it."
- ""
- " &3┃ &r&bLevel: &r&a%sndungeons_enchant_frost-nova_level% &8(max)"
- " &3┃ &r&bChance: &r&f%sndungeons_enchant_frost-nova_chance%%"
- ""
- "&a&lMAX LEVEL"
key: i
view-requirements:
- "%sndungeons_enchant_frost-nova_state% == maxed"
click-actions:
- "[sword-enchants] upgrade frost-nova"
- "[sound] UI_BUTTON_CLICK"
frost-nova-unbuyable:
material: PACKED_ICE
display-name: "&b&lFrost Nova &r&f&lEnchant"
lore:
- "&c&lWARNING: &r&4It cannot be bought: its currency"
- "&4%sndungeons_enchant_frost-nova_currency% &4is not loaded."
key: i
view-requirements:
- "%sndungeons_enchant_frost-nova_state% == unbuyable"
click-actions:
- "[sword-enchants] upgrade frost-nova"
- "[sound] UI_BUTTON_CLICK"
frost-nova:
material: PACKED_ICE
display-name: "&b&lFrost Nova &r&f&lEnchant"
lore:
- "&7A ring of frost bursts around"
- "&7your target and hits every mob near it."
- ""
- " &3┃ &r&bLevel: &r&f%sndungeons_enchant_frost-nova_level%&7/&f%sndungeons_enchant_frost-nova_max%"
- " &3┃ &r&bChance: &r&f%sndungeons_enchant_frost-nova_chance%% &8-> &f%sndungeons_enchant_frost-nova_next_chance%%"
- " &3┃ &r&bNext Level: &r&f%sndungeons_enchant_frost-nova_cost% %sndungeons_enchant_frost-nova_currency%"
- " &3┃ &r&bYou Have: &r&f%sndungeons_enchant_frost-nova_balance% %sndungeons_enchant_frost-nova_currency%"
- ""
- "&b&lCLICK HERE"
- "&3Click here to upgrade this enchant."
key: i
click-actions:
- "[sword-enchants] upgrade frost-nova"
- "[sound] UI_BUTTON_CLICK"Step 3: Add the info tile to the upgrade menu
Clicking the tile opens the shared upgrade menu, modules/sword/guis/upgrade.yml. Its top cell
i shows the enchant you opened, so add two items there (the max state first):
modules/sword/guis/upgrade.yml (under items:)
info-frost-nova-maxed:
material: PACKED_ICE
glow: true
display-name: "&b&lFrost Nova &r&f&lEnchant"
lore:
- " &3┃ &r&bLevel: &r&a%sndungeons_viewenchant_level% &8(max)"
- " &3┃ &r&bChance: &r&f%sndungeons_viewenchant_chance%%"
- ""
- "&a&lMAX LEVEL"
key: i
view-requirements:
- "%sndungeons_viewenchant_id% == frost-nova"
- "%sndungeons_viewenchant_state% == maxed"
info-frost-nova:
material: PACKED_ICE
display-name: "&b&lFrost Nova &r&f&lEnchant"
lore:
- " &3┃ &r&bLevel: &r&f%sndungeons_viewenchant_level%&7/&f%sndungeons_viewenchant_max%"
- " &3┃ &r&bChance: &r&f%sndungeons_viewenchant_chance%% &8-> &f%sndungeons_viewenchant_next_chance%%"
- " &3┃ &r&bYou Have: &r&f%sndungeons_viewenchant_balance% %sndungeons_viewenchant_currency%"
key: i
view-requirements:
- "%sndungeons_viewenchant_id% == frost-nova"The level buttons, Max and Prestige are shared by every enchant: you add nothing else.
Step 4: Reload and read the console
Run /dungeons reload. A clean file prints no warning. A broken value prints one line with the
file and the key, for example:
modules/sword/enchants/frost-nova.yml: actions[3].amount '{dmg} * 2' is not a valid expression:
unknown variable {dmg} (known: level, max_level, damage, ...); action skippedFix the line and reload again. Testing and Errors lists the common warnings.
Step 5: Test it
/dungeons admin sword testenchant <you> frost-nova 300Your next swing procs Frost Nova for sure, at level 300, and no other enchant. Hit a mob in your zone and watch the ring. Run it again without the level to test at your own level (1 when you have none).
Then give yourself real levels and check the menus:
/dungeons admin sword enchant <you> frost-nova 10Open /sword enchants, go to page 2, and check the tile, its states and the upgrade menu.
Iterate fast: edit the file, /dungeons reload, testenchant, swing. A reload keeps every
level, so you never give them again.
Where to go next
- Make the effect richer: Actions and the Cookbook.
- Tune the price curve and prestige: Pricing and Prestige.
- Reuse parts across enchants: Presets.
- Let an AI agent write the next one: AI Agent Skill.