tutorial:enchantments
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:enchantments [2020/07/03 18:33] – formatting changes + mapping updates draylar | tutorial:enchantments [2020/07/03 19:02] – draylar | ||
---|---|---|---|
Line 10: | Line 10: | ||
==== Creating Enchantment Class ==== | ==== Creating Enchantment Class ==== | ||
- | Our new enchantment is called //Frost// and slows mobs on hit. The slowness effect, durability, and potency will grow relative to the level of the enchantment. | + | Our new enchantment is called //Frost// and slows mobs on hit. The slowness effect, durability, and potency will grow relative to the level of the enchantment. In our enchantment class, we pass up '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
public class FrostEnchantment extends Enchantment { | public class FrostEnchantment extends Enchantment { | ||
- | public FrostEnchantment(Rarity rarity, EnchantmentTarget type, EquipmentSlot[] slots) { | + | public FrostEnchantment() { |
- | super(rarity, type, slots) | + | super(Enchantment.Rarity.UNCOMMON, EnchantmentTarget.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND}); |
} | } | ||
} | } | ||
Line 22: | Line 22: | ||
We will now override a few basic methods for basic functionality: | We will now override a few basic methods for basic functionality: | ||
- | '' | + | '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
@Override | @Override | ||
Line 54: | Line 54: | ||
Registering enchantments follows the same process as usual: | Registering enchantments follows the same process as usual: | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | private static Enchantment FROST; | + | public class EnchantingExample implements ModInitializer { |
- | @Override | + | private static Enchantment |
- | public void onInitialize() { | + | Registry.ENCHANTMENT, |
- | | + | new Identifier(" |
- | Registry.ENCHANTMENT, | + | new FrostEnchantment() |
- | new Identifier(" | + | |
- | new FrostEnchantment( | + | |
- | Enchantment.Weight.VERY_RARE, | + | |
- | EnchantmentTarget.WEAPON, | + | |
- | new EquipmentSlot[] { | + | |
- | EquipmentSlot.MAINHAND | + | |
- | } | + | |
- | ) | + | |
); | ); | ||
+ | |||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | |||
+ | } | ||
} | } | ||
</ | </ | ||
- | This registers our enchantment under the namespace '' | + | This registers our enchantment under the namespace '' |
==== Adding Translations & Testing ==== | ==== Adding Translations & Testing ==== |
tutorial/enchantments.txt · Last modified: 2023/01/04 13:52 by datsuns