forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hay_bale.go
75 lines (62 loc) · 1.93 KB
/
hay_bale.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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"
)
// HayBale is a decorative, flammable block that can also be used to
// feed horses, breed llamas, reduce fall damage, and extend campfire smokes.
type HayBale struct {
solid
// Axis is the axis which the hay bale block faces.
Axis cube.Axis
}
// Instrument ...
func (HayBale) Instrument() sound.Instrument {
return sound.Banjo()
}
// EntityLand ...
func (h HayBale) EntityLand(_ cube.Pos, _ *world.World, e world.Entity, distance *float64) {
if _, ok := e.(fallDistanceEntity); ok {
*distance *= 0.2
}
}
// UseOnBlock ...
func (h HayBale) 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, h)
if !used {
return
}
h.Axis = face.Axis()
place(w, pos, h, user, ctx)
return placed(ctx)
}
// FlammabilityInfo ...
func (HayBale) FlammabilityInfo() FlammabilityInfo {
return newFlammabilityInfo(60, 20, false)
}
// BreakInfo ...
func (h HayBale) BreakInfo() BreakInfo {
return newBreakInfo(0.5, alwaysHarvestable, hoeEffective, oneOf(h))
}
// CompostChance ...
func (HayBale) CompostChance() float64 {
return 0.85
}
// EncodeItem ...
func (HayBale) EncodeItem() (name string, meta int16) {
return "minecraft:hay_block", 0
}
// EncodeBlock ...
func (h HayBale) EncodeBlock() (name string, properties map[string]interface{}) {
return "minecraft:hay_block", map[string]interface{}{"pillar_axis": h.Axis.String(), "deprecated": int32(0)}
}
// allHayBales ...
func allHayBales() (haybale []world.Block) {
for _, a := range cube.Axes() {
haybale = append(haybale, HayBale{Axis: a})
}
return
}