github.com/df-mc/dragonfly@v0.9.13/server/block/sandstone.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  // Sandstone is a solid block commonly found in deserts and beaches underneath sand.
     9  type Sandstone struct {
    10  	solid
    11  	bassDrum
    12  
    13  	// Type is the type of sandstone of the block.
    14  	Type SandstoneType
    15  
    16  	// Red specifies if the sandstone type is red or not. When set to true, the sandstone type will represent its
    17  	// red variant, for example red sandstone.
    18  	Red bool
    19  }
    20  
    21  // BreakInfo ...
    22  func (s Sandstone) BreakInfo() BreakInfo {
    23  	return newBreakInfo(0.8, pickaxeHarvestable, pickaxeEffective, oneOf(s))
    24  }
    25  
    26  // EncodeItem ...
    27  func (s Sandstone) EncodeItem() (name string, meta int16) {
    28  	if s.Red {
    29  		return "minecraft:red_sandstone", int16(s.Type.Uint8())
    30  	}
    31  	return "minecraft:sandstone", int16(s.Type.Uint8())
    32  }
    33  
    34  // EncodeBlock ...
    35  func (s Sandstone) EncodeBlock() (string, map[string]any) {
    36  	if s.Red {
    37  		return "minecraft:red_sandstone", map[string]any{"sand_stone_type": s.Type.String()}
    38  	}
    39  	return "minecraft:sandstone", map[string]any{"sand_stone_type": s.Type.String()}
    40  }
    41  
    42  // SmeltInfo ...
    43  func (s Sandstone) SmeltInfo() item.SmeltInfo {
    44  	if s.Type == NormalSandstone() {
    45  		return newSmeltInfo(item.NewStack(Sandstone{Red: s.Red, Type: SmoothSandstone()}, 1), 0.1)
    46  	}
    47  	return item.SmeltInfo{}
    48  }
    49  
    50  // allSandstones returns a list of all sandstone block variants.
    51  func allSandstones() (c []world.Block) {
    52  	f := func(red bool) {
    53  		for _, t := range SandstoneTypes() {
    54  			c = append(c, Sandstone{Type: t, Red: red})
    55  		}
    56  	}
    57  	f(true)
    58  	f(false)
    59  	return
    60  }