forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gravel.go
40 lines (34 loc) · 1.07 KB
/
gravel.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
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"
"math/rand"
)
// Gravel is a block affected by gravity. It has a 10% chance of dropping flint instead of itself on break.
type Gravel struct {
gravityAffected
solid
snare
}
// NeighbourUpdateTick ...
func (g Gravel) NeighbourUpdateTick(pos, _ cube.Pos, w *world.World) {
g.fall(g, pos, w)
}
// BreakInfo ...
func (g Gravel) BreakInfo() BreakInfo {
return newBreakInfo(0.6, alwaysHarvestable, shovelEffective, func(t item.Tool, enchantments []item.Enchantment) []item.Stack {
if !hasSilkTouch(enchantments) && rand.Float64() < 0.1 {
return []item.Stack{item.NewStack(item.Flint{}, 1)}
}
return []item.Stack{item.NewStack(g, 1)}
})
}
// EncodeItem ...
func (Gravel) EncodeItem() (name string, meta int16) {
return "minecraft:gravel", 0
}
// EncodeBlock ...
func (Gravel) EncodeBlock() (string, map[string]any) {
return "minecraft:gravel", nil
}