github.com/df-mc/dragonfly@v0.9.13/server/item/egg.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  // Egg is an item that can be used to craft food items, or as a throwable entity to spawn chicks.
     9  type Egg struct{}
    10  
    11  // MaxCount ...
    12  func (e Egg) MaxCount() int {
    13  	return 16
    14  }
    15  
    16  // Use ...
    17  func (e Egg) Use(w *world.World, user User, ctx *UseContext) bool {
    18  	create := w.EntityRegistry().Config().Egg
    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 (e Egg) EncodeItem() (name string, meta int16) {
    28  	return "minecraft:egg", 0
    29  }