github.com/df-mc/dragonfly@v0.9.13/server/block/bone.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 "github.com/df-mc/dragonfly/server/world/sound" 8 "github.com/go-gl/mathgl/mgl64" 9 ) 10 11 // Bone is a decorative block that can face different directions. 12 type Bone struct { 13 solid 14 15 // Axis is the axis which the bone block faces. 16 Axis cube.Axis 17 } 18 19 // Instrument ... 20 func (b Bone) Instrument() sound.Instrument { 21 return sound.Xylophone() 22 } 23 24 // UseOnBlock handles the rotational placing of bone blocks. 25 func (b Bone) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) { 26 pos, face, used = firstReplaceable(w, pos, face, b) 27 if !used { 28 return 29 } 30 b.Axis = face.Axis() 31 32 place(w, pos, b, user, ctx) 33 return placed(ctx) 34 } 35 36 // BreakInfo ... 37 func (b Bone) BreakInfo() BreakInfo { 38 return newBreakInfo(2, pickaxeHarvestable, pickaxeEffective, oneOf(b)) 39 } 40 41 // EncodeItem ... 42 func (b Bone) EncodeItem() (name string, meta int16) { 43 return "minecraft:bone_block", 0 44 } 45 46 // EncodeBlock ... 47 func (b Bone) EncodeBlock() (name string, properties map[string]any) { 48 return "minecraft:bone_block", map[string]any{"pillar_axis": b.Axis.String(), "deprecated": int32(0)} 49 } 50 51 // allBoneBlock ... 52 func allBoneBlock() (boneBlocks []world.Block) { 53 for _, axis := range cube.Axes() { 54 boneBlocks = append(boneBlocks, Bone{Axis: axis}) 55 } 56 return 57 }