diff --git a/cmd/template/main.go b/cmd/template/main.go new file mode 100644 index 0000000..bf3482e --- /dev/null +++ b/cmd/template/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "context" + "fmt" + + "git.konjactw.dev/patyhank/minego/pkg/auth" + "git.konjactw.dev/patyhank/minego/pkg/bot" + "git.konjactw.dev/patyhank/minego/pkg/client" + "git.konjactw.dev/patyhank/minego/pkg/game/player" +) + +func main() { + userCode := "powru" + c := client.NewClient(&bot.ClientOptions{AuthProvider: &auth.KonjacAuth{ + UserCode: userCode, + }}) + + ctx, cancelFunc := context.WithCancel(context.Background()) + defer cancelFunc() + + err := c.Connect(ctx, "mc.konjactw.dev", nil) + if err != nil { + panic(err) + } + + bot.SubscribeEvent(c, func(e player.MessageEvent) error { + fmt.Println(e.Message.String()) + return nil + }) + + err = c.HandleGame(ctx) + if err != nil { + panic(err) + } + +} diff --git a/login-sequence.txt b/login-sequence.txt deleted file mode 100644 index fb54139..0000000 --- a/login-sequence.txt +++ /dev/null @@ -1,45 +0,0 @@ -The recommended login sequence as of 1.21 looks like this, where C is the client and S is the server: - -Client connects to the server -C→S: Handshake State=2 -C→S: Login Start -S→C: Encryption Request (optional) -Client auth (Only if server sent Encryption Request) -C→S: Encryption Response (Only if server sent Encryption Request) -Server auth, both enable encryption (Only if server sent Encryption Request) -S → C: Set Compression (Optional, enables compression) -S → C: Login Success -C → S: Login Acknowledged -C → S: Serverbound Plugin Message (Optional, minecraft:brand with the client's brand) -C → S: Client Information (Optional) -S → C: Clientbound Plugin Message (Optional, minecraft:brand with the server's brand) -S → C: Feature Flags (Optional) -S → C: Clientbound Known Packs -C → S: Serverbound Known Packs -S → C: Registry Data (Multiple) -S → C: Update Tags (Optional) -S → C: Finish Configuration -C → S: Acknowledge Finish Configuration -S → C: Login (play) -S → C: Change Difficulty (Optional) -S → C: Player Abilities (Optional) -S → C: Set Held Item (Optional) -S → C: Update Recipes (Optional) -S → C: Entity Event (Optional, for the OP permission level; see Entity statuses#Player) -S → C: Commands (Optional) -S → C: Update Recipe Book (Optional) -S → C: Synchronize Player Position -C → S: Confirm Teleportation -C → S: Set Player Position and Rotation (Optional, to confirm the spawn position) -S → C: Server Data (Optional) -S → C: Player Info Update (Add Player action, all players except the one joining (the vanilla server separates these, you don't need to)) -S → C: Player Info Update (Add Player action, joining player) -S → C: Initialize World Border (Optional) -S → C: Update Time (Optional) -S → C: Set Default Spawn Position (Optional, “home” spawn, not where the client will spawn on login) -S → C: Game Event (Start waiting for level chunks event, required for the client to spawn) -S → C: Set Ticking State (Optional) -S → C: Step Tick (Optional, the vanilla server sends this regardless of ticking state) -S → C: Set Center Chunk -S → C: Chunk Data and Update Light (One sent for each chunk in a circular area centered on the player's position) -S → C: inventory, entities, etc. \ No newline at end of file diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 0d02d98..043eacf 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -308,9 +308,32 @@ func (o *OfflineAuth) Authenticate(ctx context.Context, conn *net.Conn, content } type KonjacAuth struct { - *OnlineAuth UserCode string - Profile Profile +} + +func (k *KonjacAuth) Authenticate(ctx context.Context, conn *net.Conn, content client.LoginHello) error { + key, encodeStream, decodeStream := newSymmetricEncryption() + + err := k.LoginAuth(ctx, content, key) + if err != nil { + return errors.Join(ErrEncrypt, fmt.Errorf("login auth fail: %w", err)) + } + + // Response with Encryption Key + var pkt pk.Packet + pkt, err = genEncryptionKeyResponse(key, content.PublicKey, content.VerifyToken) + if err != nil { + return fmt.Errorf("gen encryption key response fail: %v", err) + } + + err = conn.WritePacket(pkt) + if err != nil { + return err + } + + // Set Connection Encryption + conn.SetCipher(encodeStream, decodeStream) + return nil } func (k *KonjacAuth) LoginAuth(ctx context.Context, content client.LoginHello, key []byte) error { @@ -322,7 +345,7 @@ func (k *KonjacAuth) LoginAuth(ctx context.Context, content client.LoginHello, k ServerID string `json:"serverId"` }{ AccessToken: k.UserCode, - SelectedProfile: "", + SelectedProfile: "-", ServerID: digest, }) @@ -372,10 +395,19 @@ func (k *KonjacAuth) FetchProfile(ctx context.Context) *Profile { return nil } defer resp.Body.Close() - _, _ = io.ReadAll(resp.Body) - if resp.StatusCode != http.StatusNoContent { + data, err = io.ReadAll(resp.Body) + if resp.StatusCode >= 300 { return nil } - return nil + var profile struct { + SelectedProfile Profile `json:"selectedProfile"` + } + + err = json.Unmarshal(data, &profile) + if err != nil { + return nil + } + + return &profile.SelectedProfile } diff --git a/pkg/bot/client.go b/pkg/bot/client.go index 41cd367..dfcb7cc 100644 --- a/pkg/bot/client.go +++ b/pkg/bot/client.go @@ -9,6 +9,7 @@ import ( type Client interface { Connect(ctx context.Context, addr string, options *ConnectOptions) error + HandleGame(ctx context.Context) error Close(ctx context.Context) error IsConnected() bool WritePacket(ctx context.Context, packet server.ServerboundPacket) error diff --git a/pkg/bot/event.go b/pkg/bot/event.go index 3b23d45..ee62ef5 100644 --- a/pkg/bot/event.go +++ b/pkg/bot/event.go @@ -13,8 +13,9 @@ func PublishEvent(client Client, event Event) error { return client.EventHandler().PublishEvent(event.EventID(), event) } -func SubscribeEvent(client Client, event string, handler func(event Event) error) { - client.EventHandler().SubscribeEvent(event, func(data any) error { - return handler(data.(Event)) +func SubscribeEvent[T Event](client Client, handler func(event T) error) { + var t T + client.EventHandler().SubscribeEvent(t.EventID(), func(data any) error { + return handler(data.(T)) }) } diff --git a/pkg/client/client.go b/pkg/client/client.go index dd4bc47..1a0e0d5 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -94,7 +94,7 @@ func (b *botClient) Connect(ctx context.Context, addr string, options *bot.Conne // 建立連接 dialer := &mcnet.DefaultDialer - conn, err := dialer.DialMCContext(ctx, addr) + b.conn, err = dialer.DialMCContext(ctx, addr) if err != nil { return err } @@ -104,7 +104,7 @@ func (b *botClient) Connect(ctx context.Context, addr string, options *bot.Conne host = options.FakeHost } - err = b.handshake(conn, host, port) + err = b.handshake(host, port) if err != nil { return err } @@ -119,17 +119,18 @@ func (b *botClient) Connect(ctx context.Context, addr string, options *bot.Conne return err } - b.conn = conn b.connected = true // 啟動封包處理 goroutine - go b.handlePackets(ctx) - return nil } -func (b *botClient) handshake(conn *mcnet.Conn, host string, port uint64) error { - return conn.WritePacket(pk.Marshal( +func (b *botClient) HandleGame(ctx context.Context) error { + return b.handlePackets(ctx) +} + +func (b *botClient) handshake(host string, port uint64) error { + return b.conn.WritePacket(pk.Marshal( 0, pk.VarInt(772), pk.String(host), @@ -138,21 +139,28 @@ func (b *botClient) handshake(conn *mcnet.Conn, host string, port uint64) error )) } -func (b *botClient) handlePackets(ctx context.Context) { +func (b *botClient) handlePackets(ctx context.Context) error { group, ctx := errgroup.WithContext(ctx) group.SetLimit(15) for { select { case <-ctx.Done(): - return + return ctx.Err() default: var p pk.Packet if err := b.conn.ReadPacket(&p); err != nil { - return + return err } - - creator, ok := client.ClientboundPackets[packetid.ClientboundPacketID(p.ID)] + pktID := packetid.ClientboundPacketID(p.ID) + if pktID == packetid.ClientboundStartConfiguration { + err := b.configuration() + if err != nil { + return err + } + continue + } + creator, ok := client.ClientboundPackets[pktID] if !ok { continue } @@ -172,6 +180,7 @@ func (b *botClient) handlePackets(ctx context.Context) { func NewClient(options *bot.ClientOptions) bot.Client { c := &botClient{ packetHandler: newPacketHandler(), + eventHandler: NewEventHandler(), authProvider: options.AuthProvider, } @@ -180,7 +189,6 @@ func NewClient(options *bot.ClientOptions) bot.Client { } c.world = world.NewWorld(c) - c.eventHandler = NewEventHandler() c.inventory = inventory.NewManager(c) c.player = player.New(c) diff --git a/pkg/game/player/player.go b/pkg/game/player/player.go index 6e04c66..f2ddf31 100644 --- a/pkg/game/player/player.go +++ b/pkg/game/player/player.go @@ -35,6 +35,14 @@ func New(c bot.Client) *Player { pl.lastReceivedPacketTime = time.Now() }) + bot.AddHandler(c, func(ctx context.Context, p *client.KeepAlive) { + c.WritePacket(ctx, &server.KeepAlive{ + ID: p.ID, + }) + }) + bot.AddHandler(c, func(ctx context.Context, p *client.Disconnect) { + fmt.Println(p.Reason.String()) + }) bot.AddHandler(c, func(ctx context.Context, p *client.SystemChatMessage) { if !p.Overlay { bot.PublishEvent(c, MessageEvent{Message: p.Content}) diff --git a/pkg/game/world/world.go b/pkg/game/world/world.go index 5a14d19..ac72f5c 100644 --- a/pkg/game/world/world.go +++ b/pkg/game/world/world.go @@ -22,8 +22,7 @@ import ( type World struct { c bot.Client - Columns map[level.ChunkPos]*level.Chunk - + columns map[level.ChunkPos]*level.Chunk entities map[int32]*Entity entityLock sync.Mutex @@ -32,30 +31,34 @@ type World struct { func NewWorld(c bot.Client) *World { w := &World{ - c: c, - Columns: make(map[level.ChunkPos]*level.Chunk), + c: c, + columns: make(map[level.ChunkPos]*level.Chunk), + entities: make(map[int32]*Entity), } bot.AddHandler(c, func(ctx context.Context, p *cp.LevelChunkWithLight) { w.chunkLock.Lock() defer w.chunkLock.Unlock() - w.Columns[p.Pos] = p.Data + w.columns[p.Pos] = p.Data }) bot.AddHandler(c, func(ctx context.Context, p *cp.ForgetLevelChunk) { w.chunkLock.Lock() defer w.chunkLock.Unlock() - delete(w.Columns, p.Pos) + delete(w.columns, p.Pos) }) bot.AddHandler(c, func(ctx context.Context, p *cp.Respawn) { w.chunkLock.Lock() defer w.chunkLock.Unlock() - w.Columns = make(map[level.ChunkPos]*level.Chunk) + w.columns = make(map[level.ChunkPos]*level.Chunk) }) bot.AddHandler(c, func(ctx context.Context, p *cp.AddEntity) { + w.entityLock.Lock() + defer w.entityLock.Unlock() + w.entities[p.ID] = &Entity{ id: p.ID, entityUUID: p.UUID, @@ -137,7 +140,7 @@ func (w *World) GetBlock(pos protocol.Position) (block.Block, error) { chunkZ := pos[2] >> 4 pos2d := level.ChunkPos{chunkX, chunkZ} - chunk, ok := w.Columns[pos2d] + chunk, ok := w.columns[pos2d] if !ok { return nil, errors.New("chunk not loaded") } @@ -161,7 +164,7 @@ func (w *World) SetBlock(pos protocol.Position, blk block.Block) error { chunkZ := pos[2] >> 4 pos2d := level.ChunkPos{chunkX, chunkZ} - chunk, ok := w.Columns[pos2d] + chunk, ok := w.columns[pos2d] if !ok { return errors.New("chunk not loaded") } diff --git a/pkg/protocol/component/codecs.go b/pkg/protocol/component/codecs.go index d328ab1..4272e95 100644 --- a/pkg/protocol/component/codecs.go +++ b/pkg/protocol/component/codecs.go @@ -3602,10 +3602,10 @@ func (c WrittenBookPage) WriteTo(w io.Writer) (n int64, err error) { return n, err } -// Float32VarIntArray a utility type for encoding/decoding packet.Float -> float32[packet.VarInt] slice. -type Float32VarIntArray []float32 +// Int32VarIntArray a utility type for encoding/decoding packet.Int -> int32[packet.VarInt] slice. +type Int32VarIntArray []int32 -func (a Float32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { +func (a Int32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { size := len(a) nn, err := packet.VarInt(size).WriteTo(w) if err != nil { @@ -3613,7 +3613,7 @@ func (a Float32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { } n += nn for i := 0; i < size; i++ { - nn, err := packet.Float(a[i]).WriteTo(w) + nn, err := packet.Int(a[i]).WriteTo(w) n += nn if err != nil { return n, err @@ -3622,7 +3622,7 @@ func (a Float32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { return n, nil } -func (a *Float32VarIntArray) ReadFrom(r io.Reader) (n int64, err error) { +func (a *Int32VarIntArray) ReadFrom(r io.Reader) (n int64, err error) { var size packet.VarInt nn, err := size.ReadFrom(r) n += nn @@ -3636,11 +3636,59 @@ func (a *Float32VarIntArray) ReadFrom(r io.Reader) (n int64, err error) { if cap(*a) >= int(size) { *a = (*a)[:int(size)] } else { - *a = make(Float32VarIntArray, int(size)) + *a = make(Int32VarIntArray, int(size)) } for i := 0; i < int(size); i++ { - nn, err = (*packet.Float)(&(*a)[i]).ReadFrom(r) + nn, err = (*packet.Int)(&(*a)[i]).ReadFrom(r) + n += nn + if err != nil { + return n, err + } + } + + return n, err +} + +// Int32PrefixedArrayVarIntArray a utility type for encoding/decoding packet.Int -> int32[packet.VarInt] slice. +type Int32PrefixedArrayVarIntArray []int32 + +func (a Int32PrefixedArrayVarIntArray) WriteTo(w io.Writer) (n int64, err error) { + size := len(a) + nn, err := packet.VarInt(size).WriteTo(w) + if err != nil { + return n, err + } + n += nn + for i := 0; i < size; i++ { + nn, err := packet.Int(a[i]).WriteTo(w) + n += nn + if err != nil { + return n, err + } + } + return n, nil +} + +func (a *Int32PrefixedArrayVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { + var size packet.VarInt + nn, err := size.ReadFrom(r) + n += nn + if err != nil { + return n, err + } + if size < 0 { + return n, errors.New("array length less than zero") + } + + if cap(*a) >= int(size) { + *a = (*a)[:int(size)] + } else { + *a = make(Int32PrefixedArrayVarIntArray, int(size)) + } + + for i := 0; i < int(size); i++ { + nn, err = (*packet.Int)(&(*a)[i]).ReadFrom(r) n += nn if err != nil { return n, err @@ -3794,10 +3842,10 @@ func (a *Int32VarIntVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { return n, err } -// Int32VarIntArray a utility type for encoding/decoding packet.Int -> int32[packet.VarInt] slice. -type Int32VarIntArray []int32 +// Float32VarIntArray a utility type for encoding/decoding packet.Float -> float32[packet.VarInt] slice. +type Float32VarIntArray []float32 -func (a Int32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { +func (a Float32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { size := len(a) nn, err := packet.VarInt(size).WriteTo(w) if err != nil { @@ -3805,7 +3853,7 @@ func (a Int32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { } n += nn for i := 0; i < size; i++ { - nn, err := packet.Int(a[i]).WriteTo(w) + nn, err := packet.Float(a[i]).WriteTo(w) n += nn if err != nil { return n, err @@ -3814,7 +3862,7 @@ func (a Int32VarIntArray) WriteTo(w io.Writer) (n int64, err error) { return n, nil } -func (a *Int32VarIntArray) ReadFrom(r io.Reader) (n int64, err error) { +func (a *Float32VarIntArray) ReadFrom(r io.Reader) (n int64, err error) { var size packet.VarInt nn, err := size.ReadFrom(r) n += nn @@ -3828,59 +3876,11 @@ func (a *Int32VarIntArray) ReadFrom(r io.Reader) (n int64, err error) { if cap(*a) >= int(size) { *a = (*a)[:int(size)] } else { - *a = make(Int32VarIntArray, int(size)) + *a = make(Float32VarIntArray, int(size)) } for i := 0; i < int(size); i++ { - nn, err = (*packet.Int)(&(*a)[i]).ReadFrom(r) - n += nn - if err != nil { - return n, err - } - } - - return n, err -} - -// Int32PrefixedArrayVarIntArray a utility type for encoding/decoding packet.Int -> int32[packet.VarInt] slice. -type Int32PrefixedArrayVarIntArray []int32 - -func (a Int32PrefixedArrayVarIntArray) WriteTo(w io.Writer) (n int64, err error) { - size := len(a) - nn, err := packet.VarInt(size).WriteTo(w) - if err != nil { - return n, err - } - n += nn - for i := 0; i < size; i++ { - nn, err := packet.Int(a[i]).WriteTo(w) - n += nn - if err != nil { - return n, err - } - } - return n, nil -} - -func (a *Int32PrefixedArrayVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { - var size packet.VarInt - nn, err := size.ReadFrom(r) - n += nn - if err != nil { - return n, err - } - if size < 0 { - return n, errors.New("array length less than zero") - } - - if cap(*a) >= int(size) { - *a = (*a)[:int(size)] - } else { - *a = make(Int32PrefixedArrayVarIntArray, int(size)) - } - - for i := 0; i < int(size); i++ { - nn, err = (*packet.Int)(&(*a)[i]).ReadFrom(r) + nn, err = (*packet.Float)(&(*a)[i]).ReadFrom(r) n += nn if err != nil { return n, err diff --git a/pkg/protocol/metadata/metadata.go b/pkg/protocol/metadata/metadata.go index b0841ed..4ae04b6 100644 --- a/pkg/protocol/metadata/metadata.go +++ b/pkg/protocol/metadata/metadata.go @@ -84,6 +84,7 @@ func (m EntityMetadata) WriteTo(w io.Writer) (int64, error) { } func (m *EntityMetadata) ReadFrom(r io.Reader) (int64, error) { + m.Data = make(map[uint8]Metadata) var index uint8 n, err := (*pk.UnsignedByte)(&index).ReadFrom(r) if err != nil { diff --git a/pkg/protocol/packet/configuration/client/clear_dialog.go b/pkg/protocol/packet/configuration/client/clear_dialog.go index 5a307ec..ac2e33a 100644 --- a/pkg/protocol/packet/configuration/client/clear_dialog.go +++ b/pkg/protocol/packet/configuration/client/clear_dialog.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type ConfigClearDialog struct { } -func (ConfigClearDialog) PacketID() packetid.ClientboundPacketID { +func (*ConfigClearDialog) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigClearDialog } diff --git a/pkg/protocol/packet/configuration/client/cookie_request.go b/pkg/protocol/packet/configuration/client/cookie_request.go index 72e934a..cdcb315 100644 --- a/pkg/protocol/packet/configuration/client/cookie_request.go +++ b/pkg/protocol/packet/configuration/client/cookie_request.go @@ -7,7 +7,7 @@ type ConfigCookieRequest struct { Key string `mc:"Identifier"` } -func (ConfigCookieRequest) PacketID() packetid.ClientboundPacketID { +func (*ConfigCookieRequest) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigCookieRequest } diff --git a/pkg/protocol/packet/configuration/client/custom_payload.go b/pkg/protocol/packet/configuration/client/custom_payload.go index 8fd76ac..6e43b3f 100644 --- a/pkg/protocol/packet/configuration/client/custom_payload.go +++ b/pkg/protocol/packet/configuration/client/custom_payload.go @@ -8,7 +8,7 @@ type ConfigCustomPayload struct { Data []byte `mc:"ByteArray"` } -func (ConfigCustomPayload) PacketID() packetid.ClientboundPacketID { +func (*ConfigCustomPayload) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigCustomPayload } diff --git a/pkg/protocol/packet/configuration/client/custom_report_details.go b/pkg/protocol/packet/configuration/client/custom_report_details.go index 2f0ce53..83c5f73 100644 --- a/pkg/protocol/packet/configuration/client/custom_report_details.go +++ b/pkg/protocol/packet/configuration/client/custom_report_details.go @@ -9,7 +9,7 @@ type ConfigCustomReportDetails struct { client.CustomReportDetails } -func (ConfigCustomReportDetails) PacketID() packetid.ClientboundPacketID { +func (*ConfigCustomReportDetails) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigCustomReportDetails } diff --git a/pkg/protocol/packet/configuration/client/disconnect.go b/pkg/protocol/packet/configuration/client/disconnect.go index ba3417e..6f61e6a 100644 --- a/pkg/protocol/packet/configuration/client/disconnect.go +++ b/pkg/protocol/packet/configuration/client/disconnect.go @@ -10,7 +10,7 @@ type ConfigDisconnect struct { Reason chat.Message } -func (ConfigDisconnect) PacketID() packetid.ClientboundPacketID { +func (*ConfigDisconnect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigDisconnect } diff --git a/pkg/protocol/packet/configuration/client/finish_configuration.go b/pkg/protocol/packet/configuration/client/finish_configuration.go index 6526ca3..60e85df 100644 --- a/pkg/protocol/packet/configuration/client/finish_configuration.go +++ b/pkg/protocol/packet/configuration/client/finish_configuration.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type ConfigFinishConfiguration struct { } -func (ConfigFinishConfiguration) PacketID() packetid.ClientboundPacketID { +func (*ConfigFinishConfiguration) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigFinishConfiguration } diff --git a/pkg/protocol/packet/configuration/client/keep_alive.go b/pkg/protocol/packet/configuration/client/keep_alive.go index 7b9a482..be50f07 100644 --- a/pkg/protocol/packet/configuration/client/keep_alive.go +++ b/pkg/protocol/packet/configuration/client/keep_alive.go @@ -7,7 +7,7 @@ type ConfigKeepAlive struct { ID int64 } -func (ConfigKeepAlive) PacketID() packetid.ClientboundPacketID { +func (*ConfigKeepAlive) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigKeepAlive } diff --git a/pkg/protocol/packet/configuration/client/ping.go b/pkg/protocol/packet/configuration/client/ping.go index 608f1f5..65fdcca 100644 --- a/pkg/protocol/packet/configuration/client/ping.go +++ b/pkg/protocol/packet/configuration/client/ping.go @@ -7,7 +7,7 @@ type ConfigPing struct { ID int32 } -func (ConfigPing) PacketID() packetid.ClientboundPacketID { +func (*ConfigPing) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigPing } diff --git a/pkg/protocol/packet/configuration/client/registry_data.go b/pkg/protocol/packet/configuration/client/registry_data.go index 6fa2036..3bb3065 100644 --- a/pkg/protocol/packet/configuration/client/registry_data.go +++ b/pkg/protocol/packet/configuration/client/registry_data.go @@ -19,7 +19,7 @@ type ConfigRegistryData struct { Data []RegistryData } -func (ConfigRegistryData) PacketID() packetid.ClientboundPacketID { +func (*ConfigRegistryData) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigRegistryData } diff --git a/pkg/protocol/packet/configuration/client/reset_chat.go b/pkg/protocol/packet/configuration/client/reset_chat.go index 8d0bb49..a10851e 100644 --- a/pkg/protocol/packet/configuration/client/reset_chat.go +++ b/pkg/protocol/packet/configuration/client/reset_chat.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type ConfigResetChat struct { } -func (ConfigResetChat) PacketID() packetid.ClientboundPacketID { +func (*ConfigResetChat) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigResetChat } diff --git a/pkg/protocol/packet/configuration/client/resource_pack_pop.go b/pkg/protocol/packet/configuration/client/resource_pack_pop.go index 07538bd..72dd547 100644 --- a/pkg/protocol/packet/configuration/client/resource_pack_pop.go +++ b/pkg/protocol/packet/configuration/client/resource_pack_pop.go @@ -9,7 +9,7 @@ type ConfigResourcePackPop struct { client.RemoveResourcePack } -func (ConfigResourcePackPop) PacketID() packetid.ClientboundPacketID { +func (*ConfigResourcePackPop) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigResourcePackPop } diff --git a/pkg/protocol/packet/configuration/client/resource_pack_push.go b/pkg/protocol/packet/configuration/client/resource_pack_push.go index 031c926..002e95f 100644 --- a/pkg/protocol/packet/configuration/client/resource_pack_push.go +++ b/pkg/protocol/packet/configuration/client/resource_pack_push.go @@ -9,7 +9,7 @@ type ConfigResourcePackPush struct { client.AddResourcePack } -func (ConfigResourcePackPush) PacketID() packetid.ClientboundPacketID { +func (*ConfigResourcePackPush) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigResourcePackPush } diff --git a/pkg/protocol/packet/configuration/client/select_known_packs.go b/pkg/protocol/packet/configuration/client/select_known_packs.go index 85673a8..f4694d8 100644 --- a/pkg/protocol/packet/configuration/client/select_known_packs.go +++ b/pkg/protocol/packet/configuration/client/select_known_packs.go @@ -14,7 +14,7 @@ type ConfigSelectKnownPacks struct { KnownPacks []KnownPack } -func (ConfigSelectKnownPacks) PacketID() packetid.ClientboundPacketID { +func (*ConfigSelectKnownPacks) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigSelectKnownPacks } diff --git a/pkg/protocol/packet/configuration/client/server_links.go b/pkg/protocol/packet/configuration/client/server_links.go index 9d54428..89e651b 100644 --- a/pkg/protocol/packet/configuration/client/server_links.go +++ b/pkg/protocol/packet/configuration/client/server_links.go @@ -9,7 +9,7 @@ type ConfigServerLinks struct { client.ServerLinks } -func (ConfigServerLinks) PacketID() packetid.ClientboundPacketID { +func (*ConfigServerLinks) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigServerLinks } diff --git a/pkg/protocol/packet/configuration/client/show_dialog.go b/pkg/protocol/packet/configuration/client/show_dialog.go index e0c6330..3f952b9 100644 --- a/pkg/protocol/packet/configuration/client/show_dialog.go +++ b/pkg/protocol/packet/configuration/client/show_dialog.go @@ -9,7 +9,7 @@ type ConfigShowDialog struct { client.ShowDialog } -func (ConfigShowDialog) PacketID() packetid.ClientboundPacketID { +func (*ConfigShowDialog) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigShowDialog } diff --git a/pkg/protocol/packet/configuration/client/store_cookie.go b/pkg/protocol/packet/configuration/client/store_cookie.go index b5253d4..79393b9 100644 --- a/pkg/protocol/packet/configuration/client/store_cookie.go +++ b/pkg/protocol/packet/configuration/client/store_cookie.go @@ -8,7 +8,7 @@ type ConfigStoreCookie struct { Payload []int8 } -func (ConfigStoreCookie) PacketID() packetid.ClientboundPacketID { +func (*ConfigStoreCookie) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigStoreCookie } diff --git a/pkg/protocol/packet/configuration/client/transfer.go b/pkg/protocol/packet/configuration/client/transfer.go index 715aae1..78e6307 100644 --- a/pkg/protocol/packet/configuration/client/transfer.go +++ b/pkg/protocol/packet/configuration/client/transfer.go @@ -8,7 +8,7 @@ type ConfigTransfer struct { Port int32 `mc:"VarInt"` } -func (ConfigTransfer) PacketID() packetid.ClientboundPacketID { +func (*ConfigTransfer) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigTransfer } diff --git a/pkg/protocol/packet/configuration/client/update_enabled_features.go b/pkg/protocol/packet/configuration/client/update_enabled_features.go index 9dc1f9d..fa65d44 100644 --- a/pkg/protocol/packet/configuration/client/update_enabled_features.go +++ b/pkg/protocol/packet/configuration/client/update_enabled_features.go @@ -7,7 +7,7 @@ type ConfigUpdateEnabledFeatures struct { Features []string `mc:"Identifier"` } -func (ConfigUpdateEnabledFeatures) PacketID() packetid.ClientboundPacketID { +func (*ConfigUpdateEnabledFeatures) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigUpdateEnabledFeatures } diff --git a/pkg/protocol/packet/configuration/client/update_tags.go b/pkg/protocol/packet/configuration/client/update_tags.go index d7e4b2f..705624e 100644 --- a/pkg/protocol/packet/configuration/client/update_tags.go +++ b/pkg/protocol/packet/configuration/client/update_tags.go @@ -9,7 +9,7 @@ type ConfigUpdateTags struct { client.UpdateTags } -func (ConfigUpdateTags) PacketID() packetid.ClientboundPacketID { +func (*ConfigUpdateTags) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundConfigUpdateTags } diff --git a/pkg/protocol/packet/configuration/server/client_information.go b/pkg/protocol/packet/configuration/server/client_information.go index 7f982ba..911eba2 100644 --- a/pkg/protocol/packet/configuration/server/client_information.go +++ b/pkg/protocol/packet/configuration/server/client_information.go @@ -9,7 +9,7 @@ type ConfigClientInformation struct { server.ClientInformation } -func (ConfigClientInformation) PacketID() packetid.ServerboundPacketID { +func (*ConfigClientInformation) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigClientInformation } diff --git a/pkg/protocol/packet/configuration/server/cookie_response.go b/pkg/protocol/packet/configuration/server/cookie_response.go index 4659715..8fd6447 100644 --- a/pkg/protocol/packet/configuration/server/cookie_response.go +++ b/pkg/protocol/packet/configuration/server/cookie_response.go @@ -9,7 +9,7 @@ type ConfigCookieResponse struct { server.CookieResponse } -func (ConfigCookieResponse) PacketID() packetid.ServerboundPacketID { +func (*ConfigCookieResponse) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigCookieResponse } diff --git a/pkg/protocol/packet/configuration/server/custom_click_action.go b/pkg/protocol/packet/configuration/server/custom_click_action.go index 6348510..fdc51d4 100644 --- a/pkg/protocol/packet/configuration/server/custom_click_action.go +++ b/pkg/protocol/packet/configuration/server/custom_click_action.go @@ -11,7 +11,7 @@ type ConfigCustomClickAction struct { Data nbt.RawMessage `mc:"NBT"` } -func (ConfigCustomClickAction) PacketID() packetid.ServerboundPacketID { +func (*ConfigCustomClickAction) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigCustomClickAction } diff --git a/pkg/protocol/packet/configuration/server/custom_payload.go b/pkg/protocol/packet/configuration/server/custom_payload.go index 293073f..7dd6fee 100644 --- a/pkg/protocol/packet/configuration/server/custom_payload.go +++ b/pkg/protocol/packet/configuration/server/custom_payload.go @@ -9,7 +9,7 @@ type ConfigCustomPayload struct { server.CustomPayload } -func (ConfigCustomPayload) PacketID() packetid.ServerboundPacketID { +func (*ConfigCustomPayload) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigCustomPayload } diff --git a/pkg/protocol/packet/configuration/server/finish_configuration.go b/pkg/protocol/packet/configuration/server/finish_configuration.go index 7f0781c..a0763d5 100644 --- a/pkg/protocol/packet/configuration/server/finish_configuration.go +++ b/pkg/protocol/packet/configuration/server/finish_configuration.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type ConfigFinishConfiguration struct { } -func (ConfigFinishConfiguration) PacketID() packetid.ServerboundPacketID { +func (*ConfigFinishConfiguration) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigFinishConfiguration } diff --git a/pkg/protocol/packet/configuration/server/keep_alive.go b/pkg/protocol/packet/configuration/server/keep_alive.go index 9ffb0f0..c03be25 100644 --- a/pkg/protocol/packet/configuration/server/keep_alive.go +++ b/pkg/protocol/packet/configuration/server/keep_alive.go @@ -7,7 +7,7 @@ type ConfigKeepAlive struct { ID int64 } -func (ConfigKeepAlive) PacketID() packetid.ServerboundPacketID { +func (*ConfigKeepAlive) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigKeepAlive } diff --git a/pkg/protocol/packet/configuration/server/pong.go b/pkg/protocol/packet/configuration/server/pong.go index b7e9a3f..8af30b4 100644 --- a/pkg/protocol/packet/configuration/server/pong.go +++ b/pkg/protocol/packet/configuration/server/pong.go @@ -7,7 +7,7 @@ type ConfigPong struct { ID int32 } -func (ConfigPong) PacketID() packetid.ServerboundPacketID { +func (*ConfigPong) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigPong } diff --git a/pkg/protocol/packet/configuration/server/resource_pack.go b/pkg/protocol/packet/configuration/server/resource_pack.go index 61dc234..fb36c48 100644 --- a/pkg/protocol/packet/configuration/server/resource_pack.go +++ b/pkg/protocol/packet/configuration/server/resource_pack.go @@ -9,7 +9,7 @@ type ConfigResourcePack struct { server.ResourcePack } -func (ConfigResourcePack) PacketID() packetid.ServerboundPacketID { +func (*ConfigResourcePack) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigResourcePack } diff --git a/pkg/protocol/packet/configuration/server/select_known_packs.go b/pkg/protocol/packet/configuration/server/select_known_packs.go index 4e9a344..97761fe 100644 --- a/pkg/protocol/packet/configuration/server/select_known_packs.go +++ b/pkg/protocol/packet/configuration/server/select_known_packs.go @@ -10,7 +10,7 @@ type ConfigSelectKnownPacks struct { Packs []client.KnownPack } -func (ConfigSelectKnownPacks) PacketID() packetid.ServerboundPacketID { +func (*ConfigSelectKnownPacks) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigSelectKnownPacks } diff --git a/pkg/protocol/packet/game/client/codecs.go b/pkg/protocol/packet/game/client/codecs.go index 45881cb..a077b25 100644 --- a/pkg/protocol/packet/game/client/codecs.go +++ b/pkg/protocol/packet/game/client/codecs.go @@ -818,33 +818,11 @@ func (c CommandSuggestions) WriteTo(w io.Writer) (n int64, err error) { return n, err } func (c *Commands) ReadFrom(r io.Reader) (n int64, err error) { - var temp int64 - temp, err = packet.Array(&c.Nodes).ReadFrom(r) - n += temp - if err != nil { - return n, err - } - temp, err = (*packet.VarInt)(&c.RootIndex).ReadFrom(r) - n += temp - if err != nil { - return n, err - } - return n, err + return 0, nil } func (c Commands) WriteTo(w io.Writer) (n int64, err error) { - var temp int64 - temp, err = packet.Array(&c.Nodes).WriteTo(w) - n += temp - if err != nil { - return n, err - } - temp, err = (*packet.VarInt)(&c.RootIndex).WriteTo(w) - n += temp - if err != nil { - return n, err - } - return n, err + return 0, nil } func (c *SetContainerContent) ReadFrom(r io.Reader) (n int64, err error) { var temp int64 @@ -1557,7 +1535,6 @@ func (c Explode) WriteTo(w io.Writer) (n int64, err error) { } return n, err } - func (c *ForgetLevelChunk) ReadFrom(r io.Reader) (n int64, err error) { var temp int64 temp, err = (&c.Pos).ReadFrom(r) @@ -7090,150 +7067,6 @@ func (c Waypoint) WriteTo(w io.Writer) (n int64, err error) { return n, err } -// StringVarIntArray a utility type for encoding/decoding packet.String -> string[packet.VarInt] slice. -type StringVarIntArray []string - -func (a StringVarIntArray) WriteTo(w io.Writer) (n int64, err error) { - size := len(a) - nn, err := packet.VarInt(size).WriteTo(w) - if err != nil { - return n, err - } - n += nn - for i := 0; i < size; i++ { - nn, err := packet.String(a[i]).WriteTo(w) - n += nn - if err != nil { - return n, err - } - } - return n, nil -} - -func (a *StringVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { - var size packet.VarInt - nn, err := size.ReadFrom(r) - n += nn - if err != nil { - return n, err - } - if size < 0 { - return n, errors.New("array length less than zero") - } - - if cap(*a) >= int(size) { - *a = (*a)[:int(size)] - } else { - *a = make(StringVarIntArray, int(size)) - } - - for i := 0; i < int(size); i++ { - nn, err = (*packet.String)(&(*a)[i]).ReadFrom(r) - n += nn - if err != nil { - return n, err - } - } - - return n, err -} - -// UuidUUIDUUIDVarIntArray a utility type for encoding/decoding packet.UUID -> uuid.UUID[packet.VarInt] slice. -type UuidUUIDUUIDVarIntArray []uuid.UUID - -func (a UuidUUIDUUIDVarIntArray) WriteTo(w io.Writer) (n int64, err error) { - size := len(a) - nn, err := packet.VarInt(size).WriteTo(w) - if err != nil { - return n, err - } - n += nn - for i := 0; i < size; i++ { - nn, err := packet.UUID(a[i]).WriteTo(w) - n += nn - if err != nil { - return n, err - } - } - return n, nil -} - -func (a *UuidUUIDUUIDVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { - var size packet.VarInt - nn, err := size.ReadFrom(r) - n += nn - if err != nil { - return n, err - } - if size < 0 { - return n, errors.New("array length less than zero") - } - - if cap(*a) >= int(size) { - *a = (*a)[:int(size)] - } else { - *a = make(UuidUUIDUUIDVarIntArray, int(size)) - } - - for i := 0; i < int(size); i++ { - nn, err = (*packet.UUID)(&(*a)[i]).ReadFrom(r) - n += nn - if err != nil { - return n, err - } - } - - return n, err -} - -// Int32VarIntVarIntArray a utility type for encoding/decoding packet.VarInt -> int32[packet.VarInt] slice. -type Int32VarIntVarIntArray []int32 - -func (a Int32VarIntVarIntArray) WriteTo(w io.Writer) (n int64, err error) { - size := len(a) - nn, err := packet.VarInt(size).WriteTo(w) - if err != nil { - return n, err - } - n += nn - for i := 0; i < size; i++ { - nn, err := packet.VarInt(a[i]).WriteTo(w) - n += nn - if err != nil { - return n, err - } - } - return n, nil -} - -func (a *Int32VarIntVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { - var size packet.VarInt - nn, err := size.ReadFrom(r) - n += nn - if err != nil { - return n, err - } - if size < 0 { - return n, errors.New("array length less than zero") - } - - if cap(*a) >= int(size) { - *a = (*a)[:int(size)] - } else { - *a = make(Int32VarIntVarIntArray, int(size)) - } - - for i := 0; i < int(size); i++ { - nn, err = (*packet.VarInt)(&(*a)[i]).ReadFrom(r) - n += nn - if err != nil { - return n, err - } - } - - return n, err -} - // Int64VarLongVarIntArray a utility type for encoding/decoding packet.VarLong -> int64[packet.VarInt] slice. type Int64VarLongVarIntArray []int64 @@ -7282,6 +7115,54 @@ func (a *Int64VarLongVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { return n, err } +// Int8ByteVarIntArray a utility type for encoding/decoding packet.Byte -> int8[packet.VarInt] slice. +type Int8ByteVarIntArray []int8 + +func (a Int8ByteVarIntArray) WriteTo(w io.Writer) (n int64, err error) { + size := len(a) + nn, err := packet.VarInt(size).WriteTo(w) + if err != nil { + return n, err + } + n += nn + for i := 0; i < size; i++ { + nn, err := packet.Byte(a[i]).WriteTo(w) + n += nn + if err != nil { + return n, err + } + } + return n, nil +} + +func (a *Int8ByteVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { + var size packet.VarInt + nn, err := size.ReadFrom(r) + n += nn + if err != nil { + return n, err + } + if size < 0 { + return n, errors.New("array length less than zero") + } + + if cap(*a) >= int(size) { + *a = (*a)[:int(size)] + } else { + *a = make(Int8ByteVarIntArray, int(size)) + } + + for i := 0; i < int(size); i++ { + nn, err = (*packet.Byte)(&(*a)[i]).ReadFrom(r) + n += nn + if err != nil { + return n, err + } + } + + return n, err +} + // Int8VarIntArray a utility type for encoding/decoding packet.Byte -> int8[packet.VarInt] slice. type Int8VarIntArray []int8 @@ -7426,10 +7307,10 @@ func (a *StringIdentifierVarIntArray) ReadFrom(r io.Reader) (n int64, err error) return n, err } -// Int8ByteVarIntArray a utility type for encoding/decoding packet.Byte -> int8[packet.VarInt] slice. -type Int8ByteVarIntArray []int8 +// UuidUUIDUUIDVarIntArray a utility type for encoding/decoding packet.UUID -> uuid.UUID[packet.VarInt] slice. +type UuidUUIDUUIDVarIntArray []uuid.UUID -func (a Int8ByteVarIntArray) WriteTo(w io.Writer) (n int64, err error) { +func (a UuidUUIDUUIDVarIntArray) WriteTo(w io.Writer) (n int64, err error) { size := len(a) nn, err := packet.VarInt(size).WriteTo(w) if err != nil { @@ -7437,7 +7318,7 @@ func (a Int8ByteVarIntArray) WriteTo(w io.Writer) (n int64, err error) { } n += nn for i := 0; i < size; i++ { - nn, err := packet.Byte(a[i]).WriteTo(w) + nn, err := packet.UUID(a[i]).WriteTo(w) n += nn if err != nil { return n, err @@ -7446,7 +7327,7 @@ func (a Int8ByteVarIntArray) WriteTo(w io.Writer) (n int64, err error) { return n, nil } -func (a *Int8ByteVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { +func (a *UuidUUIDUUIDVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { var size packet.VarInt nn, err := size.ReadFrom(r) n += nn @@ -7460,11 +7341,59 @@ func (a *Int8ByteVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { if cap(*a) >= int(size) { *a = (*a)[:int(size)] } else { - *a = make(Int8ByteVarIntArray, int(size)) + *a = make(UuidUUIDUUIDVarIntArray, int(size)) } for i := 0; i < int(size); i++ { - nn, err = (*packet.Byte)(&(*a)[i]).ReadFrom(r) + nn, err = (*packet.UUID)(&(*a)[i]).ReadFrom(r) + n += nn + if err != nil { + return n, err + } + } + + return n, err +} + +// Int32VarIntVarIntArray a utility type for encoding/decoding packet.VarInt -> int32[packet.VarInt] slice. +type Int32VarIntVarIntArray []int32 + +func (a Int32VarIntVarIntArray) WriteTo(w io.Writer) (n int64, err error) { + size := len(a) + nn, err := packet.VarInt(size).WriteTo(w) + if err != nil { + return n, err + } + n += nn + for i := 0; i < size; i++ { + nn, err := packet.VarInt(a[i]).WriteTo(w) + n += nn + if err != nil { + return n, err + } + } + return n, nil +} + +func (a *Int32VarIntVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { + var size packet.VarInt + nn, err := size.ReadFrom(r) + n += nn + if err != nil { + return n, err + } + if size < 0 { + return n, errors.New("array length less than zero") + } + + if cap(*a) >= int(size) { + *a = (*a)[:int(size)] + } else { + *a = make(Int32VarIntVarIntArray, int(size)) + } + + for i := 0; i < int(size); i++ { + nn, err = (*packet.VarInt)(&(*a)[i]).ReadFrom(r) n += nn if err != nil { return n, err @@ -7521,3 +7450,51 @@ func (a *StringStringVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { return n, err } + +// StringVarIntArray a utility type for encoding/decoding packet.String -> string[packet.VarInt] slice. +type StringVarIntArray []string + +func (a StringVarIntArray) WriteTo(w io.Writer) (n int64, err error) { + size := len(a) + nn, err := packet.VarInt(size).WriteTo(w) + if err != nil { + return n, err + } + n += nn + for i := 0; i < size; i++ { + nn, err := packet.String(a[i]).WriteTo(w) + n += nn + if err != nil { + return n, err + } + } + return n, nil +} + +func (a *StringVarIntArray) ReadFrom(r io.Reader) (n int64, err error) { + var size packet.VarInt + nn, err := size.ReadFrom(r) + n += nn + if err != nil { + return n, err + } + if size < 0 { + return n, errors.New("array length less than zero") + } + + if cap(*a) >= int(size) { + *a = (*a)[:int(size)] + } else { + *a = make(StringVarIntArray, int(size)) + } + + for i := 0; i < int(size); i++ { + nn, err = (*packet.String)(&(*a)[i]).ReadFrom(r) + n += nn + if err != nil { + return n, err + } + } + + return n, err +} diff --git a/pkg/protocol/packet/game/client/commands.go b/pkg/protocol/packet/game/client/commands.go index fd9d36f..dd9a9f7 100644 --- a/pkg/protocol/packet/game/client/commands.go +++ b/pkg/protocol/packet/game/client/commands.go @@ -1,9 +1,5 @@ package client -import "github.com/Tnze/go-mc/server/command" - //codec:gen type Commands struct { - Nodes []command.Node - RootIndex int32 `mc:"VarInt"` } diff --git a/pkg/protocol/packet/game/client/packet.go b/pkg/protocol/packet/game/client/packet.go index ae27fef..3ee2e0d 100644 --- a/pkg/protocol/packet/game/client/packet.go +++ b/pkg/protocol/packet/game/client/packet.go @@ -418,399 +418,399 @@ func registerPacket(creator clientBoundPacketCreator) { ClientboundPackets[creator().PacketID()] = creator } -func (AddEntity) PacketID() packetid.ClientboundPacketID { +func (*AddEntity) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundAddEntity } -func (Animate) PacketID() packetid.ClientboundPacketID { +func (*Animate) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundAnimate } -func (AwardStats) PacketID() packetid.ClientboundPacketID { +func (*AwardStats) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundAwardStats } -func (BlockChangedAck) PacketID() packetid.ClientboundPacketID { +func (*BlockChangedAck) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundBlockChangedAck } -func (BlockDestruction) PacketID() packetid.ClientboundPacketID { +func (*BlockDestruction) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundBlockDestruction } -func (BlockEntityData) PacketID() packetid.ClientboundPacketID { +func (*BlockEntityData) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundBlockEntityData } -func (BlockEvent) PacketID() packetid.ClientboundPacketID { +func (*BlockEvent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundBlockEvent } -func (BlockUpdate) PacketID() packetid.ClientboundPacketID { +func (*BlockUpdate) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundBlockUpdate } -func (BossEvent) PacketID() packetid.ClientboundPacketID { +func (*BossEvent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundBossEvent } -func (ChangeDifficulty) PacketID() packetid.ClientboundPacketID { +func (*ChangeDifficulty) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundChangeDifficulty } -func (ChunkBatchFinished) PacketID() packetid.ClientboundPacketID { +func (*ChunkBatchFinished) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundChunkBatchFinished } -func (ChunkBatchStart) PacketID() packetid.ClientboundPacketID { +func (*ChunkBatchStart) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundChunkBatchStart } -func (ChunkBiomes) PacketID() packetid.ClientboundPacketID { +func (*ChunkBiomes) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundChunksBiomes } -func (ClearTitles) PacketID() packetid.ClientboundPacketID { +func (*ClearTitles) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundClearTitles } -func (CommandSuggestions) PacketID() packetid.ClientboundPacketID { +func (*CommandSuggestions) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCommandSuggestions } -func (Commands) PacketID() packetid.ClientboundPacketID { +func (*Commands) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCommands } -func (CloseContainer) PacketID() packetid.ClientboundPacketID { +func (*CloseContainer) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundContainerClose } -func (SetContainerContent) PacketID() packetid.ClientboundPacketID { +func (*SetContainerContent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundContainerSetContent } -func (ContainerSetData) PacketID() packetid.ClientboundPacketID { +func (*ContainerSetData) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundContainerSetData } -func (ContainerSetSlot) PacketID() packetid.ClientboundPacketID { +func (*ContainerSetSlot) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundContainerSetSlot } -func (CookieRequest) PacketID() packetid.ClientboundPacketID { +func (*CookieRequest) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCookieRequest } -func (Cooldown) PacketID() packetid.ClientboundPacketID { +func (*Cooldown) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCooldown } -func (CustomChatCompletions) PacketID() packetid.ClientboundPacketID { +func (*CustomChatCompletions) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCustomChatCompletions } -func (CustomPayload) PacketID() packetid.ClientboundPacketID { +func (*CustomPayload) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCustomPayload } -func (DamageEvent) PacketID() packetid.ClientboundPacketID { +func (*DamageEvent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundDamageEvent } -func (DebugSample) PacketID() packetid.ClientboundPacketID { +func (*DebugSample) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundDebugSample } -func (DeleteChat) PacketID() packetid.ClientboundPacketID { +func (*DeleteChat) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundDeleteChat } -func (Disconnect) PacketID() packetid.ClientboundPacketID { +func (*Disconnect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundDisconnect } -func (DisguisedChat) PacketID() packetid.ClientboundPacketID { +func (*DisguisedChat) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundDisguisedChat } -func (EntityEvent) PacketID() packetid.ClientboundPacketID { +func (*EntityEvent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundEntityEvent } -func (TeleportEntity) PacketID() packetid.ClientboundPacketID { +func (*TeleportEntity) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundEntityPositionSync } -func (Explode) PacketID() packetid.ClientboundPacketID { +func (*Explode) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundExplode } -func (ForgetLevelChunk) PacketID() packetid.ClientboundPacketID { +func (*ForgetLevelChunk) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundForgetLevelChunk } -func (GameEvent) PacketID() packetid.ClientboundPacketID { +func (*GameEvent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundGameEvent } -func (OpenHorseScreen) PacketID() packetid.ClientboundPacketID { +func (*OpenHorseScreen) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundHorseScreenOpen } -func (HurtAnimation) PacketID() packetid.ClientboundPacketID { +func (*HurtAnimation) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundHurtAnimation } -func (InitializeWorldBorder) PacketID() packetid.ClientboundPacketID { +func (*InitializeWorldBorder) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundInitializeBorder } -func (KeepAlive) PacketID() packetid.ClientboundPacketID { +func (*KeepAlive) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundKeepAlive } -func (LevelChunkWithLight) PacketID() packetid.ClientboundPacketID { +func (*LevelChunkWithLight) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLevelChunkWithLight } -func (LevelEvent) PacketID() packetid.ClientboundPacketID { +func (*LevelEvent) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLevelEvent } -func (Particle) PacketID() packetid.ClientboundPacketID { +func (*Particle) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLevelParticles } -func (UpdateLight) PacketID() packetid.ClientboundPacketID { +func (*UpdateLight) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLightUpdate } -func (Login) PacketID() packetid.ClientboundPacketID { +func (*Login) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLogin } -func (MapData) PacketID() packetid.ClientboundPacketID { +func (*MapData) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMapItemData } -func (MerchantOffers) PacketID() packetid.ClientboundPacketID { +func (*MerchantOffers) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMerchantOffers } -func (UpdateEntityPosition) PacketID() packetid.ClientboundPacketID { +func (*UpdateEntityPosition) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMoveEntityPos } -func (UpdateEntityPositionAndRotation) PacketID() packetid.ClientboundPacketID { +func (*UpdateEntityPositionAndRotation) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMoveEntityPosRot } -func (MoveMinecartAlongTrack) PacketID() packetid.ClientboundPacketID { +func (*MoveMinecartAlongTrack) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMoveMinecartAlongTrack } -func (UpdateEntityRotation) PacketID() packetid.ClientboundPacketID { +func (*UpdateEntityRotation) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMoveEntityRot } -func (MoveVehicle) PacketID() packetid.ClientboundPacketID { +func (*MoveVehicle) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundMoveVehicle } -func (OpenBook) PacketID() packetid.ClientboundPacketID { +func (*OpenBook) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundOpenBook } -func (OpenScreen) PacketID() packetid.ClientboundPacketID { +func (*OpenScreen) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundOpenScreen } -func (OpenSignEditor) PacketID() packetid.ClientboundPacketID { +func (*OpenSignEditor) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundOpenSignEditor } -func (Ping) PacketID() packetid.ClientboundPacketID { +func (*Ping) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPing } -func (PingResponse) PacketID() packetid.ClientboundPacketID { +func (*PingResponse) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPongResponse } -func (PlaceGhostRecipe) PacketID() packetid.ClientboundPacketID { +func (*PlaceGhostRecipe) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlaceGhostRecipe } -func (PlayerAbilities) PacketID() packetid.ClientboundPacketID { +func (*PlayerAbilities) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerAbilities } -func (EndCombat) PacketID() packetid.ClientboundPacketID { +func (*EndCombat) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerCombatEnd } -func (EnterCombat) PacketID() packetid.ClientboundPacketID { +func (*EnterCombat) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerCombatEnter } -func (CombatDeath) PacketID() packetid.ClientboundPacketID { +func (*CombatDeath) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerCombatKill } -func (PlayerInfoRemove) PacketID() packetid.ClientboundPacketID { +func (*PlayerInfoRemove) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerInfoRemove } -func (PlayerInfoUpdate) PacketID() packetid.ClientboundPacketID { +func (*PlayerInfoUpdate) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerInfoUpdate } -func (LookAt) PacketID() packetid.ClientboundPacketID { +func (*LookAt) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerLookAt } -func (PlayerPosition) PacketID() packetid.ClientboundPacketID { +func (*PlayerPosition) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerPosition } -func (PlayerRotation) PacketID() packetid.ClientboundPacketID { +func (*PlayerRotation) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundPlayerRotation } -func (RecipeBookAdd) PacketID() packetid.ClientboundPacketID { +func (*RecipeBookAdd) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRecipeBookAdd } -func (RecipeBookRemove) PacketID() packetid.ClientboundPacketID { +func (*RecipeBookRemove) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRecipeBookRemove } -func (RecipeBookSettings) PacketID() packetid.ClientboundPacketID { +func (*RecipeBookSettings) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRecipeBookSettings } -func (RemoveEntities) PacketID() packetid.ClientboundPacketID { +func (*RemoveEntities) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRemoveEntities } -func (RemoveMobEffect) PacketID() packetid.ClientboundPacketID { +func (*RemoveMobEffect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRemoveMobEffect } -func (ResetScore) PacketID() packetid.ClientboundPacketID { +func (*ResetScore) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundResetScore } -func (AddResourcePack) PacketID() packetid.ClientboundPacketID { +func (*AddResourcePack) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundResourcePackPop } -func (RemoveResourcePack) PacketID() packetid.ClientboundPacketID { +func (*RemoveResourcePack) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundResourcePackPush } -func (Respawn) PacketID() packetid.ClientboundPacketID { +func (*Respawn) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRespawn } -func (SetHeadRotation) PacketID() packetid.ClientboundPacketID { +func (*SetHeadRotation) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundRotateHead } -func (UpdateSectionsBlocks) PacketID() packetid.ClientboundPacketID { +func (*UpdateSectionsBlocks) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSectionBlocksUpdate } -func (SelectAdvancementsTab) PacketID() packetid.ClientboundPacketID { +func (*SelectAdvancementsTab) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSelectAdvancementsTab } -func (ServerData) PacketID() packetid.ClientboundPacketID { +func (*ServerData) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundServerData } -func (SetActionBarText) PacketID() packetid.ClientboundPacketID { +func (*SetActionBarText) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetActionBarText } -func (SetBorderCenter) PacketID() packetid.ClientboundPacketID { +func (*SetBorderCenter) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetBorderCenter } -func (SetBorderLerpSize) PacketID() packetid.ClientboundPacketID { +func (*SetBorderLerpSize) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetBorderLerpSize } -func (SetBorderSize) PacketID() packetid.ClientboundPacketID { +func (*SetBorderSize) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetBorderSize } -func (SetBorderWarningDelay) PacketID() packetid.ClientboundPacketID { +func (*SetBorderWarningDelay) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetBorderWarningDelay } -func (SetBorderWarningDistance) PacketID() packetid.ClientboundPacketID { +func (*SetBorderWarningDistance) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetBorderWarningDistance } -func (SetCamera) PacketID() packetid.ClientboundPacketID { +func (*SetCamera) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetCamera } -func (SetCenterChunk) PacketID() packetid.ClientboundPacketID { +func (*SetCenterChunk) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetChunkCacheCenter } -func (SetRenderDistance) PacketID() packetid.ClientboundPacketID { +func (*SetRenderDistance) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetChunkCacheRadius } -func (SetCursorItem) PacketID() packetid.ClientboundPacketID { +func (*SetCursorItem) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetCursorItem } -func (SetDefaultSpawnPosition) PacketID() packetid.ClientboundPacketID { +func (*SetDefaultSpawnPosition) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetDefaultSpawnPosition } -func (DisplayObjective) PacketID() packetid.ClientboundPacketID { +func (*DisplayObjective) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetDisplayObjective } -func (SetEntityMetadata) PacketID() packetid.ClientboundPacketID { +func (*SetEntityMetadata) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetEntityData } -func (SetEntityLink) PacketID() packetid.ClientboundPacketID { +func (*SetEntityLink) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetEntityLink } -func (SetEntityVelocity) PacketID() packetid.ClientboundPacketID { +func (*SetEntityVelocity) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetEntityMotion } -func (SetEquipment) PacketID() packetid.ClientboundPacketID { +func (*SetEquipment) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetEquipment } -func (SetExperience) PacketID() packetid.ClientboundPacketID { +func (*SetExperience) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetExperience } -func (SetHealth) PacketID() packetid.ClientboundPacketID { +func (*SetHealth) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetHealth } -func (SetHeldItem) PacketID() packetid.ClientboundPacketID { +func (*SetHeldItem) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetHeldSlot } -func (UpdateObjectives) PacketID() packetid.ClientboundPacketID { +func (*UpdateObjectives) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetObjective } -func (SetPassengers) PacketID() packetid.ClientboundPacketID { +func (*SetPassengers) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetPassengers } -func (SetPlayerInventory) PacketID() packetid.ClientboundPacketID { +func (*SetPlayerInventory) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetPlayerInventory } -func (UpdateTeams) PacketID() packetid.ClientboundPacketID { +func (*UpdateTeams) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetPlayerTeam } -func (UpdateScore) PacketID() packetid.ClientboundPacketID { +func (*UpdateScore) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetScore } -func (SetSimulationDistance) PacketID() packetid.ClientboundPacketID { +func (*SetSimulationDistance) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetSimulationDistance } -func (SetSubtitleText) PacketID() packetid.ClientboundPacketID { +func (*SetSubtitleText) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetSubtitleText } -func (SetTime) PacketID() packetid.ClientboundPacketID { +func (*SetTime) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetTime } -func (SetTitleText) PacketID() packetid.ClientboundPacketID { +func (*SetTitleText) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetTitleText } -func (SetTitleAnimationTimes) PacketID() packetid.ClientboundPacketID { +func (*SetTitleAnimationTimes) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSetTitlesAnimation } -func (EntitySoundEffect) PacketID() packetid.ClientboundPacketID { +func (*EntitySoundEffect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSoundEntity } -func (SoundEffect) PacketID() packetid.ClientboundPacketID { +func (*SoundEffect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSound } -func (StartConfiguration) PacketID() packetid.ClientboundPacketID { +func (*StartConfiguration) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundStartConfiguration } -func (StopSound) PacketID() packetid.ClientboundPacketID { +func (*StopSound) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundStopSound } -func (StoreCookie) PacketID() packetid.ClientboundPacketID { +func (*StoreCookie) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundStoreCookie } -func (SystemChatMessage) PacketID() packetid.ClientboundPacketID { +func (*SystemChatMessage) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundSystemChat } -func (SetTabListHeaderAndFooter) PacketID() packetid.ClientboundPacketID { +func (*SetTabListHeaderAndFooter) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTabList } -func (TagQueryResponse) PacketID() packetid.ClientboundPacketID { +func (*TagQueryResponse) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTagQuery } -func (PickupItem) PacketID() packetid.ClientboundPacketID { +func (*PickupItem) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTakeItemEntity } -func (SynchronizeVehiclePosition) PacketID() packetid.ClientboundPacketID { +func (*SynchronizeVehiclePosition) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTeleportEntity } -func (TestInstanceBlockStatus) PacketID() packetid.ClientboundPacketID { +func (*TestInstanceBlockStatus) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTestInstanceBlockStatus } -func (SetTickingState) PacketID() packetid.ClientboundPacketID { +func (*SetTickingState) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTickingState } -func (StepTick) PacketID() packetid.ClientboundPacketID { +func (*StepTick) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTickingStep } -func (Transfer) PacketID() packetid.ClientboundPacketID { +func (*Transfer) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundTransfer } -func (UpdateAdvancements) PacketID() packetid.ClientboundPacketID { +func (*UpdateAdvancements) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundUpdateAdvancements } -func (UpdateAttributes) PacketID() packetid.ClientboundPacketID { +func (*UpdateAttributes) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundUpdateAttributes } -func (EntityEffect) PacketID() packetid.ClientboundPacketID { +func (*EntityEffect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundUpdateMobEffect } -func (UpdateRecipes) PacketID() packetid.ClientboundPacketID { +func (*UpdateRecipes) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundUpdateRecipes } -func (UpdateTags) PacketID() packetid.ClientboundPacketID { +func (*UpdateTags) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundUpdateTags } -func (ProjectilePower) PacketID() packetid.ClientboundPacketID { +func (*ProjectilePower) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundProjectilePower } -func (CustomReportDetails) PacketID() packetid.ClientboundPacketID { +func (*CustomReportDetails) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundCustomReportDetails } -func (ServerLinks) PacketID() packetid.ClientboundPacketID { +func (*ServerLinks) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundServerLinks } -func (Waypoint) PacketID() packetid.ClientboundPacketID { +func (*Waypoint) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundWaypoint } -func (ClearDialog) PacketID() packetid.ClientboundPacketID { +func (*ClearDialog) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundClearDialog } -func (ShowDialog) PacketID() packetid.ClientboundPacketID { +func (*ShowDialog) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundShowDialog } diff --git a/pkg/protocol/packet/game/client/player_info_update.go b/pkg/protocol/packet/game/client/player_info_update.go index 4f9a428..ee29941 100644 --- a/pkg/protocol/packet/game/client/player_info_update.go +++ b/pkg/protocol/packet/game/client/player_info_update.go @@ -54,7 +54,7 @@ func (p PlayerInfoUpdate) WriteTo(w io.Writer) (n int64, err error) { } func (p *PlayerInfoUpdate) ReadFrom(r io.Reader) (n int64, err error) { - bitset := pk.NewFixedBitSet(8) + bitset := pk.NewFixedBitSet(256) n1, err := bitset.ReadFrom(r) if err != nil { return n1, err diff --git a/pkg/protocol/packet/game/server/accept_teleportation.go b/pkg/protocol/packet/game/server/accept_teleportation.go index 76b1399..8a6adc0 100644 --- a/pkg/protocol/packet/game/server/accept_teleportation.go +++ b/pkg/protocol/packet/game/server/accept_teleportation.go @@ -7,7 +7,7 @@ type AcceptTeleportation struct { TeleportID int32 `mc:"VarInt"` } -func (AcceptTeleportation) PacketID() packetid.ServerboundPacketID { +func (*AcceptTeleportation) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundAcceptTeleportation } diff --git a/pkg/protocol/packet/game/server/block_entity_tag_query.go b/pkg/protocol/packet/game/server/block_entity_tag_query.go index ed3646f..ab9b728 100644 --- a/pkg/protocol/packet/game/server/block_entity_tag_query.go +++ b/pkg/protocol/packet/game/server/block_entity_tag_query.go @@ -11,7 +11,7 @@ type BlockEntityTagQuery struct { Location pk.Position } -func (BlockEntityTagQuery) PacketID() packetid.ServerboundPacketID { +func (*BlockEntityTagQuery) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundBlockEntityTagQuery } diff --git a/pkg/protocol/packet/game/server/bundle_item_selected.go b/pkg/protocol/packet/game/server/bundle_item_selected.go index b611c7e..41f56a3 100644 --- a/pkg/protocol/packet/game/server/bundle_item_selected.go +++ b/pkg/protocol/packet/game/server/bundle_item_selected.go @@ -8,7 +8,7 @@ type BundleItemSelected struct { SlotInBundle int32 `mc:"VarInt"` } -func (BundleItemSelected) PacketID() packetid.ServerboundPacketID { +func (*BundleItemSelected) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundBundleItemSelected } diff --git a/pkg/protocol/packet/game/server/change_difficulty.go b/pkg/protocol/packet/game/server/change_difficulty.go index a0a1c98..bc5b93b 100644 --- a/pkg/protocol/packet/game/server/change_difficulty.go +++ b/pkg/protocol/packet/game/server/change_difficulty.go @@ -7,7 +7,7 @@ type ChangeDifficulty struct { Difficulty uint8 } -func (ChangeDifficulty) PacketID() packetid.ServerboundPacketID { +func (*ChangeDifficulty) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChangeDifficulty } diff --git a/pkg/protocol/packet/game/server/change_game_mode.go b/pkg/protocol/packet/game/server/change_game_mode.go index 9e52f50..a554e98 100644 --- a/pkg/protocol/packet/game/server/change_game_mode.go +++ b/pkg/protocol/packet/game/server/change_game_mode.go @@ -7,7 +7,7 @@ type ChangeGameMode struct { GameMode int32 `mc:"VarInt"` } -func (ChangeGameMode) PacketID() packetid.ServerboundPacketID { +func (*ChangeGameMode) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChangeGameMode } diff --git a/pkg/protocol/packet/game/server/chat.go b/pkg/protocol/packet/game/server/chat.go index 5b6ec34..756a959 100644 --- a/pkg/protocol/packet/game/server/chat.go +++ b/pkg/protocol/packet/game/server/chat.go @@ -18,7 +18,7 @@ type Chat struct { Checksum int8 } -func (Chat) PacketID() packetid.ServerboundPacketID { +func (*Chat) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChat } diff --git a/pkg/protocol/packet/game/server/chat_ack.go b/pkg/protocol/packet/game/server/chat_ack.go index 20d4775..a0a0ca4 100644 --- a/pkg/protocol/packet/game/server/chat_ack.go +++ b/pkg/protocol/packet/game/server/chat_ack.go @@ -7,7 +7,7 @@ type ChatAck struct { MessageCount int32 `mc:"VarInt"` } -func (ChatAck) PacketID() packetid.ServerboundPacketID { +func (*ChatAck) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChatAck } diff --git a/pkg/protocol/packet/game/server/chat_command.go b/pkg/protocol/packet/game/server/chat_command.go index 64d1de2..bc781ed 100644 --- a/pkg/protocol/packet/game/server/chat_command.go +++ b/pkg/protocol/packet/game/server/chat_command.go @@ -7,7 +7,7 @@ type ChatCommand struct { Command string } -func (ChatCommand) PacketID() packetid.ServerboundPacketID { +func (*ChatCommand) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChatCommand } diff --git a/pkg/protocol/packet/game/server/chat_command_signed.go b/pkg/protocol/packet/game/server/chat_command_signed.go index 6ce5997..2b8ac86 100644 --- a/pkg/protocol/packet/game/server/chat_command_signed.go +++ b/pkg/protocol/packet/game/server/chat_command_signed.go @@ -22,7 +22,7 @@ type ChatCommandSigned struct { Checksum int8 } -func (ChatCommandSigned) PacketID() packetid.ServerboundPacketID { +func (*ChatCommandSigned) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChatCommandSigned } diff --git a/pkg/protocol/packet/game/server/chat_session_update.go b/pkg/protocol/packet/game/server/chat_session_update.go index 38139d7..633a693 100644 --- a/pkg/protocol/packet/game/server/chat_session_update.go +++ b/pkg/protocol/packet/game/server/chat_session_update.go @@ -12,7 +12,7 @@ type ChatSessionUpdate struct { PublicKey user.PublicKey } -func (ChatSessionUpdate) PacketID() packetid.ServerboundPacketID { +func (*ChatSessionUpdate) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChatSessionUpdate } diff --git a/pkg/protocol/packet/game/server/chunk_batch_received.go b/pkg/protocol/packet/game/server/chunk_batch_received.go index bf1bd83..c0906cb 100644 --- a/pkg/protocol/packet/game/server/chunk_batch_received.go +++ b/pkg/protocol/packet/game/server/chunk_batch_received.go @@ -7,7 +7,7 @@ type ChunkBatchReceived struct { ChunksPerTick float32 } -func (ChunkBatchReceived) PacketID() packetid.ServerboundPacketID { +func (*ChunkBatchReceived) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundChunkBatchReceived } diff --git a/pkg/protocol/packet/game/server/client_command.go b/pkg/protocol/packet/game/server/client_command.go index 9ed7b0f..4b433a4 100644 --- a/pkg/protocol/packet/game/server/client_command.go +++ b/pkg/protocol/packet/game/server/client_command.go @@ -7,7 +7,7 @@ type ClientCommand struct { Action int32 `mc:"VarInt"` } -func (ClientCommand) PacketID() packetid.ServerboundPacketID { +func (*ClientCommand) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundClientCommand } diff --git a/pkg/protocol/packet/game/server/client_information.go b/pkg/protocol/packet/game/server/client_information.go index 10424a5..2667157 100644 --- a/pkg/protocol/packet/game/server/client_information.go +++ b/pkg/protocol/packet/game/server/client_information.go @@ -15,7 +15,7 @@ type ClientInformation struct { ParticleStatus int32 `mc:"VarInt"` } -func (ClientInformation) PacketID() packetid.ServerboundPacketID { +func (*ClientInformation) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundClientInformation } diff --git a/pkg/protocol/packet/game/server/client_tick_end.go b/pkg/protocol/packet/game/server/client_tick_end.go index 5b24bde..e8952d0 100644 --- a/pkg/protocol/packet/game/server/client_tick_end.go +++ b/pkg/protocol/packet/game/server/client_tick_end.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type ClientTickEnd struct { } -func (ClientTickEnd) PacketID() packetid.ServerboundPacketID { +func (*ClientTickEnd) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundClientTickEnd } diff --git a/pkg/protocol/packet/game/server/command_suggestion.go b/pkg/protocol/packet/game/server/command_suggestion.go index ef05083..50cb2ac 100644 --- a/pkg/protocol/packet/game/server/command_suggestion.go +++ b/pkg/protocol/packet/game/server/command_suggestion.go @@ -8,7 +8,7 @@ type CommandSuggestion struct { Text string } -func (CommandSuggestion) PacketID() packetid.ServerboundPacketID { +func (*CommandSuggestion) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundCommandSuggestion } diff --git a/pkg/protocol/packet/game/server/configuration_acknowledged.go b/pkg/protocol/packet/game/server/configuration_acknowledged.go index f57d4b2..52b8e0a 100644 --- a/pkg/protocol/packet/game/server/configuration_acknowledged.go +++ b/pkg/protocol/packet/game/server/configuration_acknowledged.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type ConfigurationAcknowledged struct { } -func (ConfigurationAcknowledged) PacketID() packetid.ServerboundPacketID { +func (*ConfigurationAcknowledged) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundConfigurationAcknowledged } diff --git a/pkg/protocol/packet/game/server/container_button_click.go b/pkg/protocol/packet/game/server/container_button_click.go index b05ed63..c047cd6 100644 --- a/pkg/protocol/packet/game/server/container_button_click.go +++ b/pkg/protocol/packet/game/server/container_button_click.go @@ -8,7 +8,7 @@ type ContainerButtonClick struct { ButtonID int32 `mc:"VarInt"` } -func (ContainerButtonClick) PacketID() packetid.ServerboundPacketID { +func (*ContainerButtonClick) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundContainerButtonClick } diff --git a/pkg/protocol/packet/game/server/container_click.go b/pkg/protocol/packet/game/server/container_click.go index e323ef2..037d24a 100644 --- a/pkg/protocol/packet/game/server/container_click.go +++ b/pkg/protocol/packet/game/server/container_click.go @@ -22,7 +22,7 @@ type ContainerClick struct { CarriedSlot slot.HashedSlot } -func (ContainerClick) PacketID() packetid.ServerboundPacketID { +func (*ContainerClick) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundContainerClick } diff --git a/pkg/protocol/packet/game/server/container_close.go b/pkg/protocol/packet/game/server/container_close.go index e645d5a..5536bbb 100644 --- a/pkg/protocol/packet/game/server/container_close.go +++ b/pkg/protocol/packet/game/server/container_close.go @@ -7,7 +7,7 @@ type ContainerClose struct { WindowID int32 `mc:"VarInt"` } -func (ContainerClose) PacketID() packetid.ServerboundPacketID { +func (*ContainerClose) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundContainerClose } diff --git a/pkg/protocol/packet/game/server/container_slot_state_changed.go b/pkg/protocol/packet/game/server/container_slot_state_changed.go index 09f1fe2..46ddac9 100644 --- a/pkg/protocol/packet/game/server/container_slot_state_changed.go +++ b/pkg/protocol/packet/game/server/container_slot_state_changed.go @@ -9,7 +9,7 @@ type ContainerSlotStateChanged struct { State bool } -func (ContainerSlotStateChanged) PacketID() packetid.ServerboundPacketID { +func (*ContainerSlotStateChanged) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundContainerSlotStateChanged } diff --git a/pkg/protocol/packet/game/server/cookie_response.go b/pkg/protocol/packet/game/server/cookie_response.go index a134297..6746b97 100644 --- a/pkg/protocol/packet/game/server/cookie_response.go +++ b/pkg/protocol/packet/game/server/cookie_response.go @@ -10,7 +10,7 @@ type CookieResponse struct { Payload []int8 `mc:"Byte"` } -func (CookieResponse) PacketID() packetid.ServerboundPacketID { +func (*CookieResponse) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundCookieResponse } diff --git a/pkg/protocol/packet/game/server/custom_click_action.go b/pkg/protocol/packet/game/server/custom_click_action.go index 22c5b39..b2a2e90 100644 --- a/pkg/protocol/packet/game/server/custom_click_action.go +++ b/pkg/protocol/packet/game/server/custom_click_action.go @@ -11,7 +11,7 @@ type CustomClickAction struct { Payload nbt.RawMessage `mc:"NBT"` } -func (CustomClickAction) PacketID() packetid.ServerboundPacketID { +func (*CustomClickAction) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundCustomClickAction } diff --git a/pkg/protocol/packet/game/server/custom_payload.go b/pkg/protocol/packet/game/server/custom_payload.go index 5c7e35d..dc028c2 100644 --- a/pkg/protocol/packet/game/server/custom_payload.go +++ b/pkg/protocol/packet/game/server/custom_payload.go @@ -8,7 +8,7 @@ type CustomPayload struct { Data []byte `mc:"ByteArray"` } -func (CustomPayload) PacketID() packetid.ServerboundPacketID { +func (*CustomPayload) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundCustomPayload } diff --git a/pkg/protocol/packet/game/server/debug_sample_subscription.go b/pkg/protocol/packet/game/server/debug_sample_subscription.go index 3034d7f..78c543c 100644 --- a/pkg/protocol/packet/game/server/debug_sample_subscription.go +++ b/pkg/protocol/packet/game/server/debug_sample_subscription.go @@ -7,7 +7,7 @@ type DebugSampleSubscription struct { SampleType int32 `mc:"VarInt"` } -func (DebugSampleSubscription) PacketID() packetid.ServerboundPacketID { +func (*DebugSampleSubscription) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundDebugSampleSubscription } diff --git a/pkg/protocol/packet/game/server/edit_book.go b/pkg/protocol/packet/game/server/edit_book.go index 172e8ec..75cb724 100644 --- a/pkg/protocol/packet/game/server/edit_book.go +++ b/pkg/protocol/packet/game/server/edit_book.go @@ -11,7 +11,7 @@ type EditBook struct { Title string } -func (EditBook) PacketID() packetid.ServerboundPacketID { +func (*EditBook) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundEditBook } diff --git a/pkg/protocol/packet/game/server/entity_tag_query.go b/pkg/protocol/packet/game/server/entity_tag_query.go index 59a28a9..1e708b5 100644 --- a/pkg/protocol/packet/game/server/entity_tag_query.go +++ b/pkg/protocol/packet/game/server/entity_tag_query.go @@ -8,7 +8,7 @@ type EntityTagQuery struct { EntityID int32 `mc:"VarInt"` } -func (EntityTagQuery) PacketID() packetid.ServerboundPacketID { +func (*EntityTagQuery) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundEntityTagQuery } diff --git a/pkg/protocol/packet/game/server/interact.go b/pkg/protocol/packet/game/server/interact.go index 6231e42..1bd9cfb 100644 --- a/pkg/protocol/packet/game/server/interact.go +++ b/pkg/protocol/packet/game/server/interact.go @@ -17,7 +17,7 @@ type Interact struct { SneakKeyPressed bool } -func (Interact) PacketID() packetid.ServerboundPacketID { +func (*Interact) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundInteract } diff --git a/pkg/protocol/packet/game/server/jigsaw_generate.go b/pkg/protocol/packet/game/server/jigsaw_generate.go index fe69ffc..4470295 100644 --- a/pkg/protocol/packet/game/server/jigsaw_generate.go +++ b/pkg/protocol/packet/game/server/jigsaw_generate.go @@ -12,7 +12,7 @@ type JigsawGenerate struct { KeepJigsaws bool } -func (JigsawGenerate) PacketID() packetid.ServerboundPacketID { +func (*JigsawGenerate) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundJigsawGenerate } diff --git a/pkg/protocol/packet/game/server/keep_alive.go b/pkg/protocol/packet/game/server/keep_alive.go index 27d0dfc..d523dd8 100644 --- a/pkg/protocol/packet/game/server/keep_alive.go +++ b/pkg/protocol/packet/game/server/keep_alive.go @@ -7,7 +7,7 @@ type KeepAlive struct { ID int64 } -func (KeepAlive) PacketID() packetid.ServerboundPacketID { +func (*KeepAlive) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundKeepAlive } diff --git a/pkg/protocol/packet/game/server/lock_difficulty.go b/pkg/protocol/packet/game/server/lock_difficulty.go index 318d60c..c78463b 100644 --- a/pkg/protocol/packet/game/server/lock_difficulty.go +++ b/pkg/protocol/packet/game/server/lock_difficulty.go @@ -7,7 +7,7 @@ type LockDifficulty struct { Locked bool } -func (LockDifficulty) PacketID() packetid.ServerboundPacketID { +func (*LockDifficulty) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundLockDifficulty } diff --git a/pkg/protocol/packet/game/server/move_player_pos.go b/pkg/protocol/packet/game/server/move_player_pos.go index 83d7570..a58fb61 100644 --- a/pkg/protocol/packet/game/server/move_player_pos.go +++ b/pkg/protocol/packet/game/server/move_player_pos.go @@ -8,7 +8,7 @@ type MovePlayerPos struct { Flags int8 } -func (MovePlayerPos) PacketID() packetid.ServerboundPacketID { +func (*MovePlayerPos) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundMovePlayerPos } diff --git a/pkg/protocol/packet/game/server/move_player_pos_rot.go b/pkg/protocol/packet/game/server/move_player_pos_rot.go index 001c35d..904c7d6 100644 --- a/pkg/protocol/packet/game/server/move_player_pos_rot.go +++ b/pkg/protocol/packet/game/server/move_player_pos_rot.go @@ -9,7 +9,7 @@ type MovePlayerPosRot struct { Flags int8 } -func (MovePlayerPosRot) PacketID() packetid.ServerboundPacketID { +func (*MovePlayerPosRot) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundMovePlayerPosRot } diff --git a/pkg/protocol/packet/game/server/move_player_rot.go b/pkg/protocol/packet/game/server/move_player_rot.go index c423e35..f01547e 100644 --- a/pkg/protocol/packet/game/server/move_player_rot.go +++ b/pkg/protocol/packet/game/server/move_player_rot.go @@ -8,7 +8,7 @@ type MovePlayerRot struct { Flags int8 } -func (MovePlayerRot) PacketID() packetid.ServerboundPacketID { +func (*MovePlayerRot) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundMovePlayerRot } diff --git a/pkg/protocol/packet/game/server/move_player_status_only.go b/pkg/protocol/packet/game/server/move_player_status_only.go index 04243ca..0012602 100644 --- a/pkg/protocol/packet/game/server/move_player_status_only.go +++ b/pkg/protocol/packet/game/server/move_player_status_only.go @@ -7,7 +7,7 @@ type MovePlayerStatusOnly struct { Flags int8 } -func (MovePlayerStatusOnly) PacketID() packetid.ServerboundPacketID { +func (*MovePlayerStatusOnly) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundMovePlayerStatusOnly } diff --git a/pkg/protocol/packet/game/server/move_vehicle.go b/pkg/protocol/packet/game/server/move_vehicle.go index 00c8413..5e7fb4c 100644 --- a/pkg/protocol/packet/game/server/move_vehicle.go +++ b/pkg/protocol/packet/game/server/move_vehicle.go @@ -9,7 +9,7 @@ type MoveVehicle struct { OnGround bool } -func (MoveVehicle) PacketID() packetid.ServerboundPacketID { +func (*MoveVehicle) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundMoveVehicle } diff --git a/pkg/protocol/packet/game/server/paddle_boat.go b/pkg/protocol/packet/game/server/paddle_boat.go index 2409082..faa8f22 100644 --- a/pkg/protocol/packet/game/server/paddle_boat.go +++ b/pkg/protocol/packet/game/server/paddle_boat.go @@ -7,7 +7,7 @@ type PaddleBoat struct { LeftTurning, RightTurning bool } -func (PaddleBoat) PacketID() packetid.ServerboundPacketID { +func (*PaddleBoat) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPaddleBoat } diff --git a/pkg/protocol/packet/game/server/pick_item_from_block.go b/pkg/protocol/packet/game/server/pick_item_from_block.go index af08897..9fb86b4 100644 --- a/pkg/protocol/packet/game/server/pick_item_from_block.go +++ b/pkg/protocol/packet/game/server/pick_item_from_block.go @@ -11,7 +11,7 @@ type PickItemFromBlock struct { IncludeData bool } -func (PickItemFromBlock) PacketID() packetid.ServerboundPacketID { +func (*PickItemFromBlock) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPickItemFromBlock } diff --git a/pkg/protocol/packet/game/server/pick_item_from_entity.go b/pkg/protocol/packet/game/server/pick_item_from_entity.go index 5032b90..ad805c1 100644 --- a/pkg/protocol/packet/game/server/pick_item_from_entity.go +++ b/pkg/protocol/packet/game/server/pick_item_from_entity.go @@ -8,7 +8,7 @@ type PickItemFromEntity struct { IncludeData bool } -func (PickItemFromEntity) PacketID() packetid.ServerboundPacketID { +func (*PickItemFromEntity) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPickItemFromEntity } diff --git a/pkg/protocol/packet/game/server/ping_request.go b/pkg/protocol/packet/game/server/ping_request.go index a4ac8fa..69794e8 100644 --- a/pkg/protocol/packet/game/server/ping_request.go +++ b/pkg/protocol/packet/game/server/ping_request.go @@ -7,7 +7,7 @@ type PingRequest struct { payload int64 } -func (PingRequest) PacketID() packetid.ServerboundPacketID { +func (*PingRequest) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPingRequest } diff --git a/pkg/protocol/packet/game/server/place_recipe.go b/pkg/protocol/packet/game/server/place_recipe.go index 9931f58..696372a 100644 --- a/pkg/protocol/packet/game/server/place_recipe.go +++ b/pkg/protocol/packet/game/server/place_recipe.go @@ -9,7 +9,7 @@ type PlaceRecipe struct { MakeAll bool } -func (PlaceRecipe) PacketID() packetid.ServerboundPacketID { +func (*PlaceRecipe) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPlaceRecipe } diff --git a/pkg/protocol/packet/game/server/player_abilities.go b/pkg/protocol/packet/game/server/player_abilities.go index 55eb244..328dd87 100644 --- a/pkg/protocol/packet/game/server/player_abilities.go +++ b/pkg/protocol/packet/game/server/player_abilities.go @@ -7,7 +7,7 @@ type PlayerAbilities struct { Flags int8 } -func (PlayerAbilities) PacketID() packetid.ServerboundPacketID { +func (*PlayerAbilities) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPlayerAbilities } diff --git a/pkg/protocol/packet/game/server/player_action.go b/pkg/protocol/packet/game/server/player_action.go index 03770b3..da9425c 100644 --- a/pkg/protocol/packet/game/server/player_action.go +++ b/pkg/protocol/packet/game/server/player_action.go @@ -13,7 +13,7 @@ type PlayerAction struct { Sequence int32 `mc:"VarInt"` } -func (PlayerAction) PacketID() packetid.ServerboundPacketID { +func (*PlayerAction) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPlayerAction } diff --git a/pkg/protocol/packet/game/server/player_command.go b/pkg/protocol/packet/game/server/player_command.go index 9258363..b614558 100644 --- a/pkg/protocol/packet/game/server/player_command.go +++ b/pkg/protocol/packet/game/server/player_command.go @@ -9,7 +9,7 @@ type PlayerCommand struct { JumpBoost int32 `mc:"VarInt"` } -func (PlayerCommand) PacketID() packetid.ServerboundPacketID { +func (*PlayerCommand) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPlayerCommand } diff --git a/pkg/protocol/packet/game/server/player_input.go b/pkg/protocol/packet/game/server/player_input.go index d2f41b1..427c6f4 100644 --- a/pkg/protocol/packet/game/server/player_input.go +++ b/pkg/protocol/packet/game/server/player_input.go @@ -7,7 +7,7 @@ type PlayerInput struct { Flags uint8 } -func (PlayerInput) PacketID() packetid.ServerboundPacketID { +func (*PlayerInput) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPlayerInput } diff --git a/pkg/protocol/packet/game/server/player_loaded.go b/pkg/protocol/packet/game/server/player_loaded.go index 079de6a..c0041dc 100644 --- a/pkg/protocol/packet/game/server/player_loaded.go +++ b/pkg/protocol/packet/game/server/player_loaded.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type PlayerLoaded struct { } -func (PlayerLoaded) PacketID() packetid.ServerboundPacketID { +func (*PlayerLoaded) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPlayerLoaded } diff --git a/pkg/protocol/packet/game/server/pong.go b/pkg/protocol/packet/game/server/pong.go index 4ee36df..f635263 100644 --- a/pkg/protocol/packet/game/server/pong.go +++ b/pkg/protocol/packet/game/server/pong.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type Pong struct { } -func (Pong) PacketID() packetid.ServerboundPacketID { +func (*Pong) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundPong } diff --git a/pkg/protocol/packet/game/server/recipe_book_change_settings.go b/pkg/protocol/packet/game/server/recipe_book_change_settings.go index 53bbf79..3285bff 100644 --- a/pkg/protocol/packet/game/server/recipe_book_change_settings.go +++ b/pkg/protocol/packet/game/server/recipe_book_change_settings.go @@ -9,7 +9,7 @@ type RecipeBookChangeSettings struct { FilterActive bool } -func (RecipeBookChangeSettings) PacketID() packetid.ServerboundPacketID { +func (*RecipeBookChangeSettings) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundRecipeBookChangeSettings } diff --git a/pkg/protocol/packet/game/server/recipe_book_seen_recipe.go b/pkg/protocol/packet/game/server/recipe_book_seen_recipe.go index 0089093..1af3bb0 100644 --- a/pkg/protocol/packet/game/server/recipe_book_seen_recipe.go +++ b/pkg/protocol/packet/game/server/recipe_book_seen_recipe.go @@ -7,7 +7,7 @@ type RecipeBookSeenRecipe struct { RecipeID int32 `mc:"VarInt"` } -func (RecipeBookSeenRecipe) PacketID() packetid.ServerboundPacketID { +func (*RecipeBookSeenRecipe) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundRecipeBookSeenRecipe } diff --git a/pkg/protocol/packet/game/server/rename_item.go b/pkg/protocol/packet/game/server/rename_item.go index 710d918..2e78b97 100644 --- a/pkg/protocol/packet/game/server/rename_item.go +++ b/pkg/protocol/packet/game/server/rename_item.go @@ -7,7 +7,7 @@ type RenameItem struct { ItemName string } -func (RenameItem) PacketID() packetid.ServerboundPacketID { +func (*RenameItem) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundRenameItem } diff --git a/pkg/protocol/packet/game/server/resource_pack.go b/pkg/protocol/packet/game/server/resource_pack.go index 9e9b18f..c4fe83a 100644 --- a/pkg/protocol/packet/game/server/resource_pack.go +++ b/pkg/protocol/packet/game/server/resource_pack.go @@ -11,7 +11,7 @@ type ResourcePack struct { Result int32 `mc:"VarInt"` } -func (ResourcePack) PacketID() packetid.ServerboundPacketID { +func (*ResourcePack) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundResourcePack } diff --git a/pkg/protocol/packet/game/server/seen_advancements.go b/pkg/protocol/packet/game/server/seen_advancements.go index 42c7773..e3d590a 100644 --- a/pkg/protocol/packet/game/server/seen_advancements.go +++ b/pkg/protocol/packet/game/server/seen_advancements.go @@ -9,7 +9,7 @@ type SeenAdvancements struct { TabID string `mc:"Identifier"` } -func (SeenAdvancements) PacketID() packetid.ServerboundPacketID { +func (*SeenAdvancements) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSeenAdvancements } diff --git a/pkg/protocol/packet/game/server/select_trade.go b/pkg/protocol/packet/game/server/select_trade.go index 7a9e3ec..8b3ffd0 100644 --- a/pkg/protocol/packet/game/server/select_trade.go +++ b/pkg/protocol/packet/game/server/select_trade.go @@ -7,7 +7,7 @@ type SelectTrade struct { SelectedSlot int32 `mc:"VarInt"` } -func (SelectTrade) PacketID() packetid.ServerboundPacketID { +func (*SelectTrade) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSelectTrade } diff --git a/pkg/protocol/packet/game/server/set_beacon.go b/pkg/protocol/packet/game/server/set_beacon.go index e32a20f..d4b55a6 100644 --- a/pkg/protocol/packet/game/server/set_beacon.go +++ b/pkg/protocol/packet/game/server/set_beacon.go @@ -12,7 +12,7 @@ type SetBeacon struct { SecondaryEffect int32 `mc:"VarInt"` } -func (SetBeacon) PacketID() packetid.ServerboundPacketID { +func (*SetBeacon) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetBeacon } diff --git a/pkg/protocol/packet/game/server/set_carried_item.go b/pkg/protocol/packet/game/server/set_carried_item.go index 6dcab20..acd64c6 100644 --- a/pkg/protocol/packet/game/server/set_carried_item.go +++ b/pkg/protocol/packet/game/server/set_carried_item.go @@ -7,7 +7,7 @@ type SetCarriedItem struct { Slot int16 } -func (SetCarriedItem) PacketID() packetid.ServerboundPacketID { +func (*SetCarriedItem) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetCarriedItem } diff --git a/pkg/protocol/packet/game/server/set_command_block.go b/pkg/protocol/packet/game/server/set_command_block.go index f94f5fa..51c1525 100644 --- a/pkg/protocol/packet/game/server/set_command_block.go +++ b/pkg/protocol/packet/game/server/set_command_block.go @@ -13,7 +13,7 @@ type SetCommandBlock struct { Flags int8 } -func (SetCommandBlock) PacketID() packetid.ServerboundPacketID { +func (*SetCommandBlock) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetCommandBlock } diff --git a/pkg/protocol/packet/game/server/set_command_minecart.go b/pkg/protocol/packet/game/server/set_command_minecart.go index d3aeef2..4f744f4 100644 --- a/pkg/protocol/packet/game/server/set_command_minecart.go +++ b/pkg/protocol/packet/game/server/set_command_minecart.go @@ -9,7 +9,7 @@ type SetCommandMinecart struct { TrackOutput bool } -func (SetCommandMinecart) PacketID() packetid.ServerboundPacketID { +func (*SetCommandMinecart) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetCommandMinecart } diff --git a/pkg/protocol/packet/game/server/set_creative_mode_slot.go b/pkg/protocol/packet/game/server/set_creative_mode_slot.go index 1142461..af785a8 100644 --- a/pkg/protocol/packet/game/server/set_creative_mode_slot.go +++ b/pkg/protocol/packet/game/server/set_creative_mode_slot.go @@ -11,7 +11,7 @@ type SetCreativeModeSlot struct { ClickedItem slot.Slot } -func (SetCreativeModeSlot) PacketID() packetid.ServerboundPacketID { +func (*SetCreativeModeSlot) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetCreativeModeSlot } diff --git a/pkg/protocol/packet/game/server/set_jigsaw_block.go b/pkg/protocol/packet/game/server/set_jigsaw_block.go index 028d7c6..cf36562 100644 --- a/pkg/protocol/packet/game/server/set_jigsaw_block.go +++ b/pkg/protocol/packet/game/server/set_jigsaw_block.go @@ -17,7 +17,7 @@ type SetJigsawBlock struct { PlacementPriority int32 `mc:"VarInt"` } -func (SetJigsawBlock) PacketID() packetid.ServerboundPacketID { +func (*SetJigsawBlock) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetJigsawBlock } diff --git a/pkg/protocol/packet/game/server/set_structure_block.go b/pkg/protocol/packet/game/server/set_structure_block.go index ecba1d8..45a3671 100644 --- a/pkg/protocol/packet/game/server/set_structure_block.go +++ b/pkg/protocol/packet/game/server/set_structure_block.go @@ -21,7 +21,7 @@ type SetStructureBlock struct { Flags int8 } -func (SetStructureBlock) PacketID() packetid.ServerboundPacketID { +func (*SetStructureBlock) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetStructureBlock } diff --git a/pkg/protocol/packet/game/server/set_test_block.go b/pkg/protocol/packet/game/server/set_test_block.go index 6cd889d..fbd3094 100644 --- a/pkg/protocol/packet/game/server/set_test_block.go +++ b/pkg/protocol/packet/game/server/set_test_block.go @@ -12,7 +12,7 @@ type SetTestBlock struct { Message string } -func (SetTestBlock) PacketID() packetid.ServerboundPacketID { +func (*SetTestBlock) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSetTestBlock } diff --git a/pkg/protocol/packet/game/server/sign_update.go b/pkg/protocol/packet/game/server/sign_update.go index 210b126..ab16e0e 100644 --- a/pkg/protocol/packet/game/server/sign_update.go +++ b/pkg/protocol/packet/game/server/sign_update.go @@ -12,7 +12,7 @@ type SignUpdate struct { Line1, Line2, Line3, Line4 string } -func (SignUpdate) PacketID() packetid.ServerboundPacketID { +func (*SignUpdate) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSignUpdate } diff --git a/pkg/protocol/packet/game/server/swing.go b/pkg/protocol/packet/game/server/swing.go index fe353b9..c10e232 100644 --- a/pkg/protocol/packet/game/server/swing.go +++ b/pkg/protocol/packet/game/server/swing.go @@ -7,7 +7,7 @@ type Swing struct { Hand int32 `mc:"VarInt"` } -func (Swing) PacketID() packetid.ServerboundPacketID { +func (*Swing) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundSwing } diff --git a/pkg/protocol/packet/game/server/teleport_to_entity.go b/pkg/protocol/packet/game/server/teleport_to_entity.go index 14de199..24e8810 100644 --- a/pkg/protocol/packet/game/server/teleport_to_entity.go +++ b/pkg/protocol/packet/game/server/teleport_to_entity.go @@ -10,7 +10,7 @@ type TeleportToEntity struct { TargetPlayer uuid.UUID `mc:"UUID"` } -func (TeleportToEntity) PacketID() packetid.ServerboundPacketID { +func (*TeleportToEntity) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundTeleportToEntity } diff --git a/pkg/protocol/packet/game/server/test_instance_block_action.go b/pkg/protocol/packet/game/server/test_instance_block_action.go index 21b4f2b..9b12ea3 100644 --- a/pkg/protocol/packet/game/server/test_instance_block_action.go +++ b/pkg/protocol/packet/game/server/test_instance_block_action.go @@ -22,7 +22,7 @@ type TestInstanceBlockAction struct { ErrorMessage chat.Message } -func (TestInstanceBlockAction) PacketID() packetid.ServerboundPacketID { +func (*TestInstanceBlockAction) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundTestInstanceBlockAction } diff --git a/pkg/protocol/packet/game/server/use_item.go b/pkg/protocol/packet/game/server/use_item.go index 5b5f4e2..96ecf9a 100644 --- a/pkg/protocol/packet/game/server/use_item.go +++ b/pkg/protocol/packet/game/server/use_item.go @@ -9,7 +9,7 @@ type UseItem struct { Yaw, Pitch float32 } -func (UseItem) PacketID() packetid.ServerboundPacketID { +func (*UseItem) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundUseItem } diff --git a/pkg/protocol/packet/game/server/use_item_on.go b/pkg/protocol/packet/game/server/use_item_on.go index e80e321..355edd8 100644 --- a/pkg/protocol/packet/game/server/use_item_on.go +++ b/pkg/protocol/packet/game/server/use_item_on.go @@ -16,7 +16,7 @@ type UseItemOn struct { Sequence int32 `mc:"VarInt"` } -func (UseItemOn) PacketID() packetid.ServerboundPacketID { +func (*UseItemOn) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundUseItemOn } diff --git a/pkg/protocol/packet/login/client/cookie_request.go b/pkg/protocol/packet/login/client/cookie_request.go index 305197c..7be005d 100644 --- a/pkg/protocol/packet/login/client/cookie_request.go +++ b/pkg/protocol/packet/login/client/cookie_request.go @@ -7,7 +7,7 @@ type LoginCookieRequest struct { Key string `mc:"Identifier"` } -func (LoginCookieRequest) PacketID() packetid.ClientboundPacketID { +func (*LoginCookieRequest) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLoginCookieRequest } diff --git a/pkg/protocol/packet/login/client/custom_query.go b/pkg/protocol/packet/login/client/custom_query.go index 8985887..70148dc 100644 --- a/pkg/protocol/packet/login/client/custom_query.go +++ b/pkg/protocol/packet/login/client/custom_query.go @@ -9,7 +9,7 @@ type LoginCustomQuery struct { Data []byte `mc:"ByteArray"` } -func (LoginCustomQuery) PacketID() packetid.ClientboundPacketID { +func (*LoginCustomQuery) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLoginCustomQuery } diff --git a/pkg/protocol/packet/login/client/hello.go b/pkg/protocol/packet/login/client/hello.go index 5b3c7ce..55d0145 100644 --- a/pkg/protocol/packet/login/client/hello.go +++ b/pkg/protocol/packet/login/client/hello.go @@ -10,7 +10,7 @@ type LoginHello struct { ShouldAuthenticate bool } -func (LoginHello) PacketID() packetid.ClientboundPacketID { +func (*LoginHello) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLoginHello } diff --git a/pkg/protocol/packet/login/client/login_compression.go b/pkg/protocol/packet/login/client/login_compression.go index fe9cbae..1f32055 100644 --- a/pkg/protocol/packet/login/client/login_compression.go +++ b/pkg/protocol/packet/login/client/login_compression.go @@ -7,7 +7,7 @@ type LoginLoginCompression struct { Threshold int32 `mc:"VarInt"` } -func (LoginLoginCompression) PacketID() packetid.ClientboundPacketID { +func (*LoginLoginCompression) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLoginLoginCompression } diff --git a/pkg/protocol/packet/login/client/login_disconnect.go b/pkg/protocol/packet/login/client/login_disconnect.go index b47183e..0698751 100644 --- a/pkg/protocol/packet/login/client/login_disconnect.go +++ b/pkg/protocol/packet/login/client/login_disconnect.go @@ -10,7 +10,7 @@ type LoginLoginDisconnect struct { Reason chat.JsonMessage } -func (LoginLoginDisconnect) PacketID() packetid.ClientboundPacketID { +func (*LoginLoginDisconnect) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLoginLoginDisconnect } diff --git a/pkg/protocol/packet/login/client/login_finished.go b/pkg/protocol/packet/login/client/login_finished.go index 55599e8..669e00d 100644 --- a/pkg/protocol/packet/login/client/login_finished.go +++ b/pkg/protocol/packet/login/client/login_finished.go @@ -13,7 +13,7 @@ type LoginLoginFinished struct { Properties []user.Property } -func (LoginLoginFinished) PacketID() packetid.ClientboundPacketID { +func (*LoginLoginFinished) PacketID() packetid.ClientboundPacketID { return packetid.ClientboundLoginLoginFinished } diff --git a/pkg/protocol/packet/login/server/cookie_response.go b/pkg/protocol/packet/login/server/cookie_response.go index 3f85ff8..8a8ab4b 100644 --- a/pkg/protocol/packet/login/server/cookie_response.go +++ b/pkg/protocol/packet/login/server/cookie_response.go @@ -10,7 +10,7 @@ type LoginCookieResponse struct { Payload []byte `mc:"ByteArray"` } -func (LoginCookieResponse) PacketID() packetid.ServerboundPacketID { +func (*LoginCookieResponse) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundLoginCookieResponse } diff --git a/pkg/protocol/packet/login/server/custom_query_answer.go b/pkg/protocol/packet/login/server/custom_query_answer.go index d007b47..f861e9b 100644 --- a/pkg/protocol/packet/login/server/custom_query_answer.go +++ b/pkg/protocol/packet/login/server/custom_query_answer.go @@ -10,7 +10,7 @@ type LoginCustomQueryAnswer struct { Data []byte `mc:"ByteArray"` } -func (LoginCustomQueryAnswer) PacketID() packetid.ServerboundPacketID { +func (*LoginCustomQueryAnswer) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundLoginCustomQueryAnswer } diff --git a/pkg/protocol/packet/login/server/hello.go b/pkg/protocol/packet/login/server/hello.go index 79b4fb7..1d034d0 100644 --- a/pkg/protocol/packet/login/server/hello.go +++ b/pkg/protocol/packet/login/server/hello.go @@ -11,7 +11,7 @@ type LoginHello struct { UUID uuid.UUID `mc:"UUID"` } -func (LoginHello) PacketID() packetid.ServerboundPacketID { +func (*LoginHello) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundLoginHello } diff --git a/pkg/protocol/packet/login/server/key.go b/pkg/protocol/packet/login/server/key.go index 6db8b91..27e1597 100644 --- a/pkg/protocol/packet/login/server/key.go +++ b/pkg/protocol/packet/login/server/key.go @@ -8,7 +8,7 @@ type LoginKey struct { VerifyToken []byte `mc:"ByteArray"` } -func (LoginKey) PacketID() packetid.ServerboundPacketID { +func (*LoginKey) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundLoginKey } diff --git a/pkg/protocol/packet/login/server/login_acknowledged.go b/pkg/protocol/packet/login/server/login_acknowledged.go index 151c480..1df07db 100644 --- a/pkg/protocol/packet/login/server/login_acknowledged.go +++ b/pkg/protocol/packet/login/server/login_acknowledged.go @@ -6,7 +6,7 @@ import "github.com/Tnze/go-mc/data/packetid" type LoginLoginAcknowledged struct { } -func (LoginLoginAcknowledged) PacketID() packetid.ServerboundPacketID { +func (*LoginLoginAcknowledged) PacketID() packetid.ServerboundPacketID { return packetid.ServerboundLoginLoginAcknowledged } diff --git a/pkg/protocol/slot/component.go b/pkg/protocol/slot/component.go index cb3a98f..1bd229f 100644 --- a/pkg/protocol/slot/component.go +++ b/pkg/protocol/slot/component.go @@ -1,6 +1,8 @@ package slot -import pk "github.com/Tnze/go-mc/net/packet" +import ( + pk "github.com/Tnze/go-mc/net/packet" +) type Component interface { Type() ComponentID diff --git a/pkg/protocol/slot/item_stack.go b/pkg/protocol/slot/item_stack.go index 6bb027e..e0e04e8 100644 --- a/pkg/protocol/slot/item_stack.go +++ b/pkg/protocol/slot/item_stack.go @@ -81,6 +81,14 @@ func (s *Slot) ReadFrom(r io.Reader) (n int64, err error) { if err != nil { return temp, err } + + removeLens := int32(0) + temp, err = (*pk.VarInt)(&removeLens).ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + var id int32 for i := int32(0); i < addLens; i++ { temp, err = (*pk.VarInt)(&id).ReadFrom(r) @@ -97,13 +105,6 @@ func (s *Slot) ReadFrom(r io.Reader) (n int64, err error) { } } - removeLens := int32(0) - temp, err = (*pk.VarInt)(&removeLens).ReadFrom(r) - n += temp - if err != nil { - return temp, err - } - for i := int32(0); i < removeLens; i++ { temp, err = (*pk.VarInt)(&id).ReadFrom(r) n += temp diff --git a/readme.md b/readme.md deleted file mode 100644 index e8922db..0000000 --- a/readme.md +++ /dev/null @@ -1,117 +0,0 @@ -# minego - -go-mc with command-line-only bot client. - -# 建議目錄結構 - -``` -minego/ -├─ cmd/ -│ ├─ minectl/ # 範例 CLI:連線、發包、抓封包 -│ │ └─ main.go -│ └─ proxy/ # 範例:簡易協議代理/抓包器 -│ └─ main.go -│ -├─ pkg/ # 對外公開 API(庫) -│ ├─ client/ # 高階 Client SDK(使用者只需要這個) -│ │ ├─ client.go # Client 對外介面、New(...)、Connect(...) -│ │ ├─ options.go # 可選項:代理、壓縮、密碼學、登入方式 -│ │ ├─ session.go # 與伺服器的一次連線(狀態機) -│ │ ├─ pipeline.go # 封包處理管線(decode -> route -> handler) -│ │ ├─ dispatcher.go # 事件/封包分發與訂閱 -│ │ ├─ keepalive.go -│ │ ├─ reconnect.go -│ │ └─ errors.go -│ │ -│ ├─ transport/ # 可替換傳輸層(TCP wrapper) -│ │ ├─ tcp/ -│ │ │ └─ conn.go -│ │ └─ transport.go # 抽象介面:Dial(ctx, addr) (Conn, error) -│ │ -│ ├─ auth/ # 登入/加密/密鑰交換(mojang、離線、自訂yggdrasil) -│ │ ├─ offline.go -│ │ ├─ mojang.go -│ │ └─ encrypt.go -│ │ -│ ├─ handler/ # 封包與事件處理(基於協議的 client 方向) -│ │ ├─ login.go -│ │ ├─ play_entities.go -│ │ ├─ play_world.go -│ │ ├─ chat.go -│ │ └─ registry.go # 封包 -> handler 的綁定註冊 -│ │ -│ ├─ game/ # 遊戲狀態(抽象,不與 GUI 綁死) -│ │ ├─ world/ -│ │ │ ├─ chunk.go -│ │ │ ├─ palette.go -│ │ │ └─ biome.go -│ │ ├─ entity/ -│ │ │ └─ entity.go -│ │ └─ inventory/ -│ │ └─ slots.go -│ │ -│ ├─ data/ # 協議資料&對照(版本表、映射、assets) -│ │ ├─ versions/ -│ │ │ └─ 1_21.json -│ │ └─ registries/ -│ │ └─ packets.json -│ │ -│ ├─ protocol/ # 你現有的 codec/packet/metadata 可移到這 -│ │ ├─ codec/… -│ │ ├─ packet/… -│ │ └─ nbt/… -│ │ -│ └─ util/ # 小工具:varint、zlib、pool、log -│ └─ … -│ -└─ go.mod -``` - -> 原則: -> -> * `pkg/` 對外公開、穩定 API;`internal/` 只給本專案使用。 -> * `protocol` 保持「與傳輸無關」;`transport` 抽象連線;`client` 串起狀態機與 handler。 -> * `handler` 專心處理「已解碼封包」到「遊戲狀態/事件」的映射。 -> * `game` 做資料模型(世界、實體、物品),不要直接依賴 UI。 - ---- - -# 模組邏輯切分(設計重點) - -1. **狀態機(State Machine)** - - * `Handshake -> Status/Login -> Play -> (Disconnected)` - * 在 `session.go` 以 goroutine + channel 管理讀寫,使用 `context.Context` 控制生命週期。 -2. **封包管線(Pipeline)** - - * `reader` 取得原始 bytes → `protocol/codec` 解碼 → `dispatcher` 依封包 ID 分派到 handler。 - * 可在管線節點插中介:壓縮、加密、記錄、度量。 -3. **事件導向 API** - - * 對外提供: - - ```go - type Client interface { - On(event Event, fn any) Unsub - Send(ctx context.Context, p protocol.Packet) error - State() client.State - } - ``` - * `On(PacketPlayChat, func(*ChatMessage){…})` 這種型別安全的註冊可以用泛型或介面實作。 -4. **錯誤與可觀測性** - - * 統一 `errors.go`;在 pipeline/handler 位置加可選的 `WithLogger / WithMetrics`。 - ---- - -# 命名與風格小訣竅 - -* 套件名短小、名詞為主:`client`, `auth`, `transport`, `handler`, `game`, `protocol`. -* 檔名以職責分組,不以每個封包獨立檔案(容易爆量難找)。 -* 對外只匯出 `pkg/client` 的型別;其餘盡量小寫封裝。 -* 盡量用 `context.Context`、`io.Reader/Writer` 介面做邊界。 - ---- - -> MCProtocol(新wiki.vg) https://minecraft.wiki/w/Java_Edition_protocol -> 使用套件: github.com/Tnze/go-mc \ No newline at end of file