github.com/df-mc/dragonfly@v0.9.13/server/block/crafting_table.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  	"time"
     8  )
     9  
    10  // CraftingTable is a utility block that allows the player to craft a variety of blocks and items.
    11  type CraftingTable struct {
    12  	bass
    13  	solid
    14  }
    15  
    16  // EncodeItem ...
    17  func (c CraftingTable) EncodeItem() (name string, meta int16) {
    18  	return "minecraft:crafting_table", 0
    19  }
    20  
    21  // EncodeBlock ...
    22  func (c CraftingTable) EncodeBlock() (name string, properties map[string]interface{}) {
    23  	return "minecraft:crafting_table", nil
    24  }
    25  
    26  // BreakInfo ...
    27  func (c CraftingTable) BreakInfo() BreakInfo {
    28  	return newBreakInfo(2.5, alwaysHarvestable, axeEffective, oneOf(c))
    29  }
    30  
    31  // FuelInfo ...
    32  func (CraftingTable) FuelInfo() item.FuelInfo {
    33  	return newFuelInfo(time.Second * 15)
    34  }
    35  
    36  // Activate ...
    37  func (c CraftingTable) Activate(pos cube.Pos, _ cube.Face, _ *world.World, u item.User, _ *item.UseContext) bool {
    38  	if opener, ok := u.(ContainerOpener); ok {
    39  		opener.OpenBlockContainer(pos)
    40  		return true
    41  	}
    42  	return false
    43  }