forked from Sandertv/gophertunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_pack.go
115 lines (107 loc) · 4.83 KB
/
resource_pack.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
105
106
107
108
109
110
111
112
113
114
115
package protocol
// BehaviourPackInfo represents a behaviour pack's info sent over network. It holds information about the
// behaviour pack such as its name, description and version.
type BehaviourPackInfo struct {
// UUID is the UUID of the behaviour pack. Each behaviour pack downloaded must have a different UUID in
// order for the client to be able to handle them properly.
UUID string
// Version is the version of the behaviour pack. The client will cache behaviour packs sent by the server as
// long as they carry the same version. Sending a behaviour pack with a different version than previously
// will force the client to re-download it.
Version string
// Size is the total size in bytes that the behaviour pack occupies. This is the size of the compressed
// archive (zip) of the behaviour pack.
Size uint64
// ContentKey is the key used to decrypt the behaviour pack if it is encrypted. This is generally the case
// for marketplace behaviour packs.
ContentKey string
// SubPackName ...
SubPackName string
// ContentIdentity ...
ContentIdentity string
// HasScripts specifies if the behaviour packs has any scripts in it. A client will only download the
// behaviour pack if it supports scripts, which, up to 1.11, only includes Windows 10.
HasScripts bool
}
// Marshal encodes/decodes a BehaviourPackInfo.
func (x *BehaviourPackInfo) Marshal(r IO) {
r.String(&x.UUID)
r.String(&x.Version)
r.Uint64(&x.Size)
r.String(&x.ContentKey)
r.String(&x.SubPackName)
r.String(&x.ContentIdentity)
r.Bool(&x.HasScripts)
}
// TexturePackInfo represents a texture pack's info sent over network. It holds information about the
// texture pack such as its name, description and version.
type TexturePackInfo struct {
// UUID is the UUID of the texture pack. Each texture pack downloaded must have a different UUID in
// order for the client to be able to handle them properly.
UUID string
// Version is the version of the texture pack. The client will cache texture packs sent by the server as
// long as they carry the same version. Sending a texture pack with a different version than previously
// will force the client to re-download it.
Version string
// Size is the total size in bytes that the texture pack occupies. This is the size of the compressed
// archive (zip) of the texture pack.
Size uint64
// ContentKey is the key used to decrypt the behaviour pack if it is encrypted. This is generally the case
// for marketplace texture packs.
ContentKey string
// SubPackName ...
SubPackName string
// ContentIdentity is another UUID for the resource pack, and is generally set for marketplace texture
// packs. It is also required for client-side validations when the resource pack is encrypted.
ContentIdentity string
// HasScripts specifies if the texture packs has any scripts in it. A client will only download the
// behaviour pack if it supports scripts, which, up to 1.11, only includes Windows 10.
HasScripts bool
// RTXEnabled specifies if the texture pack uses the raytracing technology introduced in 1.16.200.
RTXEnabled bool
}
// Marshal encodes/decodes a TexturePackInfo.
func (x *TexturePackInfo) Marshal(r IO) {
r.String(&x.UUID)
r.String(&x.Version)
r.Uint64(&x.Size)
r.String(&x.ContentKey)
r.String(&x.SubPackName)
r.String(&x.ContentIdentity)
r.Bool(&x.HasScripts)
r.Bool(&x.RTXEnabled)
}
// StackResourcePack represents a resource pack sent on the stack of the client. When sent, the client will
// apply them in the order of the stack sent.
type StackResourcePack struct {
// UUID is the UUID of the resource pack. Each resource pack downloaded must have a different UUID in
// order for the client to be able to handle them properly.
UUID string
// Version is the version of the resource pack. The client will cache resource packs sent by the server as
// long as they carry the same version. Sending a resource pack with a different version than previously
// will force the client to re-download it.
Version string
// SubPackName ...
SubPackName string
}
// Marshal encodes/decodes a StackResourcePack.
func (x *StackResourcePack) Marshal(r IO) {
r.String(&x.UUID)
r.String(&x.Version)
r.String(&x.SubPackName)
}
// PackURL represents a resource pack that is being served from a HTTP server rather than being sent over
// the Minecraft protocol.
type PackURL struct {
// UUIDVersion is a combination of the UUID and version of the resource pack in the format UUID_Version.
// The client will only attempt to download the resource pack if it does not already have it cached.
UUIDVersion string
// URL is the URL from which the resource pack is downloaded. This URL must serve a zip file containing
// a manifest.json file inside another folder. The manifest cannot be in the root of the zip file.
URL string
}
// Marshal encodes/decodes a CDNURL.
func (x *PackURL) Marshal(r IO) {
r.String(&x.UUIDVersion)
r.String(&x.URL)
}