github.com/df-mc/dragonfly@v0.9.13/server/item/enchantment/fire_aspect.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  	"time"
     7  )
     8  
     9  // FireAspect is a sword enchantment that sets the target on fire.
    10  type FireAspect struct{}
    11  
    12  // Name ...
    13  func (FireAspect) Name() string {
    14  	return "Fire Aspect"
    15  }
    16  
    17  // MaxLevel ...
    18  func (FireAspect) MaxLevel() int {
    19  	return 2
    20  }
    21  
    22  // Cost ...
    23  func (FireAspect) Cost(level int) (int, int) {
    24  	min := 10 + (level-1)*20
    25  	return min, min + 50
    26  }
    27  
    28  // Rarity ...
    29  func (FireAspect) Rarity() item.EnchantmentRarity {
    30  	return item.EnchantmentRarityRare
    31  }
    32  
    33  // Duration returns how long the fire from fire aspect will last.
    34  func (FireAspect) Duration(level int) time.Duration {
    35  	return time.Second * 4 * time.Duration(level)
    36  }
    37  
    38  // CompatibleWithEnchantment ...
    39  func (FireAspect) CompatibleWithEnchantment(item.EnchantmentType) bool {
    40  	return true
    41  }
    42  
    43  // CompatibleWithItem ...
    44  func (FireAspect) CompatibleWithItem(i world.Item) bool {
    45  	t, ok := i.(item.Tool)
    46  	return ok && t.ToolType() == item.TypeSword
    47  }