add generator tag

This commit is contained in:
Tnze
2022-11-23 01:25:50 +08:00
parent d250284642
commit 43c7b485c4
5 changed files with 17 additions and 4 deletions

View File

@ -16,6 +16,7 @@ type Block interface {
// This file stores all possible block states into a TAG_List with gzip compressed. // This file stores all possible block states into a TAG_List with gzip compressed.
// //
//go:generate go run ./generator/blocks/main.go
//go:embed block_states.nbt //go:embed block_states.nbt
var blockStates []byte var blockStates []byte

View File

@ -74,6 +74,7 @@ func genSourceFile(states []State) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
log.Print("Generated blocks.go")
} }
var typeMaps = map[string]string{ var typeMaps = map[string]string{

View File

@ -82,6 +82,7 @@ func main() {
if err != nil { if err != nil {
log.Panic(err) log.Panic(err)
} }
log.Print("Generated properties_enum.go")
} }
func UpperTheFirst(word string) string { func UpperTheFirst(word string) string {

View File

@ -2,6 +2,8 @@ package block
import "strconv" import "strconv"
//go:generate go run ./generator/properties/main.go
type Boolean bool type Boolean bool
func (b Boolean) MarshalText() (text []byte, err error) { func (b Boolean) MarshalText() (text []byte, err error) {

View File

@ -62,15 +62,23 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
return return
} }
var hasPubKey pk.Boolean var (
var pubKey auth.PublicKey hasPubKey pk.Boolean
pubKey auth.PublicKey
hasUUID pk.Boolean
profileUUID pk.UUID // ignored
)
err = p.Scan( err = p.Scan(
(*pk.String)(&name), (*pk.String)(&name), //decode username as pk.String
&hasPubKey, pk.Opt{ &hasPubKey, pk.Opt{
Has: &hasPubKey, Has: &hasPubKey,
Field: &pubKey, Field: &pubKey,
}, },
) //decode username as pk.String &hasUUID, pk.Opt{
Has: &hasUUID,
Field: &profileUUID,
},
)
if err != nil { if err != nil {
return return
} }