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

     1  package block
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/item"
     5  	"github.com/df-mc/dragonfly/server/world"
     6  )
     7  
     8  // StainedGlass is a decorative, fully transparent solid block that is dyed into a different colour.
     9  type StainedGlass struct {
    10  	transparent
    11  	solid
    12  	clicksAndSticks
    13  
    14  	// Colour specifies the colour of the block.
    15  	Colour item.Colour
    16  }
    17  
    18  // BreakInfo ...
    19  func (g StainedGlass) BreakInfo() BreakInfo {
    20  	return newBreakInfo(0.3, alwaysHarvestable, nothingEffective, silkTouchOnlyDrop(g))
    21  }
    22  
    23  // EncodeItem ...
    24  func (g StainedGlass) EncodeItem() (name string, meta int16) {
    25  	return "minecraft:" + g.Colour.String() + "_stained_glass", 0
    26  }
    27  
    28  // EncodeBlock ...
    29  func (g StainedGlass) EncodeBlock() (name string, properties map[string]any) {
    30  	return "minecraft:" + g.Colour.String() + "_stained_glass", nil
    31  }
    32  
    33  // allStainedGlass returns stained-glass blocks with all possible colours.
    34  func allStainedGlass() []world.Block {
    35  	b := make([]world.Block, 0, 16)
    36  	for _, c := range item.Colours() {
    37  		b = append(b, StainedGlass{Colour: c})
    38  	}
    39  	return b
    40  }