up3
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
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
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// AquaAffinity is a helmet enchantment that increases underwater mining speed.
|
||||
var AquaAffinity aquaAffinity
|
||||
|
||||
type aquaAffinity struct{}
|
||||
|
||||
// Name ...
|
||||
func (aquaAffinity) Name() string {
|
||||
return "Aqua Affinity"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (aquaAffinity) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (aquaAffinity) Cost(int) (int, int) {
|
||||
return 1, 41
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (aquaAffinity) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (aquaAffinity) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (aquaAffinity) CompatibleWithItem(i world.Item) bool {
|
||||
h, ok := i.(item.HelmetType)
|
||||
return ok && h.Helmet()
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// BlastProtection is an armour enchantment that reduces damage from explosions.
|
||||
var BlastProtection blastProtection
|
||||
|
||||
type blastProtection struct{}
|
||||
|
||||
// Name ...
|
||||
func (blastProtection) Name() string {
|
||||
return "Blast Protection"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (blastProtection) MaxLevel() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (blastProtection) Cost(level int) (int, int) {
|
||||
minCost := 5 + (level-1)*8
|
||||
return minCost, minCost + 8
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (blastProtection) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// Modifier returns the base protection modifier for the enchantment.
|
||||
func (blastProtection) Modifier() float64 {
|
||||
return 0.08
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (blastProtection) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != FireProtection && t != ProjectileProtection && t != Protection
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (blastProtection) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Armour)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"math"
|
||||
)
|
||||
|
||||
// AffectedDamageSource represents a world.DamageSource whose damage may be
|
||||
// affected by an enchantment. A world.DamageSource does not need to implement
|
||||
// AffectedDamageSource to let protection affect the damage. This happens
|
||||
// depending on the (world.DamageSource).ReducedByResistance() method.
|
||||
type AffectedDamageSource interface {
|
||||
world.DamageSource
|
||||
// AffectedByEnchantment specifies if a world.DamageSource is affected by
|
||||
// the item.EnchantmentType passed.
|
||||
AffectedByEnchantment(e item.EnchantmentType) bool
|
||||
}
|
||||
|
||||
// DamageModifier is an item.EnchantmentType that can reduce damage through a
|
||||
// modifier if an AffectedDamageSource returns true for it.
|
||||
type DamageModifier interface {
|
||||
Modifier() float64
|
||||
}
|
||||
|
||||
// ProtectionFactor calculates the combined protection factor for a slice of
|
||||
// item.Enchantment. The factor depends on the world.DamageSource passed and is
|
||||
// in a range of [0, 0.8], where 0.8 means incoming damage would be reduced by
|
||||
// 80%.
|
||||
func ProtectionFactor(src world.DamageSource, enchantments []item.Enchantment) float64 {
|
||||
f := 0.0
|
||||
for _, e := range enchantments {
|
||||
t := e.Type()
|
||||
modifier, ok := t.(DamageModifier)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
reduced := false
|
||||
if _, ok := t.(protection); ok && src.ReducedByResistance() {
|
||||
// Special case for protection, because it applies to all damage
|
||||
// sources by default, except those not reduced by resistance.
|
||||
reduced = true
|
||||
} else if asrc, ok := src.(AffectedDamageSource); ok && asrc.AffectedByEnchantment(t) {
|
||||
reduced = true
|
||||
}
|
||||
|
||||
if reduced {
|
||||
f += float64(e.Level()) * modifier.Modifier()
|
||||
}
|
||||
}
|
||||
return math.Min(f, 0.8)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// DepthStrider is a boot enchantment that increases underwater movement speed.
|
||||
var DepthStrider depthStrider
|
||||
|
||||
type depthStrider struct{}
|
||||
|
||||
// Name ...
|
||||
func (depthStrider) Name() string {
|
||||
return "Depth Strider"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (depthStrider) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (depthStrider) Cost(level int) (int, int) {
|
||||
minCost := level * 10
|
||||
return minCost, minCost + 15
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (depthStrider) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (depthStrider) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
// TODO: Frost Walker
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (depthStrider) CompatibleWithItem(i world.Item) bool {
|
||||
b, ok := i.(item.BootsType)
|
||||
return ok && b.Boots()
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Efficiency is an enchantment that increases mining speed.
|
||||
var Efficiency efficiency
|
||||
|
||||
type efficiency struct{}
|
||||
|
||||
// Name ...
|
||||
func (efficiency) Name() string {
|
||||
return "Efficiency"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (efficiency) MaxLevel() int {
|
||||
return 5
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (efficiency) Cost(level int) (int, int) {
|
||||
minCost := 1 + 10*(level-1)
|
||||
return minCost, minCost + 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (efficiency) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityCommon
|
||||
}
|
||||
|
||||
// Addend returns the mining speed addend from efficiency.
|
||||
func (efficiency) Addend(level int) float64 {
|
||||
return float64(level*level + 1)
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (efficiency) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (efficiency) CompatibleWithItem(i world.Item) bool {
|
||||
t, ok := i.(item.Tool)
|
||||
return ok && (t.ToolType() != item.TypeSword && t.ToolType() != item.TypeNone)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// FeatherFalling is an enchantment to boots that reduces fall damage. It does
|
||||
// not affect falling speed.
|
||||
var FeatherFalling featherFalling
|
||||
|
||||
type featherFalling struct{}
|
||||
|
||||
// Name ...
|
||||
func (featherFalling) Name() string {
|
||||
return "Feather Falling"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (featherFalling) MaxLevel() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (featherFalling) Cost(level int) (int, int) {
|
||||
minCost := 5 + (level-1)*6
|
||||
return minCost, minCost + 6
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (featherFalling) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityUncommon
|
||||
}
|
||||
|
||||
// Modifier returns the base protection modifier for the enchantment.
|
||||
func (featherFalling) Modifier() float64 {
|
||||
return 0.12
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (featherFalling) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (featherFalling) CompatibleWithItem(i world.Item) bool {
|
||||
b, ok := i.(item.BootsType)
|
||||
return ok && b.Boots()
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"time"
|
||||
)
|
||||
|
||||
// FireAspect is a sword enchantment that sets the target on fire.
|
||||
var FireAspect fireAspect
|
||||
|
||||
type fireAspect struct{}
|
||||
|
||||
// Name ...
|
||||
func (fireAspect) Name() string {
|
||||
return "Fire Aspect"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (fireAspect) MaxLevel() int {
|
||||
return 2
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (fireAspect) Cost(level int) (int, int) {
|
||||
minCost := 10 + (level-1)*20
|
||||
return minCost, minCost + 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (fireAspect) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// Duration returns how long the fire from fire aspect will last.
|
||||
func (fireAspect) Duration(level int) time.Duration {
|
||||
return time.Second * 4 * time.Duration(level)
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (fireAspect) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (fireAspect) CompatibleWithItem(i world.Item) bool {
|
||||
t, ok := i.(item.Tool)
|
||||
return ok && t.ToolType() == item.TypeSword
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// FireProtection is an armour enchantment that decreases fire damage.
|
||||
var FireProtection fireProtection
|
||||
|
||||
type fireProtection struct{}
|
||||
|
||||
// Name ...
|
||||
func (fireProtection) Name() string {
|
||||
return "Fire Protection"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (fireProtection) MaxLevel() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (fireProtection) Cost(level int) (int, int) {
|
||||
minCost := 10 + (level-1)*8
|
||||
return minCost, minCost + 8
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (fireProtection) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityUncommon
|
||||
}
|
||||
|
||||
// Modifier returns the base protection modifier for the enchantment.
|
||||
func (fireProtection) Modifier() float64 {
|
||||
return 0.08
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (fireProtection) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != BlastProtection && t != ProjectileProtection && t != Protection
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (fireProtection) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Armour)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Flame turns your arrows into flaming arrows allowing you to set your targets
|
||||
// on fire.
|
||||
var Flame flame
|
||||
|
||||
type flame struct{}
|
||||
|
||||
// Name ...
|
||||
func (flame) Name() string {
|
||||
return "Flame"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (flame) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (flame) Cost(int) (int, int) {
|
||||
return 20, 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (flame) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// BurnDuration always returns five seconds, no matter the level.
|
||||
func (flame) BurnDuration() time.Duration {
|
||||
return time.Second * 5
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (flame) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (flame) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Bow)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Fortune is an enchantment that gives a chance to receive more item drops from certain blocks.
|
||||
var Fortune fortune
|
||||
|
||||
type fortune struct{}
|
||||
|
||||
// Name ...
|
||||
func (fortune) Name() string {
|
||||
return "Fortune"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (fortune) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (fortune) Cost(level int) (int, int) {
|
||||
minCost := 15 + (level-1)*9
|
||||
return minCost, minCost + 50 + level
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (fortune) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (fortune) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != SilkTouch
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (fortune) CompatibleWithItem(i world.Item) bool {
|
||||
t, ok := i.(item.Tool)
|
||||
return ok && (t.ToolType() == item.TypePickaxe || t.ToolType() == item.TypeShovel || t.ToolType() == item.TypeAxe || t.ToolType() == item.TypeHoe)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Infinity is an enchantment to bows that prevents regular arrows from being
|
||||
// consumed when shot.
|
||||
var Infinity infinity
|
||||
|
||||
type infinity struct{}
|
||||
|
||||
// Name ...
|
||||
func (infinity) Name() string {
|
||||
return "Infinity"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (infinity) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (infinity) Cost(int) (int, int) {
|
||||
return 20, 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (infinity) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityVeryRare
|
||||
}
|
||||
|
||||
// ConsumesArrows always returns false.
|
||||
func (infinity) ConsumesArrows() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (infinity) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != Mending
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (infinity) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Bow)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Knockback is an enchantment to a sword that increases the sword's knock-back.
|
||||
var Knockback knockback
|
||||
|
||||
type knockback struct{}
|
||||
|
||||
// Name ...
|
||||
func (knockback) Name() string {
|
||||
return "Knockback"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (knockback) MaxLevel() int {
|
||||
return 2
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (knockback) Cost(level int) (int, int) {
|
||||
minCost := 5 + (level-1)*20
|
||||
return minCost, minCost + 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (knockback) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityUncommon
|
||||
}
|
||||
|
||||
// Force returns the increase in knock-back force from the enchantment.
|
||||
func (knockback) Force(level int) float64 {
|
||||
return float64(level) / 2
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (knockback) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (knockback) CompatibleWithItem(i world.Item) bool {
|
||||
t, ok := i.(item.Tool)
|
||||
return ok && t.ToolType() == item.TypeSword
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Mending is an enchantment that repairs the item when experience orbs are
|
||||
// collected.
|
||||
var Mending mending
|
||||
|
||||
type mending struct{}
|
||||
|
||||
// Name ...
|
||||
func (mending) Name() string {
|
||||
return "Mending"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (mending) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (mending) Cost(level int) (int, int) {
|
||||
minCost := level * 25
|
||||
return minCost, minCost + 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (mending) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// Treasure ...
|
||||
func (mending) Treasure() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (mending) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != Infinity
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (mending) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Durable)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Multishot is an enchantment for crossbows that allow them to shoot three arrows or firework rockets at the cost of one.
|
||||
var Multishot multishot
|
||||
|
||||
type multishot struct{}
|
||||
|
||||
// Name ...
|
||||
func (multishot) Name() string {
|
||||
return "Multishot"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (multishot) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (m multishot) Cost(level int) (int, int) {
|
||||
return 20, 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (multishot) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (multishot) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != Piercing
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (multishot) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Crossbow)
|
||||
return ok
|
||||
}
|
||||
|
||||
// MultipleProjectiles ...
|
||||
func (multishot) MultipleProjectiles() bool {
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Piercing is an enchantment that allows arrows to damage and pierce through multiple entities, including shields.
|
||||
var Piercing piercing
|
||||
|
||||
type piercing struct{}
|
||||
|
||||
func (p piercing) Name() string {
|
||||
return "Piercing"
|
||||
}
|
||||
|
||||
func (p piercing) MaxLevel() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
func (p piercing) Cost(level int) (int, int) {
|
||||
return 1 + (level-1)*10, 50
|
||||
}
|
||||
|
||||
func (p piercing) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityCommon
|
||||
}
|
||||
|
||||
func (p piercing) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != Multishot
|
||||
}
|
||||
|
||||
func (p piercing) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Crossbow)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (p piercing) Pierces() bool {
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Power is a bow enchantment which increases arrow damage.
|
||||
var Power power
|
||||
|
||||
type power struct{}
|
||||
|
||||
// Name ...
|
||||
func (power) Name() string {
|
||||
return "Power"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (power) MaxLevel() int {
|
||||
return 5
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (power) Cost(level int) (int, int) {
|
||||
minCost := 1 + (level-1)*10
|
||||
return minCost, minCost + 15
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (power) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityCommon
|
||||
}
|
||||
|
||||
// PowerDamage returns the extra base damage dealt by the enchantment and level.
|
||||
func (power) PowerDamage(level int) float64 {
|
||||
return float64(level+1) * 0.5
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (power) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (power) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Bow)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// ProjectileProtection is an armour enchantment that reduces damage from
|
||||
// projectiles.
|
||||
var ProjectileProtection projectileProtection
|
||||
|
||||
type projectileProtection struct{}
|
||||
|
||||
// Name ...
|
||||
func (projectileProtection) Name() string {
|
||||
return "Projectile Protection"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (projectileProtection) MaxLevel() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (projectileProtection) Cost(level int) (int, int) {
|
||||
minCost := 3 + (level-1)*6
|
||||
return minCost, minCost + 6
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (projectileProtection) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityUncommon
|
||||
}
|
||||
|
||||
// Modifier returns the base protection modifier for the enchantment.
|
||||
func (projectileProtection) Modifier() float64 {
|
||||
return 0.08
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (projectileProtection) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != BlastProtection && t != FireProtection && t != Protection
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (projectileProtection) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Armour)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Protection is an armour enchantment which increases the damage reduction.
|
||||
var Protection protection
|
||||
|
||||
type protection struct{}
|
||||
|
||||
// Name ...
|
||||
func (protection) Name() string {
|
||||
return "Protection"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (protection) MaxLevel() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (protection) Cost(level int) (int, int) {
|
||||
minCost := 1 + (level-1)*11
|
||||
return minCost, minCost + 11
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (protection) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityCommon
|
||||
}
|
||||
|
||||
// Modifier returns the base protection modifier for the enchantment.
|
||||
func (protection) Modifier() float64 {
|
||||
return 0.04
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (protection) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != BlastProtection && t != FireProtection && t != ProjectileProtection
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (protection) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Armour)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Punch increases the knock-back dealt when hitting a player or mob with a bow.
|
||||
var Punch punch
|
||||
|
||||
type punch struct{}
|
||||
|
||||
// Name ...
|
||||
func (punch) Name() string {
|
||||
return "Punch"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (punch) MaxLevel() int {
|
||||
return 2
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (punch) Cost(level int) (int, int) {
|
||||
minCost := 12 + (level-1)*20
|
||||
return minCost, minCost + 25
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (punch) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// KnockBackMultiplier returns the punch multiplier for the level and horizontal speed.
|
||||
func (punch) KnockBackMultiplier() float64 {
|
||||
return 0.25
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (punch) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (punch) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Bow)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"time"
|
||||
)
|
||||
|
||||
// QuickCharge is an enchantment for quickly reloading a crossbow.
|
||||
var QuickCharge quickCharge
|
||||
|
||||
type quickCharge struct{}
|
||||
|
||||
// Name ...
|
||||
func (quickCharge) Name() string {
|
||||
return "Quick Charge"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (quickCharge) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (quickCharge) Cost(level int) (int, int) {
|
||||
minCost := 12 + (level-1)*20
|
||||
return minCost, 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (quickCharge) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityUncommon
|
||||
}
|
||||
|
||||
// ChargeDuration returns the charge duration.
|
||||
func (quickCharge) ChargeDuration(level int) time.Duration {
|
||||
return time.Duration((1.25 - 0.25*float64(level)) * float64(time.Second))
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (quickCharge) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (quickCharge) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Crossbow)
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package enchantment
|
||||
|
||||
import "github.com/df-mc/dragonfly/server/item"
|
||||
|
||||
func init() {
|
||||
item.RegisterEnchantment(0, Protection)
|
||||
item.RegisterEnchantment(1, FireProtection)
|
||||
item.RegisterEnchantment(2, FeatherFalling)
|
||||
item.RegisterEnchantment(3, BlastProtection)
|
||||
item.RegisterEnchantment(4, ProjectileProtection)
|
||||
item.RegisterEnchantment(5, Thorns)
|
||||
item.RegisterEnchantment(6, Respiration)
|
||||
item.RegisterEnchantment(7, DepthStrider)
|
||||
item.RegisterEnchantment(8, AquaAffinity)
|
||||
item.RegisterEnchantment(9, Sharpness)
|
||||
// TODO: (10) Smite. (Requires undead mobs)
|
||||
// TODO: (11) Bane of Arthropods. (Requires arthropod mobs)
|
||||
item.RegisterEnchantment(12, Knockback)
|
||||
item.RegisterEnchantment(13, FireAspect)
|
||||
// TODO: (14) Looting.
|
||||
item.RegisterEnchantment(15, Efficiency)
|
||||
item.RegisterEnchantment(16, SilkTouch)
|
||||
item.RegisterEnchantment(17, Unbreaking)
|
||||
item.RegisterEnchantment(18, Fortune)
|
||||
item.RegisterEnchantment(19, Power)
|
||||
item.RegisterEnchantment(20, Punch)
|
||||
item.RegisterEnchantment(21, Flame)
|
||||
item.RegisterEnchantment(22, Infinity)
|
||||
// TODO: (23) Luck of the Sea.
|
||||
// TODO: (24) Lure.
|
||||
// TODO: (25) Frost Walker.
|
||||
item.RegisterEnchantment(26, Mending)
|
||||
// TODO: (27) Curse of Binding.
|
||||
item.RegisterEnchantment(28, CurseOfVanishing)
|
||||
// TODO: (29) Impaling.
|
||||
// TODO: (30) Riptide.
|
||||
// TODO: (31) Loyalty.
|
||||
// TODO: (32) Channeling.
|
||||
item.RegisterEnchantment(33, Multishot)
|
||||
item.RegisterEnchantment(34, Piercing)
|
||||
item.RegisterEnchantment(35, QuickCharge)
|
||||
item.RegisterEnchantment(36, SoulSpeed)
|
||||
item.RegisterEnchantment(37, SwiftSneak)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Respiration extends underwater breathing time by +15 seconds per enchantment
|
||||
// level in addition to the default time of 15 seconds.
|
||||
var Respiration respiration
|
||||
|
||||
type respiration struct{}
|
||||
|
||||
// Name ...
|
||||
func (respiration) Name() string {
|
||||
return "Respiration"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (respiration) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (respiration) Cost(level int) (int, int) {
|
||||
minCost := 10 * level
|
||||
return minCost, minCost + 30
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (respiration) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityRare
|
||||
}
|
||||
|
||||
// Chance returns the chance of the enchantment blocking the air supply from ticking.
|
||||
func (respiration) Chance(level int) float64 {
|
||||
return 1.0 / float64(level+1)
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (respiration) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (respiration) CompatibleWithItem(i world.Item) bool {
|
||||
h, ok := i.(item.HelmetType)
|
||||
return ok && h.Helmet()
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// Sharpness is an enchantment applied to a sword or axe that increases melee
|
||||
// damage.
|
||||
var Sharpness sharpness
|
||||
|
||||
type sharpness struct{}
|
||||
|
||||
// Name ...
|
||||
func (sharpness) Name() string {
|
||||
return "Sharpness"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (sharpness) MaxLevel() int {
|
||||
return 5
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (sharpness) Cost(level int) (int, int) {
|
||||
minCost := 1 + (level-1)*11
|
||||
return minCost, minCost + 20
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (sharpness) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityCommon
|
||||
}
|
||||
|
||||
// Addend returns the additional damage when attacking with sharpness.
|
||||
func (sharpness) Addend(level int) float64 {
|
||||
return float64(level) * 1.25
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (sharpness) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (sharpness) CompatibleWithItem(i world.Item) bool {
|
||||
t, ok := i.(item.Tool)
|
||||
return ok && (t.ToolType() == item.TypeSword || t.ToolType() == item.TypeAxe)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// SilkTouch is an enchantment that allows many blocks to drop themselves
|
||||
// instead of their usual items when mined.
|
||||
var SilkTouch silkTouch
|
||||
|
||||
type silkTouch struct{}
|
||||
|
||||
// Name ...
|
||||
func (silkTouch) Name() string {
|
||||
return "Silk Touch"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (silkTouch) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (silkTouch) Cost(int) (int, int) {
|
||||
return 15, 65
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (silkTouch) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityVeryRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (silkTouch) CompatibleWithEnchantment(t item.EnchantmentType) bool {
|
||||
return t != Fortune
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (silkTouch) CompatibleWithItem(i world.Item) bool {
|
||||
t, ok := i.(item.Tool)
|
||||
return ok && (t.ToolType() != item.TypeSword && t.ToolType() != item.TypeNone)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// SoulSpeed is an enchantment that can be applied on boots and allows the
|
||||
// player to walk more quickly on soul sand or soul soil.
|
||||
var SoulSpeed soulSpeed
|
||||
|
||||
type soulSpeed struct{}
|
||||
|
||||
// Name ...
|
||||
func (soulSpeed) Name() string {
|
||||
return "Soul Speed"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (soulSpeed) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (soulSpeed) Cost(level int) (int, int) {
|
||||
minCost := level * 10
|
||||
return minCost, minCost + 15
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (soulSpeed) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityVeryRare
|
||||
}
|
||||
|
||||
// Treasure ...
|
||||
func (soulSpeed) Treasure() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (soulSpeed) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (soulSpeed) CompatibleWithItem(i world.Item) bool {
|
||||
b, ok := i.(item.BootsType)
|
||||
return ok && b.Boots()
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// SwiftSneak is a non-renewable enchantment that can be applied to leggings
|
||||
// and allows the player to walk more quickly while sneaking.
|
||||
var SwiftSneak swiftSneak
|
||||
|
||||
type swiftSneak struct{}
|
||||
|
||||
// Name ...
|
||||
func (swiftSneak) Name() string {
|
||||
return "Swift Sneak"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (swiftSneak) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (swiftSneak) Cost(level int) (int, int) {
|
||||
minCost := level * 25
|
||||
return minCost, minCost + 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (swiftSneak) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityVeryRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (swiftSneak) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Treasure ...
|
||||
func (swiftSneak) Treasure() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (swiftSneak) CompatibleWithItem(i world.Item) bool {
|
||||
b, ok := i.(item.LeggingsType)
|
||||
return ok && b.Leggings()
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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 }
|
||||
@@ -0,0 +1,58 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"math/rand/v2"
|
||||
)
|
||||
|
||||
// Unbreaking is an enchantment that gives a chance for an item to avoid
|
||||
// durability reduction when it is used, effectively increasing the item's
|
||||
// durability.
|
||||
var Unbreaking unbreaking
|
||||
|
||||
type unbreaking struct{}
|
||||
|
||||
// Name ...
|
||||
func (unbreaking) Name() string {
|
||||
return "Unbreaking"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (unbreaking) MaxLevel() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (unbreaking) Cost(level int) (int, int) {
|
||||
minCost := 5 + 8*(level-1)
|
||||
return minCost, minCost + 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (unbreaking) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityUncommon
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (unbreaking) CompatibleWithEnchantment(item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (unbreaking) CompatibleWithItem(i world.Item) bool {
|
||||
_, ok := i.(item.Durable)
|
||||
return ok
|
||||
}
|
||||
|
||||
// Reduce returns the amount of damage that should be reduced with unbreaking.
|
||||
func (unbreaking) Reduce(it world.Item, level, amount int) int {
|
||||
after := amount
|
||||
_, ok := it.(item.Armour)
|
||||
for i := 0; i < amount; i++ {
|
||||
if (!ok || rand.Float64() >= 0.6) && rand.IntN(level+1) > 0 {
|
||||
after--
|
||||
}
|
||||
}
|
||||
return after
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package enchantment
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/item"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
)
|
||||
|
||||
// CurseOfVanishing is an enchantment that causes the item to disappear on
|
||||
// death.
|
||||
var CurseOfVanishing curseOfVanishing
|
||||
|
||||
type curseOfVanishing struct{}
|
||||
|
||||
// Name ...
|
||||
func (curseOfVanishing) Name() string {
|
||||
return "Curse of Vanishing"
|
||||
}
|
||||
|
||||
// MaxLevel ...
|
||||
func (curseOfVanishing) MaxLevel() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Cost ...
|
||||
func (curseOfVanishing) Cost(int) (int, int) {
|
||||
return 25, 50
|
||||
}
|
||||
|
||||
// Rarity ...
|
||||
func (curseOfVanishing) Rarity() item.EnchantmentRarity {
|
||||
return item.EnchantmentRarityVeryRare
|
||||
}
|
||||
|
||||
// CompatibleWithEnchantment ...
|
||||
func (curseOfVanishing) CompatibleWithEnchantment(_ item.EnchantmentType) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CompatibleWithItem ...
|
||||
func (curseOfVanishing) CompatibleWithItem(i world.Item) bool {
|
||||
_, arm := i.(item.Armour)
|
||||
_, com := i.(item.Compass)
|
||||
_, dur := i.(item.Durable)
|
||||
_, rec := i.(item.RecoveryCompass)
|
||||
// TODO: Carrot on a Stick
|
||||
// TODO: Warped Fungus on a Stick
|
||||
return arm || com || dur || rec
|
||||
}
|
||||
|
||||
// Treasure ...
|
||||
func (curseOfVanishing) Treasure() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Curse ...
|
||||
func (curseOfVanishing) Curse() bool {
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user