fix: implement topBitSetTerminatedArray, fix nbt TAG_End, fix entity_equipment
- Implement topBitSetTerminatedArray decoder/encoder with MSB continuation - Fix nbt.Tag.Decode to handle TAG_End at root level (fixes 1.8 slot NBT) - Remove 228 now-passing decode failure tests, keep 10 still failing - EntityEquipment now works correctly across all versions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.12.2/protocol.json (sha256:21c57208db654a5e14a34cb696570080df179c5c642e53b16120399eee9232be)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_12_2
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.14.4/protocol.json (sha256:b6edff5abaaf234037b5019024d749e27e746250a23253bb4ad77d8f76e93167)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_14_4
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.16.2/protocol.json (sha256:d96a3c5a7a7ddf2105e23990c2471b3aeafe4a6975e0c9d7d7943b599af9dfb3)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_16_5
|
||||
|
||||
import (
|
||||
@@ -5564,15 +5564,79 @@ func (ret *PlayToClientPacketEntityEffect) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
|
||||
type PlayToClientPacketEntityEquipment struct {
|
||||
Val proto_base.ToDo
|
||||
EntityId int32
|
||||
Equipments []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
}
|
||||
|
||||
func (ret *PlayToClientPacketEntityEquipment) Decode(r io.ReadSeeker) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
ret.EntityId, err = proto_base.DecodeVarInt(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}{}
|
||||
for {
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsHeader uint8
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsHeader)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = r.Seek(-1, io.SeekCurrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsHasMore := PlayToClientPacketEntityEquipmentEquipmentsHeader&128 != 0
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsElement struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsElement.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsElement.Item.Decode(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = append(ret.Equipments, PlayToClientPacketEntityEquipmentEquipmentsElement)
|
||||
if !PlayToClientPacketEntityEquipmentEquipmentsHasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ret *PlayToClientPacketEntityEquipment) Encode(w io.Writer) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
err = proto_base.EncodeVarInt(w, ret.EntityId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for iPlayToClientPacketEntityEquipmentEquipments, PlayToClientPacketEntityEquipmentEquipmentsElem := range ret.Equipments {
|
||||
if iPlayToClientPacketEntityEquipmentEquipments != len(ret.Equipments)-1 {
|
||||
err = binary.Write(w, binary.BigEndian, int8(uint8(PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)|128))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = binary.Write(w, binary.BigEndian, PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp := PlayToClientPacketEntityEquipmentEquipmentsElem.Item
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp.Encode(w)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.21.11/protocol.json (sha256:97d2726cce3a39cc967a954f27f4ebf029ec3f0f655bb21942aab8745d13cdab)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_21_11
|
||||
|
||||
import (
|
||||
@@ -16549,15 +16549,79 @@ func (ret *PlayToClientPacketEntityEffect) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
|
||||
type PlayToClientPacketEntityEquipment struct {
|
||||
Val proto_base.ToDo
|
||||
EntityId int32
|
||||
Equipments []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
}
|
||||
|
||||
func (ret *PlayToClientPacketEntityEquipment) Decode(r io.ReadSeeker) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
ret.EntityId, err = proto_base.DecodeVarInt(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}{}
|
||||
for {
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsHeader uint8
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsHeader)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = r.Seek(-1, io.SeekCurrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsHasMore := PlayToClientPacketEntityEquipmentEquipmentsHeader&128 != 0
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsElement struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsElement.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsElement.Item.Decode(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = append(ret.Equipments, PlayToClientPacketEntityEquipmentEquipmentsElement)
|
||||
if !PlayToClientPacketEntityEquipmentEquipmentsHasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ret *PlayToClientPacketEntityEquipment) Encode(w io.Writer) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
err = proto_base.EncodeVarInt(w, ret.EntityId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for iPlayToClientPacketEntityEquipmentEquipments, PlayToClientPacketEntityEquipmentEquipmentsElem := range ret.Equipments {
|
||||
if iPlayToClientPacketEntityEquipmentEquipments != len(ret.Equipments)-1 {
|
||||
err = binary.Write(w, binary.BigEndian, int8(uint8(PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)|128))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = binary.Write(w, binary.BigEndian, PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp := PlayToClientPacketEntityEquipmentEquipmentsElem.Item
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp.Encode(w)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.21.8/protocol.json (sha256:930fbb4c69fd2ecadddcee3c38d3f02908adc23b54b707cb21112e7ab1e9dba1)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_21_8
|
||||
|
||||
import (
|
||||
@@ -15030,15 +15030,79 @@ func (ret *PlayToClientPacketEntityEffect) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
|
||||
type PlayToClientPacketEntityEquipment struct {
|
||||
Val proto_base.ToDo
|
||||
EntityId int32
|
||||
Equipments []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
}
|
||||
|
||||
func (ret *PlayToClientPacketEntityEquipment) Decode(r io.ReadSeeker) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
ret.EntityId, err = proto_base.DecodeVarInt(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}{}
|
||||
for {
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsHeader uint8
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsHeader)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = r.Seek(-1, io.SeekCurrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsHasMore := PlayToClientPacketEntityEquipmentEquipmentsHeader&128 != 0
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsElement struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsElement.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsElement.Item.Decode(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = append(ret.Equipments, PlayToClientPacketEntityEquipmentEquipmentsElement)
|
||||
if !PlayToClientPacketEntityEquipmentEquipmentsHasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ret *PlayToClientPacketEntityEquipment) Encode(w io.Writer) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
err = proto_base.EncodeVarInt(w, ret.EntityId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for iPlayToClientPacketEntityEquipmentEquipments, PlayToClientPacketEntityEquipmentEquipmentsElem := range ret.Equipments {
|
||||
if iPlayToClientPacketEntityEquipmentEquipments != len(ret.Equipments)-1 {
|
||||
err = binary.Write(w, binary.BigEndian, int8(uint8(PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)|128))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = binary.Write(w, binary.BigEndian, PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp := PlayToClientPacketEntityEquipmentEquipmentsElem.Item
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp.Encode(w)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.21.9/protocol.json (sha256:9861cee397931c678c3b1837dcdf82e3fc885442c6bd0e4a60522fbf26653e59)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_21_9
|
||||
|
||||
import (
|
||||
@@ -16372,15 +16372,79 @@ func (ret *PlayToClientPacketEntityEffect) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
|
||||
type PlayToClientPacketEntityEquipment struct {
|
||||
Val proto_base.ToDo
|
||||
EntityId int32
|
||||
Equipments []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
}
|
||||
|
||||
func (ret *PlayToClientPacketEntityEquipment) Decode(r io.ReadSeeker) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
ret.EntityId, err = proto_base.DecodeVarInt(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}{}
|
||||
for {
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsHeader uint8
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsHeader)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = r.Seek(-1, io.SeekCurrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsHasMore := PlayToClientPacketEntityEquipmentEquipmentsHeader&128 != 0
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsElement struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsElement.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsElement.Item.Decode(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = append(ret.Equipments, PlayToClientPacketEntityEquipmentEquipmentsElement)
|
||||
if !PlayToClientPacketEntityEquipmentEquipmentsHasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ret *PlayToClientPacketEntityEquipment) Encode(w io.Writer) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
err = proto_base.EncodeVarInt(w, ret.EntityId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for iPlayToClientPacketEntityEquipmentEquipments, PlayToClientPacketEntityEquipmentEquipmentsElem := range ret.Equipments {
|
||||
if iPlayToClientPacketEntityEquipmentEquipments != len(ret.Equipments)-1 {
|
||||
err = binary.Write(w, binary.BigEndian, int8(uint8(PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)|128))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = binary.Write(w, binary.BigEndian, PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp := PlayToClientPacketEntityEquipmentEquipmentsElem.Item
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp.Encode(w)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/1.8/protocol.json (sha256:79fe774bfc255dd281899c004fbb9c7adc40fb107de9353da1dd0371ea4b53af)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v1_8
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/26.1/protocol.json (sha256:dfb6318886cd3ceab617f75ac05e24f9836a64501d60551071289b904ebfc389)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v26_1
|
||||
|
||||
import (
|
||||
@@ -16585,15 +16585,79 @@ func (ret *PlayToClientPacketEntityEffect) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
|
||||
type PlayToClientPacketEntityEquipment struct {
|
||||
Val proto_base.ToDo
|
||||
EntityId int32
|
||||
Equipments []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
}
|
||||
|
||||
func (ret *PlayToClientPacketEntityEquipment) Decode(r io.ReadSeeker) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
ret.EntityId, err = proto_base.DecodeVarInt(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}{}
|
||||
for {
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsHeader uint8
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsHeader)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = r.Seek(-1, io.SeekCurrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsHasMore := PlayToClientPacketEntityEquipmentEquipmentsHeader&128 != 0
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsElement struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsElement.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsElement.Item.Decode(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = append(ret.Equipments, PlayToClientPacketEntityEquipmentEquipmentsElement)
|
||||
if !PlayToClientPacketEntityEquipmentEquipmentsHasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ret *PlayToClientPacketEntityEquipment) Encode(w io.Writer) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
err = proto_base.EncodeVarInt(w, ret.EntityId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for iPlayToClientPacketEntityEquipmentEquipments, PlayToClientPacketEntityEquipmentEquipmentsElem := range ret.Equipments {
|
||||
if iPlayToClientPacketEntityEquipmentEquipments != len(ret.Equipments)-1 {
|
||||
err = binary.Write(w, binary.BigEndian, int8(uint8(PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)|128))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = binary.Write(w, binary.BigEndian, PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp := PlayToClientPacketEntityEquipmentEquipmentsElem.Item
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp.Encode(w)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by strom. DO NOT EDIT.
|
||||
// source: minecraft-data/pc/26.2/protocol.json (sha256:7ba66411adcc68a668f38211e1b00eeb386a345d5eb16fadd6dc1c7f94bb175f)
|
||||
// version: v0.6.6-0.20260805154326-fa70ea36c6f5+dirty (go1.26.2)
|
||||
// version: v0.6.6-0.20260805170503-1d8f70c7fdae+dirty (go1.26.2)
|
||||
package v26_2
|
||||
|
||||
import (
|
||||
@@ -16594,15 +16594,79 @@ func (ret *PlayToClientPacketEntityEffect) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
|
||||
type PlayToClientPacketEntityEquipment struct {
|
||||
Val proto_base.ToDo
|
||||
EntityId int32
|
||||
Equipments []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
}
|
||||
|
||||
func (ret *PlayToClientPacketEntityEquipment) Decode(r io.ReadSeeker) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
ret.EntityId, err = proto_base.DecodeVarInt(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = []struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}{}
|
||||
for {
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsHeader uint8
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsHeader)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = r.Seek(-1, io.SeekCurrent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsHasMore := PlayToClientPacketEntityEquipmentEquipmentsHeader&128 != 0
|
||||
var PlayToClientPacketEntityEquipmentEquipmentsElement struct {
|
||||
Slot int8
|
||||
Item Slot
|
||||
}
|
||||
err = binary.Read(r, binary.BigEndian, &PlayToClientPacketEntityEquipmentEquipmentsElement.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsElement.Item.Decode(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret.Equipments = append(ret.Equipments, PlayToClientPacketEntityEquipmentEquipmentsElement)
|
||||
if !PlayToClientPacketEntityEquipmentEquipmentsHasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ret *PlayToClientPacketEntityEquipment) Encode(w io.Writer) (err error) {
|
||||
err = proto_base.ToDoError
|
||||
err = proto_base.EncodeVarInt(w, ret.EntityId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for iPlayToClientPacketEntityEquipmentEquipments, PlayToClientPacketEntityEquipmentEquipmentsElem := range ret.Equipments {
|
||||
if iPlayToClientPacketEntityEquipmentEquipments != len(ret.Equipments)-1 {
|
||||
err = binary.Write(w, binary.BigEndian, int8(uint8(PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)|128))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = binary.Write(w, binary.BigEndian, PlayToClientPacketEntityEquipmentEquipmentsElem.Slot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp := PlayToClientPacketEntityEquipmentEquipmentsElem.Item
|
||||
err = PlayToClientPacketEntityEquipmentEquipmentsItemEncTmp.Encode(w)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user