/
actor_event.go
104 lines (97 loc) · 2.67 KB
/
actor_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
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
96
97
98
99
100
101
102
103
104
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
const (
ActorEventJump = iota + 1
ActorEventHurt
ActorEventDeath
ActorEventStartAttacking
ActorEventStopAttacking
ActorEventTamingFailed
ActorEventTamingSucceeded
ActorEventShakeWetness
ActorEventUseItem
ActorEventEatGrass
ActorEventFishhookBubble
ActorEventFishhookFishPosition
ActorEventFishhookHookTime
ActorEventFishhookTease
ActorEventSquidFleeing
ActorEventZombieConverting
ActorEventPlayAmbient
ActorEventSpawnAlive
ActorEventStartOfferFlower
ActorEventStopOfferFlower
ActorEventLoveHearts
ActorEventVillagerAngry
ActorEventVillagerHappy
ActorEventWitchHatMagic
ActorEventFireworksExplode
ActorEventInLoveHearts
ActorEventSilverfishMergeAnimation
ActorEventGuardianAttackSound
ActorEventDrinkPotion
ActorEventThrowPotion
ActorEventCartWithPrimeTNT
ActorEventPrimeCreeper
ActorEventAirSupply
ActorEventAddPlayerLevels
ActorEventGuardianMiningFatigue
ActorEventAgentSwingArm
ActorEventDragonStartDeathAnim
ActorEventGroundDust
ActorEventShake
)
const (
ActorEventFeed = iota + 57
_
_
ActorEventBabyEat
ActorEventInstantDeath
ActorEventNotifyTrade
ActorEventLeashDestroyed
ActorEventCaravanUpdated
ActorEventTalismanActivate
ActorEventUpdateStructureFeature
ActorEventPlayerSpawnedMob
ActorEventPuke
ActorEventUpdateStackSize
ActorEventStartSwimming
ActorEventBalloonPop
ActorEventTreasureHunt
ActorEventSummonAgent
ActorEventFinishedChargingCrossbow
ActorEventLandedOnGround
ActorEventActorGrowUp
ActorEventVibrationDetected
)
// ActorEvent is sent by the server when a particular event happens that has to do with an entity. Some of
// these events are entity-specific, for example a wolf shaking itself dry, but others are used for each
// entity, such as dying.
type ActorEvent struct {
// EntityRuntimeID is the runtime ID of the entity. 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 ID of the event to be called. It is one of the constants that can be found above.
EventType byte
// EventData is optional data associated with a particular event. The data has a different function for
// different events, however most events don't use this field at all.
EventData int32
}
// ID ...
func (*ActorEvent) ID() uint32 {
return IDActorEvent
}
// Marshal ...
func (pk *ActorEvent) Marshal(w *protocol.Writer) {
w.Varuint64(&pk.EntityRuntimeID)
w.Uint8(&pk.EventType)
w.Varint32(&pk.EventData)
}
// Unmarshal ...
func (pk *ActorEvent) Unmarshal(r *protocol.Reader) {
r.Varuint64(&pk.EntityRuntimeID)
r.Uint8(&pk.EventType)
r.Varint32(&pk.EventData)
}