github.com/df-mc/dragonfly@v0.9.13/server/block/planks.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  	"time"
     7  )
     8  
     9  // Planks are common blocks used in crafting recipes. They are made by crafting logs into planks.
    10  type Planks struct {
    11  	solid
    12  	bass
    13  
    14  	// Wood is the type of wood of the planks. This field must have one of the values found in the material
    15  	// package.
    16  	Wood WoodType
    17  }
    18  
    19  // FlammabilityInfo ...
    20  func (p Planks) FlammabilityInfo() FlammabilityInfo {
    21  	if !p.Wood.Flammable() {
    22  		return newFlammabilityInfo(0, 0, false)
    23  	}
    24  	return newFlammabilityInfo(5, 20, true)
    25  }
    26  
    27  // BreakInfo ...
    28  func (p Planks) BreakInfo() BreakInfo {
    29  	return newBreakInfo(2, alwaysHarvestable, axeEffective, oneOf(p)).withBlastResistance(15)
    30  }
    31  
    32  // RepairsWoodTools ...
    33  func (p Planks) RepairsWoodTools() bool {
    34  	return true
    35  }
    36  
    37  // FuelInfo ...
    38  func (Planks) FuelInfo() item.FuelInfo {
    39  	return newFuelInfo(time.Second * 15)
    40  }
    41  
    42  // EncodeItem ...
    43  func (p Planks) EncodeItem() (name string, meta int16) {
    44  	return "minecraft:" + p.Wood.String() + "_planks", 0
    45  }
    46  
    47  // EncodeBlock ...
    48  func (p Planks) EncodeBlock() (name string, properties map[string]any) {
    49  	return "minecraft:" + p.Wood.String() + "_planks", nil
    50  }
    51  
    52  // allPlanks returns all planks types.
    53  func allPlanks() (planks []world.Block) {
    54  	for _, w := range WoodTypes() {
    55  		planks = append(planks, Planks{Wood: w})
    56  	}
    57  	return
    58  }