User Tools

Site Tools


tutorial:enchantments

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:enchantments [2019/07/02 20:13] – finished class creation section draylartutorial:enchantments [2019/07/02 20:23] – finish up end of tut draylar
Line 81: Line 81:
 </code> </code>
  
 +==== Registering Enchantment ====
 +Registering enchantments follows the same process as usual:
 +<code java [enable_line_numbers="false"]>
 +private static Enchantment WRATH;
 +
 +@Override
 +public void onInitialize()
 +{
 +    WRATH = Registry.register(
 +        Registry.ENCHANTMENT,
 + new Identifier("tutorial", "wrath"),
 + new WrathEnchantment(
 +     Enchantment.Weight.VERY_RARE,
 +     0,
 +     EquipmentSlot.MAINHAND
 + )
 +    );
 +}
 +</code>
 +
 +This registers our enchantment under the namespace ''tutorial:wrath'', sets it as a very rare enchantment, and only allows it on main hand tools.
 +
 +==== Adding Translations & Testing ====
 +You'll need to add a translation to your enchantment as well. Head over to your [[tutorial:lang|mod lang file]] and add a new entry:
 +
 +<code json [enable_line_numbers="false"]>
 +{
 +    "enchantment.tutorial.wrath": "Wrath"
 +}
 +</code>
 +
 +If you go in-game, you should be able to enchant main hand weapons with your new enchant:
 +
 +{{:tutorial:enchantment_wrath.png?400|}}
  
tutorial/enchantments.txt · Last modified: 2023/01/04 13:52 by datsuns