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