-
Notifications
You must be signed in to change notification settings - Fork 140
/
dirt.go
49 lines (41 loc) · 1.07 KB
/
dirt.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
package block
import (
"github.com/df-mc/dragonfly/server/world"
)
// Dirt is a block found abundantly in most biomes under a layer of grass blocks at the top of the normal
// world.
type Dirt struct {
solid
// Coarse specifies if the dirt should be off the coarse dirt variant. Grass blocks won't spread on
// the block if set to true.
Coarse bool
}
// BreakInfo ...
func (d Dirt) BreakInfo() BreakInfo {
return newBreakInfo(0.5, alwaysHarvestable, shovelEffective, oneOf(d))
}
// Till ...
func (d Dirt) Till() (world.Block, bool) {
if d.Coarse {
return Dirt{Coarse: false}, true
}
return Farmland{}, true
}
// Shovel ...
func (d Dirt) Shovel() (world.Block, bool) {
return DirtPath{}, true
}
// EncodeItem ...
func (d Dirt) EncodeItem() (name string, meta int16) {
if d.Coarse {
meta = 1
}
return "minecraft:dirt", meta
}
// EncodeBlock ...
func (d Dirt) EncodeBlock() (string, map[string]interface{}) {
if d.Coarse {
return "minecraft:dirt", map[string]interface{}{"dirt_type": "coarse"}
}
return "minecraft:dirt", map[string]interface{}{"dirt_type": "normal"}
}