Regenerate files, moves packet id from data package

This commit is contained in:
Tnze
2021-02-18 21:29:16 +08:00
parent b4fc573118
commit ea0e0d1cae
19 changed files with 181 additions and 1379 deletions

20
offline/uuid.go Normal file
View File

@ -0,0 +1,20 @@
package offline
import (
"crypto/md5"
"github.com/google/uuid"
)
// NameToUUID return the UUID from player name in offline mode
func NameToUUID(name string) uuid.UUID {
var version = 3
h := md5.New()
h.Reset()
h.Write([]byte("OfflinePlayer:" + name))
s := h.Sum(nil)
var id uuid.UUID
copy(id[:], s)
id[6] = (id[6] & 0x0f) | uint8((version&0xf)<<4)
id[8] = (id[8] & 0x3f) | 0x80 // RFC 4122 variant
return id
}