github.com/df-mc/dragonfly@v0.9.13/server/item/enchantment/efficiency.go (about)

     1  package enchantment
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/item"
     5  	"github.com/df-mc/dragonfly/server/world"
     6  )
     7  
     8  // Efficiency is an enchantment that increases mining speed.
     9  type Efficiency struct{}
    10  
    11  // Name ...
    12  func (Efficiency) Name() string {
    13  	return "Efficiency"
    14  }
    15  
    16  // MaxLevel ...
    17  func (Efficiency) MaxLevel() int {
    18  	return 5
    19  }
    20  
    21  // Cost ...
    22  func (Efficiency) Cost(level int) (int, int) {
    23  	min := 1 + 10*(level-1)
    24  	return min, min + 50
    25  }
    26  
    27  // Rarity ...
    28  func (Efficiency) Rarity() item.EnchantmentRarity {
    29  	return item.EnchantmentRarityCommon
    30  }
    31  
    32  // Addend returns the mining speed addend from efficiency.
    33  func (Efficiency) Addend(level int) float64 {
    34  	return float64(level*level + 1)
    35  }
    36  
    37  // CompatibleWithEnchantment ...
    38  func (Efficiency) CompatibleWithEnchantment(item.EnchantmentType) bool {
    39  	return true
    40  }
    41  
    42  // CompatibleWithItem ...
    43  func (Efficiency) CompatibleWithItem(i world.Item) bool {
    44  	t, ok := i.(item.Tool)
    45  	return ok && (t.ToolType() != item.TypeSword && t.ToolType() != item.TypeNone)
    46  }