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 revision Previous revision
tutorial:enchantments [2020/07/03 18:36]
draylar more formatting fixes
tutorial:enchantments [2020/07/03 19:02] (current)
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. In our enchantment class, we pass up ''​VERY_RARE''​ as the enchantment rarity, ''​WEAPON''​ as the enchantment target, and ''​MAINHAND''​ as the only valid tool type for our 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 ''​UNCOMMON''​ as the enchantment rarity, ''​WEAPON''​ as the enchantment target, and ''​MAINHAND''​ as the only valid tool type for our enchantment.
 <code java [enable_line_numbers="​true"​]>​ <code java [enable_line_numbers="​true"​]>​
 public class FrostEnchantment extends Enchantment { public class FrostEnchantment extends Enchantment {
  
     public FrostEnchantment() {     public FrostEnchantment() {
-        super(Enchantment.Rarity.VERY_RARE, EnchantmentTarget.WEAPON,​ new EquipmentSlot[] {EquipmentSlot.MAINHAND});​+        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:​
  
-''​getMinPower''​ is related to the minimum level needed to see the enchant in a table, but it is not a 1:1 ratio. Most enchantments return something like ''​10 * level'',​ with different scales depending on the max level and rarity of the enchantment. We will return 1 so it is always available.+''​getMinPower''​ is related to the minimum level needed to see the enchant in a table, but it is not a 1:1 ratio. Most enchantments return something like ''​10 * level'',​ with different scales depending on the max level and rarity of the enchantment. We will return 1 so it is always available. Note that the max power of an enchantment is set to ''​min(level) + 5''​ by default, which means this enchantment will only appear at very low levels. You will have to tweak your enchantment properties on your own and look at similar enchantment values to find the sweet number spot.
 <code java [enable_line_numbers="​false"​]>​ <code java [enable_line_numbers="​false"​]>​
 @Override @Override
Line 69: Line 69:
 </​code>​ </​code>​
  
-This registers our enchantment under the namespace ''​tutorial:​frost''​.+This registers our enchantment under the namespace ''​tutorial:​frost''​. All non-treasure enchantments are available in an enchanting table, including the ones you register.
  
 ==== Adding Translations & Testing ==== ==== Adding Translations & Testing ====
tutorial/enchantments.txt ยท Last modified: 2020/07/03 19:02 by draylar