NBT parser can unmarshal TagCompound as map[string]interface{} now
This commit is contained in:
@ -13,7 +13,7 @@ There's some library in Go support you to create your Minecraft client or server
|
||||
- [x] Mojang authenticate
|
||||
- [x] Minecraft network protocol
|
||||
- [x] RCON protocol
|
||||
- [ ] World container / encoding
|
||||
- [ ] Saves decoding /encoding
|
||||
|
||||
bot:
|
||||
- [x] Swing arm
|
||||
|
@ -290,6 +290,7 @@ func (d *Decoder) unmarshal(val reflect.Value, tagType byte, tagName string) err
|
||||
}
|
||||
|
||||
case TagCompound:
|
||||
var buf map[string]interface{}
|
||||
switch vk := val.Kind(); vk {
|
||||
default:
|
||||
return errors.New("cannot parse TagCompound as " + vk.String())
|
||||
@ -315,8 +316,13 @@ func (d *Decoder) unmarshal(val reflect.Value, tagType byte, tagName string) err
|
||||
}
|
||||
}
|
||||
}
|
||||
case reflect.Map:
|
||||
if !reflect.TypeOf(buf).AssignableTo(val.Type()) {
|
||||
return errors.New("cannot parse TagCompound as " + vk.String())
|
||||
}
|
||||
fallthrough
|
||||
case reflect.Interface:
|
||||
buf := make(map[string]interface{})
|
||||
buf = make(map[string]interface{})
|
||||
for {
|
||||
tt, tn, err := d.readTag()
|
||||
if err != nil {
|
||||
|
@ -28,6 +28,7 @@ type PlayerData struct {
|
||||
HurtTime int16
|
||||
Health float32
|
||||
HurtByTimestamp int32
|
||||
PortalCooldown int32
|
||||
|
||||
Invulnerable byte
|
||||
SeenCredits byte `nbt:"seenCredits"`
|
||||
@ -35,6 +36,8 @@ type PlayerData struct {
|
||||
Score int32
|
||||
AbsorptionAmount float32
|
||||
|
||||
Inventory, EnderItems []Item
|
||||
|
||||
XpLevel int32
|
||||
XpP float32
|
||||
XpTotal int32
|
||||
@ -49,6 +52,7 @@ type PlayerData struct {
|
||||
Base float64
|
||||
Name string
|
||||
}
|
||||
|
||||
Abilities struct {
|
||||
FlySpeed float32 `nbt:"flySpeed"`
|
||||
WalkSpeed float32 `nbt:"warkSpeed"`
|
||||
@ -58,6 +62,20 @@ type PlayerData struct {
|
||||
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) {
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user