github.com/df-mc/dragonfly@v0.9.13/server/item/enchantment/blast_protection.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  // BlastProtection is an armour enchantment that reduces damage from explosions.
     9  type BlastProtection struct{}
    10  
    11  // Name ...
    12  func (BlastProtection) Name() string {
    13  	return "Blast Protection"
    14  }
    15  
    16  // MaxLevel ...
    17  func (BlastProtection) MaxLevel() int {
    18  	return 4
    19  }
    20  
    21  // Cost ...
    22  func (BlastProtection) Cost(level int) (int, int) {
    23  	min := 5 + (level-1)*8
    24  	return min, min + 8
    25  }
    26  
    27  // Rarity ...
    28  func (BlastProtection) Rarity() item.EnchantmentRarity {
    29  	return item.EnchantmentRarityRare
    30  }
    31  
    32  // Modifier returns the base protection modifier for the enchantment.
    33  func (BlastProtection) Modifier() float64 {
    34  	return 0.08
    35  }
    36  
    37  // CompatibleWithEnchantment ...
    38  func (BlastProtection) CompatibleWithEnchantment(t item.EnchantmentType) bool {
    39  	_, fireProtection := t.(FireProtection)
    40  	_, projectileProtection := t.(ProjectileProtection)
    41  	_, protection := t.(Protection)
    42  	return !fireProtection && !projectileProtection && !protection
    43  }
    44  
    45  // CompatibleWithItem ...
    46  func (BlastProtection) CompatibleWithItem(i world.Item) bool {
    47  	_, ok := i.(item.Armour)
    48  	return ok
    49  }