forked from Tnze/go-mc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entities.go
95 lines (80 loc) · 2.49 KB
/
entities.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package ptypes
import pk "github.com/Tnze/go-mc/net/packet"
// SpawnEntity is a clientbound packet used to spawn a non-mob entity.
type SpawnEntity struct {
ID pk.VarInt
UUID pk.UUID
Type pk.VarInt
X, Y, Z pk.Double
Pitch, Yaw pk.Angle
Data pk.Int
VelX, VelY, VelZ pk.Short
}
func (p *SpawnEntity) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.UUID, &p.Type,
&p.X, &p.Y, &p.Z, &p.Pitch, &p.Yaw,
&p.Data, &p.VelX, &p.VelY, &p.VelZ)
}
// SpawnPlayer is a clientbound packet used to describe a player entering
// visible range.
type SpawnPlayer struct {
ID pk.VarInt
UUID pk.UUID
X, Y, Z pk.Double
Yaw, Pitch pk.Angle
}
func (p *SpawnPlayer) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.UUID, &p.X, &p.Y, &p.Z, &p.Yaw, &p.Pitch)
}
// SpawnLivingEntity is a clientbound packet used to spawn a mob.
type SpawnLivingEntity struct {
ID pk.VarInt
UUID pk.UUID
Type pk.VarInt
X, Y, Z pk.Double
Yaw, Pitch pk.Angle
HeadPitch pk.Angle
VelX, VelY, VelZ pk.Short
}
func (p *SpawnLivingEntity) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.UUID, &p.Type,
&p.X, &p.Y, &p.Z, &p.Yaw, &p.Pitch,
&p.HeadPitch, &p.VelX, &p.VelY, &p.VelZ)
}
// EntityAnimationClientbound updates the animationf state of an entity.
type EntityAnimationClientbound struct {
ID pk.VarInt
Animation pk.UnsignedByte
}
func (p *EntityAnimationClientbound) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.Animation)
}
// EntityPosition is a clientbound packet used to update an entities position.
type EntityPosition struct {
ID pk.VarInt
X, Y, Z pk.Short // Deltas
OnGround pk.Boolean
}
func (p *EntityPosition) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.X, &p.Y, &p.Z, &p.OnGround)
}
// EntityPosition is a clientbound packet used to update an entities position
// and its rotation.
type EntityPositionLook struct {
ID pk.VarInt
X, Y, Z pk.Short // Deltas
Yaw, Pitch pk.Angle
OnGround pk.Boolean
}
func (p *EntityPositionLook) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.X, &p.Y, &p.Z, &p.Yaw, &p.Pitch, &p.OnGround)
}
// EntityRotation is a clientbound packet used to update an entities rotation.
type EntityRotation struct {
ID pk.VarInt
Yaw, Pitch pk.Angle
OnGround pk.Boolean
}
func (p *EntityRotation) Decode(pkt pk.Packet) error {
return pkt.Scan(&p.ID, &p.Yaw, &p.Pitch, &p.OnGround)
}