/
animate_entity.go
65 lines (60 loc) · 2.19 KB
/
animate_entity.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
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
// AnimateEntity is sent by the server to animate an entity client-side. It may be used to play a single
// animation, or to activate a controller which can start a sequence of animations based on different
// conditions specified in an animation controller.
// Much of the documentation of this packet can be found at
// https://minecraft.gamepedia.com/Bedrock_Edition_beta_animation_documentation.
type AnimateEntity struct {
// Animation is the name of a single animation to start playing.
Animation string
// NextState is the first state to start with. These states are declared in animation controllers (which,
// in themselves, are animations too). These states in turn may have animations and transitions to move to
// a next state.
NextState string
// StopCondition is a MoLang expression that specifies when the animation should be stopped.
StopCondition string
// StopConditionVersion is the MoLang stop condition version.
StopConditionVersion int32
// Controller is the animation controller that is used to manage animations. These controllers decide when
// to play which animation.
Controller string
// BlendOutTime does not currently seem to be used.
BlendOutTime float32
// EntityRuntimeIDs is list of runtime IDs of entities that the animation should be applied to.
EntityRuntimeIDs []uint64
}
// ID ...
func (*AnimateEntity) ID() uint32 {
return IDAnimateEntity
}
// Marshal ...
func (pk *AnimateEntity) Marshal(w *protocol.Writer) {
w.String(&pk.Animation)
w.String(&pk.NextState)
w.String(&pk.StopCondition)
w.Int32(&pk.StopConditionVersion)
w.String(&pk.Controller)
w.Float32(&pk.BlendOutTime)
l := uint32(len(pk.EntityRuntimeIDs))
w.Varuint32(&l)
for i := range pk.EntityRuntimeIDs {
w.Varuint64(&pk.EntityRuntimeIDs[i])
}
}
// Unmarshal ...
func (pk *AnimateEntity) Unmarshal(r *protocol.Reader) {
r.String(&pk.Animation)
r.String(&pk.NextState)
r.String(&pk.StopCondition)
r.Int32(&pk.StopConditionVersion)
r.String(&pk.Controller)
var count uint32
r.Varuint32(&count)
pk.EntityRuntimeIDs = make([]uint64, count)
for i := uint32(0); i < count; i++ {
r.Varuint64(&pk.EntityRuntimeIDs[i])
}
}