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

     1  package block
     2  
     3  // OreType represents a variant of ore blocks.
     4  type OreType struct {
     5  	ore
     6  }
     7  
     8  // StoneOre returns the stone ore variant.
     9  func StoneOre() OreType {
    10  	return OreType{0}
    11  }
    12  
    13  // DeepslateOre returns the deepslate ore variant.
    14  func DeepslateOre() OreType {
    15  	return OreType{1}
    16  }
    17  
    18  // OreTypes returns a list of all ore types
    19  func OreTypes() []OreType {
    20  	return []OreType{StoneOre(), DeepslateOre()}
    21  }
    22  
    23  type ore uint8
    24  
    25  // Uint8 returns the ore as a uint8.
    26  func (o ore) Uint8() uint8 {
    27  	return uint8(o)
    28  }
    29  
    30  // Name ...
    31  func (o ore) Name() string {
    32  	switch o {
    33  	case 0:
    34  		return "Stone"
    35  	case 1:
    36  		return "Deepslate"
    37  	}
    38  	panic("unknown ore type")
    39  }
    40  
    41  // String ...
    42  func (o ore) String() string {
    43  	switch o {
    44  	case 0:
    45  		return "stone"
    46  	case 1:
    47  		return "deepslate"
    48  	}
    49  	panic("unknown ore type")
    50  }
    51  
    52  // Prefix ...
    53  func (o ore) Prefix() string {
    54  	switch o {
    55  	case 0:
    56  		return ""
    57  	case 1:
    58  		return "deepslate_"
    59  	}
    60  	panic("unknown ore type")
    61  }
    62  
    63  // Hardness ...
    64  func (o ore) Hardness() float64 {
    65  	switch o {
    66  	case 0:
    67  		return 3
    68  	case 1:
    69  		return 4.5
    70  	}
    71  	panic("unknown ore type")
    72  }