Files
mc/server/item/enchantment/thorns.go
T
TarnaWijaya 26ed99fda6
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
up3
2026-07-09 08:33:57 +08:00

55 lines
1.2 KiB
Go

package enchantment
import (
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
)
// Thorns is an enchantment that inflicts damage on attackers.
var Thorns thorns
type thorns struct{}
// Name ...
func (thorns) Name() string {
return "Thorns"
}
// MaxLevel ...
func (thorns) MaxLevel() int {
return 3
}
// Cost ...
func (thorns) Cost(level int) (int, int) {
minCost := 10 + 20*(level-1)
return minCost, minCost + 50
}
// Rarity ...
func (thorns) Rarity() item.EnchantmentRarity {
return item.EnchantmentRarityVeryRare
}
// CompatibleWithEnchantment ...
func (thorns) CompatibleWithEnchantment(item.EnchantmentType) bool {
return true
}
// CompatibleWithItem ...
func (thorns) CompatibleWithItem(i world.Item) bool {
_, ok := i.(item.Armour)
return ok
}
// ThornsDamageSource is used for damage caused by thorns.
type ThornsDamageSource struct {
// Owner is the owner of the armour with the thorns enchantment.
Owner world.Entity
}
func (ThornsDamageSource) ReducedByResistance() bool { return true }
func (ThornsDamageSource) ReducedByArmour() bool { return false }
func (ThornsDamageSource) Fire() bool { return false }
func (ThornsDamageSource) IgnoreTotem() bool { return false }