/
actor_event.go
102 lines (95 loc) · 2.62 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
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
const (
_ = iota
ActorEventJump
ActorEventHurt
ActorEventDeath
ActorEventStartAttack
ActorEventStopAttack
ActorEventTameFail
ActorEventTameSucceed
ActorEventShakeDry
ActorEventUseItem
ActorEventEatGrass
ActorEventFishHookBubble
ActorEventFishHookPosition
ActorEventFishHook
ActorEventFishHookTease
ActorEventSquidInkCloud
ActorEventZombieVillagerCure
ActorEventPlayAmbientSound
ActorEventRespawn
ActorEventIronGolemOfferFlower
ActorEventIronGolemWithdrawFlower
ActorEventLookingForPartner
ActorEventHappyVillager
ActorEventAngryVillager
ActorEventWitchSpell
ActorEventFirework
ActorEventFoundPartner
ActorEventSilverfishSpawn
ActorEventGuardianAttack
ActorEventWitchDrinkPotion
ActorEventWitchThrowPotion
ActorEventMinecartTNTPrimeFuse
ActorEventCreeperPrimeFuse
ActorEventAirSupplyExpired
ActorEventPlayerAddXPLevels
ActorEventElderGuardianCurse
ActorEventAgentArmSwing
ActorEventEnderDragonDeath
ActorEventDustParticles
ActorEventArrowShake
)
const (
ActorEventEatingItem = iota + 57
_
_
ActorEventBabyAnimalFeed
ActorEventDeathSmokeCloud
ActorEventCompleteTrade
ActorEventRemoveLeash
ActorEventLlamaCaravanUpdated
ActorEventConsumeTotem
ActorEventPlayerCheckTreasureHunterAchievement
ActorEventEntitySpawn
ActorEventDragonBreath
ActorEventItemEntityMerge
ActorEventStartSwimming
ActorEventBalloonPop
ActorEventTreasureHunt
ActorEventSummonAgent
ActorEventCrossbowCharged
)
// 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)
}