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,35 @@
|
||||
package item
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/entity/effect"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"time"
|
||||
)
|
||||
|
||||
// GoldenApple is a special food item that bestows beneficial effects.
|
||||
type GoldenApple struct{}
|
||||
|
||||
// AlwaysConsumable ...
|
||||
func (e GoldenApple) AlwaysConsumable() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ConsumeDuration ...
|
||||
func (e GoldenApple) ConsumeDuration() time.Duration {
|
||||
return DefaultConsumeDuration
|
||||
}
|
||||
|
||||
// Consume ...
|
||||
func (e GoldenApple) Consume(_ *world.Tx, c Consumer) Stack {
|
||||
c.Saturate(4, 9.6)
|
||||
prev := c.Absorption()
|
||||
c.AddEffect(effect.New(effect.Absorption, 1, 2*time.Minute))
|
||||
c.SetAbsorption(max(prev, min(prev+4, 16)))
|
||||
c.AddEffect(effect.New(effect.Regeneration, 2, 5*time.Second))
|
||||
return Stack{}
|
||||
}
|
||||
|
||||
// EncodeItem ...
|
||||
func (e GoldenApple) EncodeItem() (name string, meta int16) {
|
||||
return "minecraft:golden_apple", 0
|
||||
}
|
||||
Reference in New Issue
Block a user