github.com/df-mc/dragonfly@v0.9.13/server/item/golden_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 // GoldenApple is a special food item that bestows beneficial effects. 10 type GoldenApple struct{} 11 12 // AlwaysConsumable ... 13 func (e GoldenApple) AlwaysConsumable() bool { 14 return true 15 } 16 17 // ConsumeDuration ... 18 func (e GoldenApple) ConsumeDuration() time.Duration { 19 return DefaultConsumeDuration 20 } 21 22 // Consume ... 23 func (e GoldenApple) Consume(_ *world.World, c Consumer) Stack { 24 c.Saturate(4, 9.6) 25 c.AddEffect(effect.New(effect.Absorption{}, 1, 2*time.Minute)) 26 c.AddEffect(effect.New(effect.Regeneration{}, 2, 5*time.Second)) 27 return Stack{} 28 } 29 30 // EncodeItem ... 31 func (e GoldenApple) EncodeItem() (name string, meta int16) { 32 return "minecraft:golden_apple", 0 33 }