-
Notifications
You must be signed in to change notification settings - Fork 97
/
event.go
56 lines (48 loc) · 1.36 KB
/
event.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
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
const (
EventAchievementAwarded = iota
EventEntityInteract
EventPortalBuilt
EventPortalUsed
EventMobKilled
EventCauldronUsed
EventPlayerDeath
EventBossKilled
EventAgentCommand
EventAgentCreated
EventBannerPatternRemoved
EventCommandExecuted
EventFishBucketed
)
// Event is sent by the server to send an event with additional data. It is typically sent to the client for
// telemetry reasons, much like the SimpleEvent packet.
type Event struct {
// EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and
// entities are generally identified in packets using this runtime ID.
EntityRuntimeID uint64
// EventType is the type of the event to be called. It is one of the constants that may be found above.
EventType int32
// UsePlayerID ... TODO: Figure out what this is for.
UsePlayerID byte
}
// ID ...
func (*Event) ID() uint32 {
return IDEvent
}
// Marshal ...
func (pk *Event) Marshal(w *protocol.Writer) {
w.Varuint64(&pk.EntityRuntimeID)
w.Varint32(&pk.EventType)
w.Uint8(&pk.UsePlayerID)
// TODO: Add fields for all Event types.
}
// Unmarshal ...
func (pk *Event) Unmarshal(r *protocol.Reader) {
r.Varuint64(&pk.EntityRuntimeID)
r.Varint32(&pk.EventType)
r.Uint8(&pk.UsePlayerID)
// TODO: Add fields for all Event types.
}