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,30 @@
|
||||
package item
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"github.com/df-mc/dragonfly/server/world/sound"
|
||||
)
|
||||
|
||||
// Snowball is a throwable combat item obtained through shovelling snow.
|
||||
type Snowball struct{}
|
||||
|
||||
// MaxCount ...
|
||||
func (s Snowball) MaxCount() int {
|
||||
return 16
|
||||
}
|
||||
|
||||
// Use ...
|
||||
func (s Snowball) Use(tx *world.Tx, user User, ctx *UseContext) bool {
|
||||
create := tx.World().EntityRegistry().Config().Snowball
|
||||
opts := world.EntitySpawnOpts{Position: eyePosition(user), Velocity: user.Rotation().Vec3().Mul(1.5)}
|
||||
tx.AddEntity(create(opts, user))
|
||||
tx.PlaySound(user.Position(), sound.ItemThrow{})
|
||||
|
||||
ctx.SubtractFromCount(1)
|
||||
return true
|
||||
}
|
||||
|
||||
// EncodeItem ...
|
||||
func (s Snowball) EncodeItem() (name string, meta int16) {
|
||||
return "minecraft:snowball", 0
|
||||
}
|
||||
Reference in New Issue
Block a user