github.com/df-mc/dragonfly@v0.9.13/server/block/wool.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 "github.com/df-mc/dragonfly/server/world/sound" 7 ) 8 9 // Wool is a colourful block that can be obtained by killing/shearing sheep, or crafted using four string. 10 type Wool struct { 11 solid 12 13 // Colour is the colour of the wool. 14 Colour item.Colour 15 } 16 17 // Instrument ... 18 func (w Wool) Instrument() sound.Instrument { 19 return sound.Guitar() 20 } 21 22 // FlammabilityInfo ... 23 func (w Wool) FlammabilityInfo() FlammabilityInfo { 24 return newFlammabilityInfo(30, 60, true) 25 } 26 27 // BreakInfo ... 28 func (w Wool) BreakInfo() BreakInfo { 29 return newBreakInfo(0.8, alwaysHarvestable, shearsEffective, oneOf(w)) 30 } 31 32 // EncodeItem ... 33 func (w Wool) EncodeItem() (name string, meta int16) { 34 return "minecraft:wool", int16(w.Colour.Uint8()) 35 } 36 37 // EncodeBlock ... 38 func (w Wool) EncodeBlock() (name string, properties map[string]any) { 39 return "minecraft:" + w.Colour.String() + "_wool", nil 40 } 41 42 // allWool returns wool blocks with all possible colours. 43 func allWool() []world.Block { 44 b := make([]world.Block, 0, 16) 45 for _, c := range item.Colours() { 46 b = append(b, Wool{Colour: c}) 47 } 48 return b 49 }