forked from Tnze/go-mc
/
playerdata.go
82 lines (67 loc) · 1.82 KB
/
playerdata.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
package save
import (
"io"
"github.com/SkyVillageMC/go-mc/nbt"
)
type PlayerData struct {
DataVersion int32
Dimension string
Pos [3]float64
Motion [3]float64
Rotation [2]float32
FallDistance float32
FallFlying byte
OnGround byte
UUID [4]int32
PlayerGameType int32 `nbt:"playerGameType"`
Air int16
DeathTime int16
Fire int16
HurtTime int16
Health float32
HurtByTimestamp int32
PortalCooldown int32
Invulnerable byte
SeenCredits byte `nbt:"seenCredits"`
SelectedItemSlot int32
Score int32
AbsorptionAmount float32
Inventory, EnderItems []Item
XpLevel int32
XpP float32
XpTotal int32
XpSeed int32
FoodExhaustionLevel float32 `nbt:"foodExhaustionLevel"`
FoodLevel int32 `nbt:"foodLevel"`
FoodSaturationLevel float32 `nbt:"foodSaturationLevel"`
FoodTickTimer int32 `nbt:"foodTickTimer"`
Attributes []struct {
Base float64
Name string
}
Abilities struct {
FlySpeed float32 `nbt:"flySpeed"`
WalkSpeed float32 `nbt:"walkSpeed"`
Flying byte `nbt:"flying"`
InstantBuild byte `nbt:"instabuild"`
Invulnerable byte `nbt:"invulnerable"`
MayBuild byte `nbt:"mayBuild"`
MayFly byte `nbt:"mayfly"`
} `nbt:"abilities"`
RecipeBook struct {
IsFilteringCraftable byte `nbt:"isFilteringCraftable"`
IsFurnaceFilteringCraftable byte `nbt:"isFurnaceFilteringCraftable"`
IsFurnaceGUIOpen byte `nbt:"isFurnaceGuiOpen"`
IsGUIOpen byte `nbt:"isGuiOpen"`
} `nbt:"recipeBook"`
}
type Item struct {
Count byte
Slot byte
ID string `nbt:"id"`
Tag map[string]interface{} `nbt:"tag"`
}
func ReadPlayerData(r io.Reader) (data PlayerData, err error) {
_, err = nbt.NewDecoder(r).Decode(&data)
return
}