/
map.go
66 lines (60 loc) · 2.11 KB
/
map.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
package protocol
import (
"image/color"
)
const (
MapObjectTypeEntity = iota
MapObjectTypeBlock
)
// MapTrackedObject is an object on a map that is 'tracked' by the client, such as an entity or a block. This
// object may move, which is handled client-side.
type MapTrackedObject struct {
// Type is the type of the tracked object. It is either MapObjectTypeEntity or MapObjectTypeBlock.
Type int32
// EntityUniqueID is the unique ID of the entity, if the tracked object was an entity. It needs not to be
// filled out if Type is not MapObjectTypeEntity.
EntityUniqueID int64
// BlockPosition is the position of the block, if the tracked object was a block. It needs not to be
// filled out if Type is not MapObjectTypeBlock.
BlockPosition BlockPos
}
// MapDecoration is a fixed decoration on a map: Its position or other properties do not change automatically
// client-side.
type MapDecoration struct {
// Type is the type of the map decoration. The type specifies the shape (and sometimes the colour) that
// the map decoration gets.
Type byte
// Rotation is the rotation of the map decoration. It is byte due to the 16 fixed directions that the
// map decoration may face.
Rotation byte
// X is the offset on the X axis in pixels of the decoration.
X byte
// Y is the offset on the Y axis in pixels of the decoration.
Y byte
// Label is the name of the map decoration. This name may be of any value.
Label string
// Colour is the colour of the map decoration. Some map decoration types have a specific colour set
// automatically, whereas others may be changed.
Colour color.RGBA
}
// MapTrackedObj reads/writes a MapTrackedObject x using IO r.
func MapTrackedObj(r IO, x *MapTrackedObject) {
r.Int32(&x.Type)
switch x.Type {
case MapObjectTypeEntity:
r.Varint64(&x.EntityUniqueID)
case MapObjectTypeBlock:
r.UBlockPos(&x.BlockPosition)
default:
r.UnknownEnumOption(x.Type, "map tracked object type")
}
}
// MapDeco reads/writes a MapDecoration x using IO r.
func MapDeco(r IO, x *MapDecoration) {
r.Uint8(&x.Type)
r.Uint8(&x.Rotation)
r.Uint8(&x.X)
r.Uint8(&x.Y)
r.String(&x.Label)
r.VarRGBA(&x.Colour)
}