-
Notifications
You must be signed in to change notification settings - Fork 2
/
mob_effect.go
executable file
·80 lines (74 loc) · 2.31 KB
/
mob_effect.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
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
gtpacket "github.com/sandertv/gophertunnel/minecraft/protocol/packet"
)
const (
MobEffectAdd = iota + 1
MobEffectModify
MobEffectRemove
)
const (
EffectSpeed = iota + 1
EffectSlowness
EffectHaste
EffectMiningFatigue
EffectStrength
EffectInstantHealth
EffectInstantDamage
EffectJumpBoost
EffectNausea
EffectRegeneration
EffectResistance
EffectFireResistance
EffectWaterBreathing
EffectInvisibility
EffectBlindness
EffectNightVision
EffectHunger
EffectWeakness
EffectPoison
EffectWither
EffectHealthBoost
EffectAbsorption
EffectSaturation
EffectLevitation
EffectFatalPoison
EffectConduitPower
EffectSlowFalling
)
// MobEffect is sent by the server to apply an effect to the player, for example an effect like poison. It may
// also be used to modify existing effects, or removing them completely.
type MobEffect 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
// Operation is the operation of the packet. It is either MobEffectAdd, MobEffectModify or MobEffectRemove
// and specifies the result of the packet client-side.
Operation byte
// EffectType is the ID of the effect to be added, removed or modified. It is one of the constants that
// may be found above.
EffectType int32
// Amplifier is the amplifier of the effect. Take note that the amplifier is not the same as the effect's
// level. The level is usually one higher than the amplifier, and the amplifier can actually be negative
// to reverse the behaviour effect.
Amplifier int32
// Particles specifies if viewers of the entity that gets the effect shows particles around it. If set to
// false, no particles are emitted around the entity.
Particles bool
// Duration is the duration of the effect in seconds. After the duration has elapsed, the effect will be
// removed automatically client-side.
Duration int32
}
// ID ...
func (*MobEffect) ID() uint32 {
return gtpacket.IDMobEffect
}
func (pk *MobEffect) Marshal(io protocol.IO) {
io.Varuint64(&pk.EntityRuntimeID)
io.Uint8(&pk.Operation)
io.Varint32(&pk.EffectType)
io.Varint32(&pk.Amplifier)
io.Bool(&pk.Particles)
io.Varint32(&pk.Duration)
}