github.com/df-mc/dragonfly@v0.9.13/server/item/enchanted_apple.go (about)

     1  package item
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/entity/effect"
     5  	"github.com/df-mc/dragonfly/server/world"
     6  	"time"
     7  )
     8  
     9  // EnchantedApple is a rare variant of the golden apple that has stronger effects.
    10  type EnchantedApple struct{}
    11  
    12  // AlwaysConsumable ...
    13  func (EnchantedApple) AlwaysConsumable() bool {
    14  	return true
    15  }
    16  
    17  // ConsumeDuration ...
    18  func (EnchantedApple) ConsumeDuration() time.Duration {
    19  	return DefaultConsumeDuration
    20  }
    21  
    22  // Consume ...
    23  func (EnchantedApple) Consume(_ *world.World, c Consumer) Stack {
    24  	c.Saturate(4, 9.6)
    25  	c.AddEffect(effect.New(effect.Absorption{}, 4, 2*time.Minute))
    26  	c.AddEffect(effect.New(effect.Regeneration{}, 5, 30*time.Second))
    27  	c.AddEffect(effect.New(effect.FireResistance{}, 1, 5*time.Minute))
    28  	c.AddEffect(effect.New(effect.Resistance{}, 1, 5*time.Minute))
    29  	return Stack{}
    30  }
    31  
    32  // EncodeItem ...
    33  func (EnchantedApple) EncodeItem() (name string, meta int16) {
    34  	return "minecraft:enchanted_golden_apple", 0
    35  }