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

     1  package block
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/block/cube"
     5  	"github.com/df-mc/dragonfly/server/item"
     6  	"github.com/df-mc/dragonfly/server/world"
     7  	"github.com/go-gl/mathgl/mgl64"
     8  )
     9  
    10  // Froglight is a luminous natural block that can be obtained if a frog eats a tiny magma cube.
    11  type Froglight struct {
    12  	solid
    13  
    14  	// Type is the type of froglight.
    15  	Type FroglightType
    16  	// Axis is the axis which the froglight block faces.
    17  	Axis cube.Axis
    18  }
    19  
    20  // LightEmissionLevel ...
    21  func (f Froglight) LightEmissionLevel() uint8 {
    22  	return 15
    23  }
    24  
    25  // UseOnBlock ...
    26  func (f Froglight) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) {
    27  	pos, face, used = firstReplaceable(w, pos, face, f)
    28  	if !used {
    29  		return
    30  	}
    31  	f.Axis = face.Axis()
    32  
    33  	place(w, pos, f, user, ctx)
    34  	return placed(ctx)
    35  }
    36  
    37  // BreakInfo ...
    38  func (f Froglight) BreakInfo() BreakInfo {
    39  	return newBreakInfo(0.3, alwaysHarvestable, nothingEffective, oneOf(f))
    40  }
    41  
    42  // EncodeItem ...
    43  func (f Froglight) EncodeItem() (name string, meta int16) {
    44  	return "minecraft:" + f.Type.String() + "_froglight", 0
    45  }
    46  
    47  // EncodeBlock ...
    48  func (f Froglight) EncodeBlock() (name string, properties map[string]any) {
    49  	return "minecraft:" + f.Type.String() + "_froglight", map[string]any{"axis": f.Axis.String()}
    50  }
    51  
    52  // allFrogLight ...
    53  func allFroglight() (froglight []world.Block) {
    54  	for _, axis := range cube.Axes() {
    55  		for _, t := range FroglightTypes() {
    56  			froglight = append(froglight, Froglight{Type: t, Axis: axis})
    57  		}
    58  	}
    59  	return
    60  }