-
Notifications
You must be signed in to change notification settings - Fork 6
/
resource_pack_stack.go
81 lines (75 loc) · 3 KB
/
resource_pack_stack.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
package packet
import (
"dotcs/minecraft/protocol"
)
// ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs
// should be applied (and downloaded) by the client.
type ResourcePackStack struct {
// TexturePackRequired specifies if the client must accept the texture packs the server has in order to
// join the server. If set to true, the client gets the option to either download the resource packs and
// join, or quit entirely. Behaviour packs never have to be downloaded.
TexturePackRequired bool
// BehaviourPack is a list of behaviour packs that the client needs to download before joining the server.
// All of these behaviour packs will be applied together, and the order does not necessarily matter.
BehaviourPacks []protocol.StackResourcePack
// TexturePacks is a list of texture packs that the client needs to download before joining the server.
// The order of these texture packs specifies the order that they are applied in on the client side. The
// first in the list will be applied first.
TexturePacks []protocol.StackResourcePack
// BaseGameVersion is the vanilla version that the client should set its resource pack stack to.
BaseGameVersion string
// Experiments holds a list of experiments that are either enabled or disabled in the world that the
// player spawns in.
// It is not clear why experiments are sent both here and in the StartGame packet.
Experiments []protocol.ExperimentData
// ExperimentsPreviouslyToggled specifies if any experiments were previously toggled in this world. It is
// probably used for some kind of metrics.
ExperimentsPreviouslyToggled bool
}
// ID ...
func (*ResourcePackStack) ID() uint32 {
return IDResourcePackStack
}
// Marshal ...
func (pk *ResourcePackStack) Marshal(w *protocol.Writer) {
w.Bool(&pk.TexturePackRequired)
behaviourLen, textureLen := uint32(len(pk.BehaviourPacks)), uint32(len(pk.TexturePacks))
w.Varuint32(&behaviourLen)
for _, pack := range pk.BehaviourPacks {
protocol.StackPack(w, &pack)
}
w.Varuint32(&textureLen)
for _, pack := range pk.TexturePacks {
protocol.StackPack(w, &pack)
}
w.String(&pk.BaseGameVersion)
l := uint32(len(pk.Experiments))
w.Uint32(&l)
for _, experiment := range pk.Experiments {
protocol.Experiment(w, &experiment)
}
w.Bool(&pk.ExperimentsPreviouslyToggled)
}
// Unmarshal ...
func (pk *ResourcePackStack) Unmarshal(r *protocol.Reader) {
var length uint32
r.Bool(&pk.TexturePackRequired)
r.Varuint32(&length)
pk.BehaviourPacks = make([]protocol.StackResourcePack, length)
for i := uint32(0); i < length; i++ {
protocol.StackPack(r, &pk.BehaviourPacks[i])
}
r.Varuint32(&length)
pk.TexturePacks = make([]protocol.StackResourcePack, length)
for i := uint32(0); i < length; i++ {
protocol.StackPack(r, &pk.TexturePacks[i])
}
r.String(&pk.BaseGameVersion)
var l uint32
r.Uint32(&l)
pk.Experiments = make([]protocol.ExperimentData, l)
for i := uint32(0); i < l; i++ {
protocol.Experiment(r, &pk.Experiments[i])
}
r.Bool(&pk.ExperimentsPreviouslyToggled)
}