github.com/df-mc/dragonfly@v0.9.13/server/item/snowball.go (about) 1 package item 2 3 import ( 4 "github.com/df-mc/dragonfly/server/world" 5 "github.com/df-mc/dragonfly/server/world/sound" 6 ) 7 8 // Snowball is a throwable combat item obtained through shovelling snow. 9 type Snowball struct{} 10 11 // MaxCount ... 12 func (s Snowball) MaxCount() int { 13 return 16 14 } 15 16 // Use ... 17 func (s Snowball) Use(w *world.World, user User, ctx *UseContext) bool { 18 create := w.EntityRegistry().Config().Snowball 19 w.AddEntity(create(eyePosition(user), user.Rotation().Vec3().Mul(1.5), user)) 20 w.PlaySound(user.Position(), sound.ItemThrow{}) 21 22 ctx.SubtractFromCount(1) 23 return true 24 } 25 26 // EncodeItem ... 27 func (s Snowball) EncodeItem() (name string, meta int16) { 28 return "minecraft:snowball", 0 29 }