github.com/df-mc/dragonfly@v0.9.13/server/item/splash_potion.go (about) 1 package item 2 3 import ( 4 "github.com/df-mc/dragonfly/server/item/potion" 5 "github.com/df-mc/dragonfly/server/world" 6 "github.com/df-mc/dragonfly/server/world/sound" 7 ) 8 9 // SplashPotion is an item that grants effects when thrown. 10 type SplashPotion struct { 11 // Type is the type of splash potion. 12 Type potion.Potion 13 } 14 15 // MaxCount ... 16 func (s SplashPotion) MaxCount() int { 17 return 1 18 } 19 20 // Use ... 21 func (s SplashPotion) Use(w *world.World, user User, ctx *UseContext) bool { 22 create := w.EntityRegistry().Config().SplashPotion 23 w.AddEntity(create(eyePosition(user), user.Rotation().Vec3().Mul(0.5), s.Type, user)) 24 w.PlaySound(user.Position(), sound.ItemThrow{}) 25 26 ctx.SubtractFromCount(1) 27 return true 28 } 29 30 // EncodeItem ... 31 func (s SplashPotion) EncodeItem() (name string, meta int16) { 32 return "minecraft:splash_potion", int16(s.Type.Uint8()) 33 }