forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandstone.go
60 lines (51 loc) · 1.57 KB
/
sandstone.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
58
59
60
package block
import (
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/item"
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/world"
)
// Sandstone is a solid block commonly found in deserts and beaches underneath sand.
type Sandstone struct {
solid
bassDrum
// Type is the type of sandstone of the block.
Type SandstoneType
// Red specifies if the sandstone type is red or not. When set to true, the sandstone type will represent its
// red variant, for example red sandstone.
Red bool
}
// BreakInfo ...
func (s Sandstone) BreakInfo() BreakInfo {
return newBreakInfo(0.8, pickaxeHarvestable, pickaxeEffective, oneOf(s))
}
// EncodeItem ...
func (s Sandstone) EncodeItem() (name string, meta int16) {
if s.Red {
return "minecraft:red_sandstone", int16(s.Type.Uint8())
}
return "minecraft:sandstone", int16(s.Type.Uint8())
}
// EncodeBlock ...
func (s Sandstone) EncodeBlock() (string, map[string]any) {
if s.Red {
return "minecraft:red_sandstone", map[string]any{"sand_stone_type": s.Type.String()}
}
return "minecraft:sandstone", map[string]any{"sand_stone_type": s.Type.String()}
}
// SmeltInfo ...
func (s Sandstone) SmeltInfo() item.SmeltInfo {
if s.Type == NormalSandstone() {
return newSmeltInfo(item.NewStack(Sandstone{Red: s.Red, Type: SmoothSandstone()}, 1), 0.1)
}
return item.SmeltInfo{}
}
// allSandstones returns a list of all sandstone block variants.
func allSandstones() (c []world.Block) {
f := func(red bool) {
for _, t := range SandstoneTypes() {
c = append(c, Sandstone{Type: t, Red: red})
}
}
f(true)
f(false)
return
}