This commit is contained in:
adman
2026-03-02 00:14:57 +01:00
parent f7d7a72b7c
commit d8cc9cab48
32 changed files with 79606 additions and 20424 deletions
+4 -5
View File
@@ -15,6 +15,7 @@ type TypesInfo struct {
type PacketInfo struct {
TName, Name, Direction, State, PacketId, ProtocolVersion, MinecraftVersion string
PacketDef any
}
func GeneratePacketInfoFile(versions []string, packetInfos []PacketInfo) (err error) {
@@ -31,10 +32,8 @@ func GeneratePacketInfoFile(versions []string, packetInfos []PacketInfo) (err er
vUnderscore := "v" + strings.ReplaceAll(p.MinecraftVersion, ".", "_")
typeName := p.TName
var typeExpr ast.Expr
if typeName == "struct{}" {
typeExpr = &ast.StructType{Fields: &ast.FieldList{}}
} else if strings.HasPrefix(typeName, "proto_base.") {
typeExpr = Selector("proto_base", strings.TrimPrefix(typeName, "proto_base."))
if p.PacketDef == "void" {
typeExpr = Selector("proto_base", "Void")
} else {
typeExpr = Selector(vUnderscore, typeName)
}
@@ -46,7 +45,7 @@ func GeneratePacketInfoFile(versions []string, packetInfos []PacketInfo) (err er
KeyValueExpr(Ident("Type"), AddrOf(CompLit(typeExpr, nil))),
KeyValueExpr(Ident("Name"), StrLit(p.Name)),
KeyValueExpr(Ident("Direction"), Selector("proto_base", p.Direction)),
KeyValueExpr(Ident("state"), Selector("proto_base", p.State)),
KeyValueExpr(Ident("State"), Selector("proto_base", p.State)),
KeyValueExpr(Ident("PacketId"), NumLit(int(packetId))),
KeyValueExpr(Ident("ProtocolVersion"), NumLit(protocolVersion)),
}))