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