From f62e79c5be7e5869212a4b3d814c76355c685a15 Mon Sep 17 00:00:00 2001 From: layou233 Date: Sun, 1 Sep 2024 23:57:02 +0800 Subject: [PATCH] Add missing test cases from wiki.vg --- net/packet/types.go | 4 ++-- net/packet/types_test.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/net/packet/types.go b/net/packet/types.go index eed71e21..fb9e097d 100644 --- a/net/packet/types.go +++ b/net/packet/types.go @@ -273,8 +273,8 @@ func (v VarInt) WriteToBytes(buf []byte) int { return 2 } else if num&0xFFE00000 == 0 { buf[2] = byte(num >> 14) - endingBytes := uint16((num&0x7F|0x80)<<8 | ((num>>7)&0x7F | 0x80)) - binary.BigEndian.PutUint16(buf, endingBytes) + startingBytes := uint16((num&0x7F|0x80)<<8 | ((num>>7)&0x7F | 0x80)) + binary.BigEndian.PutUint16(buf, startingBytes) return 3 } else if num&0xF0000000 == 0 { result := (num&0x7F|0x80)<<24 | (((num>>7)&0x7F | 0x80) << 16) | diff --git a/net/packet/types_test.go b/net/packet/types_test.go index c27c0eda..cf369512 100644 --- a/net/packet/types_test.go +++ b/net/packet/types_test.go @@ -10,7 +10,7 @@ import ( pk "github.com/Tnze/go-mc/net/packet" ) -var VarInts = []pk.VarInt{0, 1, 2, 127, 128, 255, 2147483647, -1, -2147483648} +var VarInts = []pk.VarInt{0, 1, 2, 127, 128, 255, 25565, 2097151, 2147483647, -1, -2147483648} var PackedVarInts = [][]byte{ {0x00}, @@ -19,6 +19,8 @@ var PackedVarInts = [][]byte{ {0x7f}, {0x80, 0x01}, {0xff, 0x01}, + {0xdd, 0xc7, 0x01}, + {0xff, 0xff, 0x7f}, {0xff, 0xff, 0xff, 0xff, 0x07}, {0xff, 0xff, 0xff, 0xff, 0x0f}, {0x80, 0x80, 0x80, 0x80, 0x08},