/
game_data.go
63 lines (61 loc) · 3.55 KB
/
game_data.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
package minecraft
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
// GameData is a loose wrapper around a part of the data found in the StartGame packet. It holds data sent
// specifically at the start of the game, such as the position of the player, the game mode, etc.
type GameData struct {
// WorldName is the name of the world that the player spawns in. This name will be displayed at the top of
// the player list when opening the in-game menu. It may contain colour codes and does not have to be an
// actual world name, but instead, can be the server name.
// If WorldName is left empty, the name of the Listener will be used to show above the player list
// in-game.
WorldName string
// EntityUniqueID is the unique ID of the player. The unique ID is unique for the entire world and is
// often used in packets. Most servers send an EntityUniqueID equal to the EntityRuntimeID.
EntityUniqueID int64
// EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and
// entities are generally identified in packets using this runtime ID.
EntityRuntimeID uint64
// PlayerGameMode is the game mode the player currently has. It is a value from 0-4, with 0 being
// survival mode, 1 being creative mode, 2 being adventure mode, 3 being survival spectator and 4 being
// creative spectator.
// This field may be set to 5 to make the client fall back to the game mode set in the WorldGameMode
// field.
PlayerGameMode int32
// PlayerPosition is the spawn position of the player in the world. In servers this is often the same as
// the world's spawn position found below.
PlayerPosition mgl32.Vec3
// Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is
// measured in degrees.
Pitch float32
// Yaw is the horizontal rotation of the player. Yaw is also measured in degrees.
Yaw float32
// Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2, with 0 being
// the overworld, 1 being the nether and 2 being the end.
Dimension int32
// WorldSpawn is the block on which the world spawn of the world. This coordinate has no effect on the
// place that the client spawns, but it does have an effect on the direction that a compass points.
WorldSpawn protocol.BlockPos
// WorldGameMode is the game mode that a player gets when it first spawns in the world. It is shown in the
// settings and is used if the PlayerGameMode is set to 5.
WorldGameMode int32
// GameRules defines game rules currently active with their respective values. The value of these game
// rules may be either 'bool', 'int32' or 'float32'. Some game rules are server side only, and don't
// necessarily need to be sent to the client.
GameRules map[string]interface{}
// Time is the total time that has elapsed since the start of the world.
Time int64
// Blocks is a list of all blocks and variants existing in the game. Failing to send any of the blocks
// that are in the game, including any specific variants of that block, will crash mobile clients. It
// seems Windows 10 games do not crash.
Blocks []interface{}
// Items is a list of all items existing in the game. Failing to send any of the default items that are in
// the game will crash mobile clients.
Items []protocol.ItemEntry
// ServerAuthoritativeMovement specifies if the client should use the 'server authoritative movement',
// meaning it will send PlayerAuthInput packets instead of MovePlayer packets, which the server should
// verify.
ServerAuthoritativeMovement bool
}