Rework soundIDs and packetIDs generator code to not be platform specific
This commit is contained in:
@ -150,47 +150,54 @@ func main() {
|
||||
|
||||
maxLen := pIDs.MaxLen()
|
||||
|
||||
fmt.Println("package data")
|
||||
fmt.Println()
|
||||
fmt.Println("//go:generate bash -c \"go run gen_packetIDs.go > packetIDs.go\"")
|
||||
fmt.Println()
|
||||
fmt.Println("// This file is automatically generated by gen_packetIDs.go. DO NOT EDIT.")
|
||||
fmt.Println()
|
||||
fmt.Println("// PktID represents a packet ID used in the minecraft protocol.")
|
||||
fmt.Println("type PktID int32")
|
||||
fmt.Println()
|
||||
fmt.Println("// Valid PktID values.")
|
||||
fmt.Println("const (")
|
||||
f, err := os.Create("packetIDs.go")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
fmt.Println(" // Clientbound packets for connections in the login state.")
|
||||
fmt.Fprintln(f, "// This file is automatically generated by gen_packetIDs.go. DO NOT EDIT.")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "package data")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "//go:generate go run gen_packetIDs.go")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "// PktID represents a packet ID used in the minecraft protocol.")
|
||||
fmt.Fprintln(f, "type PktID int32")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "// Valid PktID values.")
|
||||
fmt.Fprintln(f, "const (")
|
||||
|
||||
fmt.Fprintln(f, " // Clientbound packets for connections in the login state.")
|
||||
for k, v := range pIDs.Login.Clientbound {
|
||||
fmt.Printf(" %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
fmt.Fprintf(f, " %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
}
|
||||
fmt.Println(" // Serverbound packets for connections in the login state.")
|
||||
fmt.Fprintln(f, " // Serverbound packets for connections in the login state.")
|
||||
for k, v := range pIDs.Login.Serverbound {
|
||||
fmt.Printf(" %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
fmt.Fprintf(f, " %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Fprintln(f)
|
||||
|
||||
fmt.Println(" // Clientbound packets for connections in the play state.")
|
||||
fmt.Fprintln(f, " // Clientbound packets for connections in the play state.")
|
||||
for k, v := range pIDs.Play.Clientbound {
|
||||
fmt.Printf(" %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
fmt.Fprintf(f, " %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
}
|
||||
fmt.Println(" // Serverbound packets for connections in the play state.")
|
||||
fmt.Fprintln(f, " // Serverbound packets for connections in the play state.")
|
||||
for k, v := range pIDs.Play.Serverbound {
|
||||
fmt.Printf(" %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
fmt.Fprintf(f, " %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Fprintln(f)
|
||||
|
||||
fmt.Println(" // Clientbound packets used to respond to ping/status requests.")
|
||||
fmt.Fprintln(f, " // Clientbound packets used to respond to ping/status requests.")
|
||||
for k, v := range pIDs.Status.Clientbound {
|
||||
fmt.Printf(" %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
fmt.Fprintf(f, " %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
}
|
||||
fmt.Println(" // Serverbound packets used to ping or read server status.")
|
||||
fmt.Fprintln(f, " // Serverbound packets used to ping or read server status.")
|
||||
for k, v := range pIDs.Status.Serverbound {
|
||||
fmt.Printf(" %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
fmt.Fprintf(f, " %s%s PktID = %s\n", k, strings.Repeat(" ", maxLen-len(k)), v)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Fprintln(f)
|
||||
|
||||
fmt.Println(")")
|
||||
fmt.Fprintln(f, ")")
|
||||
}
|
||||
|
Reference in New Issue
Block a user