-
Notifications
You must be signed in to change notification settings - Fork 97
/
photo_transfer.go
44 lines (39 loc) · 1.59 KB
/
photo_transfer.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
package packet
import (
"bytes"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
// PhotoTransfer is sent by the server to transfer a photo (image) file to the client. It is typically used
// to transfer photos so that the client can display it in a portfolio in Education Edition.
// While previously usable in the default Bedrock Edition, the displaying of photos in books was disabled and
// the packet now has little use anymore.
type PhotoTransfer struct {
// PhotoName is the name of the photo to transfer. It is the exact file name that the client will download
// the photo as, including the extension of the file.
PhotoName string
// PhotoData is the raw data of the photo image. The format of this data may vary: Formats such as JPEG or
// PNG work, as long as PhotoName has the correct extension.
PhotoData []byte
// BookID is the ID of the book that the photo is associated with. If the PhotoName in a book with this ID
// is set to PhotoName, it will display the photo (provided Education Edition is used).
// The photo image is downloaded to a sub-folder with this book ID.
BookID string
}
// ID ...
func (*PhotoTransfer) ID() uint32 {
return IDPhotoTransfer
}
// Marshal ...
func (pk *PhotoTransfer) Marshal(buf *bytes.Buffer) {
_ = protocol.WriteString(buf, pk.PhotoName)
_ = protocol.WriteByteSlice(buf, pk.PhotoData)
_ = protocol.WriteString(buf, pk.BookID)
}
// Unmarshal ...
func (pk *PhotoTransfer) Unmarshal(buf *bytes.Buffer) error {
return chainErr(
protocol.String(buf, &pk.PhotoName),
protocol.ByteSlice(buf, &pk.PhotoData),
protocol.String(buf, &pk.BookID),
)
}