github.com/df-mc/dragonfly@v0.9.13/server/entity/effect/speed.go (about) 1 package effect 2 3 import ( 4 "github.com/df-mc/dragonfly/server/world" 5 "image/color" 6 ) 7 8 // Speed is a lasting effect that increases the speed of an entity by 20% for each level that the effect has. 9 type Speed struct { 10 nopLasting 11 } 12 13 // Start ... 14 func (Speed) Start(e world.Entity, lvl int) { 15 speed := 1 + float64(lvl)*0.2 16 if l, ok := e.(living); ok { 17 l.SetSpeed(l.Speed() * speed) 18 } 19 } 20 21 // End ... 22 func (Speed) End(e world.Entity, lvl int) { 23 speed := 1 + float64(lvl)*0.2 24 if l, ok := e.(living); ok { 25 l.SetSpeed(l.Speed() / speed) 26 } 27 } 28 29 // RGBA ... 30 func (Speed) RGBA() color.RGBA { 31 return color.RGBA{R: 0x7c, G: 0xaf, B: 0xc6, A: 0xff} 32 }