tutorial:enchantments
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:enchantments [2024/07/03 07:14] – solidblock | tutorial:enchantments [2024/08/23 13:52] (current) – [Adding Translations] solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Adding Enchantments ===== | + | ====== Adding Enchantments ====== |
| + | |||
| + | ===== Adding enchantments since 1.21 ===== | ||
| + | Since 1.21, enchantments has been data-driven, | ||
| + | |||
| + | To use the enchantments in code, you should just store '' | ||
| + | <code java TutorialEnchantments> | ||
| + | public final class TutorialEnchantments { | ||
| + | public static final RegistryKey< | ||
| + | |||
| + | private static RegistryKey< | ||
| + | return RegistryKey.of(RegistryKeys.ENCHANTMENT, | ||
| + | } | ||
| + | |||
| + | public static void initialize() { | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Remember to refer to the '' | ||
| + | <code java ExampleMod> | ||
| + | public class ExampleMod implements ModInitializer { | ||
| + | // [...] | ||
| + | |||
| + | @Override | ||
| + | public void onInitialize() { | ||
| + | // [...] | ||
| + | TutorialEnchantments.initialize(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | To add a translated name for your enchantment, | ||
| + | |||
| + | ===== Adding enchantments before 1.21 ===== | ||
| + | :!: This part of the tutorial only applies to older Minecraft versions. | ||
| To add enchantments to your mod, you'll need to: | To add enchantments to your mod, you'll need to: | ||
| Line 93: | Line 128: | ||
| This registers our enchantment under the namespace '' | This registers our enchantment under the namespace '' | ||
| - | ==== Adding Translations | + | ===== Adding Translations ===== |
| + | =) This part works both versions since 1.21 and before 1.21. | ||
| You'll need to add a translation to your enchantment as well. Head over to your [[tutorial: | You'll need to add a translation to your enchantment as well. Head over to your [[tutorial: | ||
| - | <code json [enable_line_numbers=" | + | < |
| { | { | ||
| " | " | ||
tutorial/enchantments.1719990892.txt.gz · Last modified: 2024/07/03 07:14 by solidblock