User Tools

Site Tools


tutorial:enchantments

Differences

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

Link to this comparison view

Next revisionBoth sides next revision
tutorial:enchantments [2019/07/02 20:08] – initial kermit draylartutorial:enchantments [2019/07/02 20:13] – finished class creation section draylar
Line 47: Line 47:
 ''getAttackDamage'', as you would expect, is the additional damage provided by the enchantment. ''level'' is the level of the enchantment: ''getAttackDamage'', as you would expect, is the additional damage provided by the enchantment. ''level'' is the level of the enchantment:
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 +@Override
 public float getAttackDamage(int level, EntityGroup group) public float getAttackDamage(int level, EntityGroup group)
 { {
Line 52: Line 53:
 } }
 </code> </code>
 +
 +''getMinimumPower'' is the minimum level required to get the enchant in an enchanting table. We'll set it to 1, so you can get it at any level:
 +<code java [enable_line_numbers="false"]>
 +@Override
 +public int getMinimumPower(int int_1)
 +{
 +    return 1;;
 +}
 +</code>
 +
 +''getMaximumLevel'' is the number of tiers the enchantment has. ((Enchantments with more than a single tier will have roman numerals after the name to show the level. If the enchantment only has a single level, nothing is added.))
 +<code java [enable_line_numbers="false"]>
 +@Override
 +public int getMaximumLevel()
 +{
 +    return 5;
 +}
 +</code>
 +
 +Finally, ''differs'' is how you isolate enchantments and prevent them from being on the same tool. As an example, sharpness can't be used with smite. We'll prevent our enchant from being combined with sharpness.
 +<code java [enable_line_numbers="false"]>
 +@Override
 +public boolean differs(Enchantment enchantment)
 +{
 +    return super.differs(enchantment) && enchantment != Enchantments.SHARPNESS;
 +}
 +</code>
 +
 +
tutorial/enchantments.txt · Last modified: 2023/01/04 13:52 by datsuns