github.com/df-mc/dragonfly@v0.9.13/server/item/bottle_of_enchanting.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  // BottleOfEnchanting is a bottle that releases experience orbs when thrown.
     9  type BottleOfEnchanting struct{}
    10  
    11  // Use ...
    12  func (b BottleOfEnchanting) Use(w *world.World, user User, ctx *UseContext) bool {
    13  	create := w.EntityRegistry().Config().BottleOfEnchanting
    14  	w.AddEntity(create(eyePosition(user), user.Rotation().Vec3().Mul(0.7), user))
    15  	w.PlaySound(user.Position(), sound.ItemThrow{})
    16  
    17  	ctx.SubtractFromCount(1)
    18  	return true
    19  }
    20  
    21  // EncodeItem ...
    22  func (b BottleOfEnchanting) EncodeItem() (name string, meta int16) {
    23  	return "minecraft:experience_bottle", 0
    24  }