github.com/df-mc/dragonfly@v0.9.13/server/item/honeycomb.go (about)

     1  package item
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/block/cube"
     5  	"github.com/df-mc/dragonfly/server/world"
     6  	"github.com/go-gl/mathgl/mgl64"
     7  )
     8  
     9  // Honeycomb is an item obtained from bee nests and beehives.
    10  type Honeycomb struct{}
    11  
    12  // UseOnBlock handles the logic of using an ink sac on a sign. Glowing ink sacs turn the text of these signs glowing,
    13  // whereas normal ink sacs revert them back to non-glowing text.
    14  func (Honeycomb) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, user User, ctx *UseContext) bool {
    15  	if wa, ok := w.Block(pos).(waxable); ok {
    16  		if res, ok := wa.Wax(pos, user.Position()); ok {
    17  			w.SetBlock(pos, res, nil)
    18  			ctx.SubtractFromCount(1)
    19  			return true
    20  		}
    21  	}
    22  	return false
    23  }
    24  
    25  // waxable represents a block that may be waxed.
    26  type waxable interface {
    27  	// Wax uses an ink sac on the block, returning the resulting block and a bool specifying if waxing the block was
    28  	// successful.
    29  	Wax(pos cube.Pos, userPos mgl64.Vec3) (world.Block, bool)
    30  }
    31  
    32  // EncodeItem ...
    33  func (Honeycomb) EncodeItem() (name string, meta int16) {
    34  	return "minecraft:honeycomb", 0
    35  }