Add VarLong encoder/decoder and integrate into generation pipeline

This commit is contained in:
adman
2025-12-24 12:35:14 +01:00
parent dd41115ca2
commit db091d17df
7 changed files with 52 additions and 21 deletions
-18
View File
@@ -6,11 +6,7 @@ import (
"testing"
"github.com/admin-else/strom/nbt"
"github.com/admin-else/strom/proto_base"
"github.com/admin-else/strom/proto_generated/v1_21_8"
"github.com/google/uuid"
"github.com/google/go-cmp/cmp"
)
@@ -22,20 +18,6 @@ var nanIgnorer64 = cmp.Comparer(func(x, y float64) bool {
return (math.IsNaN(x) && math.IsNaN(y)) || x == y
})
func TestChat(t *testing.T) {
//p := v1_21_8.PlayToServerPacketChatMessage{Message: "dfs", Timestamp: 1764153707364, Salt: -5634100397920314628, Signature: (*[256]uint8)(nil), Offset: 0, Acknowledged: [3]uint8{0x0, 0x0, 0x0}, Checksum: 0x1}
p := v1_21_8.PlayToClientPacketPlayerChat{GlobalIndex: 0, SenderUuid: uuid.UUID{0x1d, 0xc5, 0x57, 0x82, 0x3c, 0x0, 0x3e, 0xd4, 0xbf, 0x8b, 0x76, 0xd4, 0xc6, 0xd9, 0xcc, 0x47}, Index: 0, Signature: (*[256]uint8)(nil), PlainMessage: "csdf", Timestamp: 1764153823132, Salt: 0, PreviousMessages: v1_21_8.PreviousMessages{Val: []struct {
Id int32
Signature interface{}
}{}}, UnsignedChatContent: (*nbt.Anon)(nil), FilterType: 0, FilterTypeMask: proto_base.Void{}, Type: v1_21_8.PlayToClientChatTypesHolder{Val: 1}, NetworkName: nbt.Anon{Value: map[string]interface{}{"click_event": map[string]interface{}{"action": "suggest_command", "command": "/tell Player659 "}, "hover_event": map[string]interface{}{"action": "show_entity", "id": "minecraft:player", "name": "Player659", "uuid": []int32{499472258, 1006649044, -1081379116, -958804921}}, "insertion": "Player659", "text": "Player659"}}, NetworkTargetName: (*nbt.Anon)(nil)}
b := bytes.NewBuffer(nil)
err := p.Encode(b)
if err != nil {
t.Fatal(err)
}
t.Logf("%q", b.Bytes())
}
func FuzzPlayPackets(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
t.Logf("Fuzz data %q\n", b)