github.com/df-mc/dragonfly@v0.9.13/server/block/stained_glass_pane.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  )
     8  
     9  // StainedGlassPane is a transparent block that can be used as a more efficient alternative to glass blocks.
    10  type StainedGlassPane struct {
    11  	transparent
    12  	thin
    13  	clicksAndSticks
    14  	sourceWaterDisplacer
    15  
    16  	// Colour specifies the colour of the block.
    17  	Colour item.Colour
    18  }
    19  
    20  // SideClosed ...
    21  func (p StainedGlassPane) SideClosed(cube.Pos, cube.Pos, *world.World) bool {
    22  	return false
    23  }
    24  
    25  // BreakInfo ...
    26  func (p StainedGlassPane) BreakInfo() BreakInfo {
    27  	return newBreakInfo(0.3, alwaysHarvestable, nothingEffective, silkTouchOnlyDrop(p))
    28  }
    29  
    30  // EncodeItem ...
    31  func (p StainedGlassPane) EncodeItem() (name string, meta int16) {
    32  	return "minecraft:" + p.Colour.String() + "_stained_glass_pane", 0
    33  }
    34  
    35  // EncodeBlock ...
    36  func (p StainedGlassPane) EncodeBlock() (name string, properties map[string]any) {
    37  	return "minecraft:" + p.Colour.String() + "_stained_glass_pane", nil
    38  }
    39  
    40  // allStainedGlassPane returns stained-glass panes with all possible colours.
    41  func allStainedGlassPane() []world.Block {
    42  	b := make([]world.Block, 0, 16)
    43  	for _, c := range item.Colours() {
    44  		b = append(b, StainedGlassPane{Colour: c})
    45  	}
    46  	return b
    47  }