refactor package

This commit is contained in:
2025-08-22 05:14:59 +08:00
parent bec0a56a3d
commit 65690e51ab
371 changed files with 835 additions and 627 deletions

View File

@ -0,0 +1,17 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigClearDialog struct {
}
func (ConfigClearDialog) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigClearDialog
}
func init() {
registerPacket(packetid.ClientboundConfigClearDialog, func() ClientboundPacket {
return &ConfigClearDialog{}
})
}

View File

@ -0,0 +1,440 @@
// Code generated by github.com/go-mc/packetizer; DO NOT EDIT.
package client
import (
"errors"
"io"
"github.com/Tnze/go-mc/net/packet"
)
func (c *ConfigClearDialog) ReadFrom(r io.Reader) (n int64, err error) {
return 0, nil
}
func (c ConfigClearDialog) WriteTo(w io.Writer) (n int64, err error) {
return 0, nil
}
func (c *ConfigCookieRequest) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Key).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigCookieRequest) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Key).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigCustomPayload) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Channel).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.ByteArray)(&c.Data).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigCustomPayload) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Channel).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.ByteArray)(&c.Data).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigDisconnect) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (&c.Reason).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigDisconnect) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (&c.Reason).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigFinishConfiguration) ReadFrom(r io.Reader) (n int64, err error) {
return 0, nil
}
func (c ConfigFinishConfiguration) WriteTo(w io.Writer) (n int64, err error) {
return 0, nil
}
func (c *ConfigKeepAlive) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Long)(&c.ID).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigKeepAlive) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Long)(&c.ID).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigPing) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Int)(&c.ID).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigPing) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Int)(&c.ID).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *RegistryData) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Entry).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.Boolean)(&c.HasData).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
if c.HasData {
temp, err = packet.NBT(&c.Data).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
}
return n, err
}
func (c RegistryData) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Entry).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.Boolean)(&c.HasData).WriteTo(w)
n += temp
if err != nil {
return n, err
}
if c.HasData {
temp, err = packet.NBT(&c.Data).WriteTo(w)
n += temp
if err != nil {
return n, err
}
}
return n, err
}
func (c *ConfigRegistryData) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.RegistryID).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = packet.Array(&c.Data).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigRegistryData) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.RegistryID).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = packet.Array(&c.Data).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigResetChat) ReadFrom(r io.Reader) (n int64, err error) {
return 0, nil
}
func (c ConfigResetChat) WriteTo(w io.Writer) (n int64, err error) {
return 0, nil
}
func (c *KnownPack) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.String)(&c.Namespace).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.String)(&c.ID).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.String)(&c.Version).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c KnownPack) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.String)(&c.Namespace).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.String)(&c.ID).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.String)(&c.Version).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigSelectKnownPacks) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = packet.Array(&c.KnownPacks).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigSelectKnownPacks) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = packet.Array(&c.KnownPacks).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigStoreCookie) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Key).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = (*Int8VarIntArray)(&c.Payload).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigStoreCookie) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Key).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = (*Int8VarIntArray)(&c.Payload).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigTransfer) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.String)(&c.Host).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.VarInt)(&c.Port).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigTransfer) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.String)(&c.Host).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = (*packet.VarInt)(&c.Port).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigUpdateEnabledFeatures) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*StringIdentifierVarIntArray)(&c.Features).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigUpdateEnabledFeatures) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*StringIdentifierVarIntArray)(&c.Features).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
// StringIdentifierVarIntArray a utility type for encoding/decoding packet.Identifier -> string[packet.VarInt] slice.
type StringIdentifierVarIntArray []string
func (a StringIdentifierVarIntArray) 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.Identifier(a[i]).WriteTo(w)
n += nn
if err != nil {
return n, err
}
}
return n, nil
}
func (a *StringIdentifierVarIntArray) 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(StringIdentifierVarIntArray, int(size))
}
for i := 0; i < int(size); i++ {
nn, err = (*packet.Identifier)(&(*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
func (a Int8VarIntArray) 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 *Int8VarIntArray) 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(Int8VarIntArray, 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
}

View File

@ -0,0 +1,18 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigCookieRequest struct {
Key string `mc:"Identifier"`
}
func (ConfigCookieRequest) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigCookieRequest
}
func init() {
registerPacket(packetid.ClientboundConfigCookieRequest, func() ClientboundPacket {
return &ConfigCookieRequest{}
})
}

View File

@ -0,0 +1,19 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigCustomPayload struct {
Channel string `mc:"Identifier"`
Data []byte `mc:"ByteArray"`
}
func (ConfigCustomPayload) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigCustomPayload
}
func init() {
registerPacket(packetid.ClientboundConfigCustomPayload, func() ClientboundPacket {
return &ConfigCustomPayload{}
})
}

View File

@ -0,0 +1,20 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigCustomReportDetails struct {
client.CustomReportDetails
}
func (ConfigCustomReportDetails) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigCustomReportDetails
}
func init() {
registerPacket(packetid.ClientboundConfigCustomReportDetails, func() ClientboundPacket {
return &ConfigCustomReportDetails{}
})
}

View File

@ -0,0 +1,21 @@
package client
import (
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/data/packetid"
)
//codec:gen
type ConfigDisconnect struct {
Reason chat.Message
}
func (ConfigDisconnect) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigDisconnect
}
func init() {
registerPacket(packetid.ClientboundConfigDisconnect, func() ClientboundPacket {
return &ConfigDisconnect{}
})
}

View File

@ -0,0 +1,17 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigFinishConfiguration struct {
}
func (ConfigFinishConfiguration) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigFinishConfiguration
}
func init() {
registerPacket(packetid.ClientboundConfigFinishConfiguration, func() ClientboundPacket {
return &ConfigFinishConfiguration{}
})
}

View File

@ -0,0 +1,18 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigKeepAlive struct {
ID int64
}
func (ConfigKeepAlive) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigKeepAlive
}
func init() {
registerPacket(packetid.ClientboundConfigKeepAlive, func() ClientboundPacket {
return &ConfigKeepAlive{}
})
}

View File

@ -0,0 +1,19 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
type ClientboundPacket interface {
pk.Field
PacketID() packetid.ClientboundPacketID
}
type packetCreator func() ClientboundPacket
var packetRegistry = make(map[packetid.ClientboundPacketID]packetCreator)
func registerPacket(id packetid.ClientboundPacketID, creator packetCreator) {
packetRegistry[id] = creator
}

View File

@ -0,0 +1,18 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigPing struct {
ID int32
}
func (ConfigPing) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigPing
}
func init() {
registerPacket(packetid.ClientboundConfigPing, func() ClientboundPacket {
return &ConfigPing{}
})
}

View File

@ -0,0 +1,30 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/nbt"
)
//codec:gen
type RegistryData struct {
Entry string `mc:"Identifier"`
HasData bool
//opt:optional:HasData
Data nbt.RawMessage `mc:"NBT"`
}
//codec:gen
type ConfigRegistryData struct {
RegistryID string `mc:"Identifier"`
Data []RegistryData
}
func (ConfigRegistryData) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigRegistryData
}
func init() {
registerPacket(packetid.ClientboundConfigRegistryData, func() ClientboundPacket {
return &ConfigRegistryData{}
})
}

View File

@ -0,0 +1,17 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigResetChat struct {
}
func (ConfigResetChat) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigResetChat
}
func init() {
registerPacket(packetid.ClientboundConfigResetChat, func() ClientboundPacket {
return &ConfigResetChat{}
})
}

View File

@ -0,0 +1,20 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigResourcePackPop struct {
client.RemoveResourcePack
}
func (ConfigResourcePackPop) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigResourcePackPop
}
func init() {
registerPacket(packetid.ClientboundConfigResourcePackPop, func() ClientboundPacket {
return &ConfigResourcePackPop{}
})
}

View File

@ -0,0 +1,20 @@
package client
import (
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigResourcePackPush struct {
client.AddResourcePack
}
func (ConfigResourcePackPush) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigResourcePackPush
}
func init() {
registerPacket(packetid.ClientboundConfigResourcePackPush, func() ClientboundPacket {
return &ConfigResourcePackPush{}
})
}

View File

@ -0,0 +1,25 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type KnownPack struct {
Namespace string
ID string
Version string
}
//codec:gen
type ConfigSelectKnownPacks struct {
KnownPacks []KnownPack
}
func (ConfigSelectKnownPacks) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigSelectKnownPacks
}
func init() {
registerPacket(packetid.ClientboundConfigSelectKnownPacks, func() ClientboundPacket {
return &ConfigSelectKnownPacks{}
})
}

View File

@ -0,0 +1,20 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigServerLinks struct {
client.ServerLinks
}
func (ConfigServerLinks) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigServerLinks
}
func init() {
registerPacket(packetid.ClientboundConfigServerLinks, func() ClientboundPacket {
return &ConfigServerLinks{}
})
}

View File

@ -0,0 +1,20 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigShowDialog struct {
client.ShowDialog
}
func (ConfigShowDialog) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigShowDialog
}
func init() {
registerPacket(packetid.ClientboundConfigShowDialog, func() ClientboundPacket {
return &ConfigShowDialog{}
})
}

View File

@ -0,0 +1,19 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigStoreCookie struct {
Key string `mc:"Identifier"`
Payload []int8
}
func (ConfigStoreCookie) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigStoreCookie
}
func init() {
registerPacket(packetid.ClientboundConfigStoreCookie, func() ClientboundPacket {
return &ConfigStoreCookie{}
})
}

View File

@ -0,0 +1,19 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigTransfer struct {
Host string
Port int32 `mc:"VarInt"`
}
func (ConfigTransfer) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigTransfer
}
func init() {
registerPacket(packetid.ClientboundConfigTransfer, func() ClientboundPacket {
return &ConfigTransfer{}
})
}

View File

@ -0,0 +1,18 @@
package client
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigUpdateEnabledFeatures struct {
Features []string `mc:"Identifier"`
}
func (ConfigUpdateEnabledFeatures) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigUpdateEnabledFeatures
}
func init() {
registerPacket(packetid.ClientboundConfigUpdateEnabledFeatures, func() ClientboundPacket {
return &ConfigUpdateEnabledFeatures{}
})
}

View File

@ -0,0 +1,20 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigUpdateTags struct {
client.UpdateTags
}
func (ConfigUpdateTags) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundConfigUpdateTags
}
func init() {
registerPacket(packetid.ClientboundConfigUpdateTags, func() ClientboundPacket {
return &ConfigUpdateTags{}
})
}

View File

@ -0,0 +1,20 @@
package server
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigClientInformation struct {
server.ClientInformation
}
func (ConfigClientInformation) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigClientInformation
}
func init() {
registerPacket(packetid.ServerboundConfigClientInformation, func() ServerboundPacket {
return &ConfigClientInformation{}
})
}

View File

@ -0,0 +1,103 @@
// Code generated by github.com/go-mc/packetizer; DO NOT EDIT.
package server
import (
"io"
"github.com/Tnze/go-mc/net/packet"
)
func (c *ConfigCustomClickAction) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Action).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
temp, err = packet.NBT(&c.Data).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigCustomClickAction) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Identifier)(&c.Action).WriteTo(w)
n += temp
if err != nil {
return n, err
}
temp, err = packet.NBT(&c.Data).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigFinishConfiguration) ReadFrom(r io.Reader) (n int64, err error) {
return 0, nil
}
func (c ConfigFinishConfiguration) WriteTo(w io.Writer) (n int64, err error) {
return 0, nil
}
func (c *ConfigKeepAlive) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Long)(&c.ID).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigKeepAlive) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Long)(&c.ID).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigPong) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = (*packet.Int)(&c.ID).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigPong) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = (*packet.Int)(&c.ID).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c *ConfigSelectKnownPacks) ReadFrom(r io.Reader) (n int64, err error) {
var temp int64
temp, err = packet.Array(&c.Packs).ReadFrom(r)
n += temp
if err != nil {
return n, err
}
return n, err
}
func (c ConfigSelectKnownPacks) WriteTo(w io.Writer) (n int64, err error) {
var temp int64
temp, err = packet.Array(&c.Packs).WriteTo(w)
n += temp
if err != nil {
return n, err
}
return n, err
}

View File

@ -0,0 +1,20 @@
package server
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigCookieResponse struct {
server.CookieResponse
}
func (ConfigCookieResponse) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigCookieResponse
}
func init() {
registerPacket(packetid.ServerboundConfigCookieResponse, func() ServerboundPacket {
return &ConfigCookieResponse{}
})
}

View File

@ -0,0 +1,22 @@
package server
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/nbt"
)
//codec:gen
type ConfigCustomClickAction struct {
Action string `mc:"Identifier"`
Data nbt.RawMessage `mc:"NBT"`
}
func (ConfigCustomClickAction) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigCustomClickAction
}
func init() {
registerPacket(packetid.ServerboundConfigCustomClickAction, func() ServerboundPacket {
return &ConfigCustomClickAction{}
})
}

View File

@ -0,0 +1,20 @@
package server
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigCustomPayload struct {
server.CustomPayload
}
func (ConfigCustomPayload) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigCustomPayload
}
func init() {
registerPacket(packetid.ServerboundConfigCustomPayload, func() ServerboundPacket {
return &ConfigCustomPayload{}
})
}

View File

@ -0,0 +1,17 @@
package server
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigFinishConfiguration struct {
}
func (ConfigFinishConfiguration) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigFinishConfiguration
}
func init() {
registerPacket(packetid.ServerboundConfigFinishConfiguration, func() ServerboundPacket {
return &ConfigFinishConfiguration{}
})
}

View File

@ -0,0 +1,18 @@
package server
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigKeepAlive struct {
ID int64
}
func (ConfigKeepAlive) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigKeepAlive
}
func init() {
registerPacket(packetid.ServerboundConfigKeepAlive, func() ServerboundPacket {
return &ConfigKeepAlive{}
})
}

View File

@ -0,0 +1,19 @@
package server
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
type ServerboundPacket interface {
pk.Field
PacketID() packetid.ServerboundPacketID
}
type serverPacketCreator func() ServerboundPacket
var packetRegistry = make(map[packetid.ServerboundPacketID]serverPacketCreator)
func registerPacket(id packetid.ServerboundPacketID, creator serverPacketCreator) {
packetRegistry[id] = creator
}

View File

@ -0,0 +1,18 @@
package server
import "github.com/Tnze/go-mc/data/packetid"
//codec:gen
type ConfigPong struct {
ID int32
}
func (ConfigPong) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigPong
}
func init() {
registerPacket(packetid.ServerboundConfigPong, func() ServerboundPacket {
return &ConfigPong{}
})
}

View File

@ -0,0 +1,20 @@
package server
import (
"git.konjactw.dev/patyhank/minego/codec/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
)
type ConfigResourcePack struct {
server.ResourcePack
}
func (ConfigResourcePack) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigResourcePack
}
func init() {
registerPacket(packetid.ServerboundConfigResourcePack, func() ServerboundPacket {
return &ConfigResourcePack{}
})
}

View File

@ -0,0 +1,21 @@
package server
import (
"git.konjactw.dev/patyhank/minego/codec/packet/configuration/client"
"github.com/Tnze/go-mc/data/packetid"
)
//codec:gen
type ConfigSelectKnownPacks struct {
Packs []client.KnownPack
}
func (ConfigSelectKnownPacks) PacketID() packetid.ServerboundPacketID {
return packetid.ServerboundConfigSelectKnownPacks
}
func init() {
registerPacket(packetid.ServerboundConfigSelectKnownPacks, func() ServerboundPacket {
return &ConfigSelectKnownPacks{}
})
}

View File

@ -0,0 +1,26 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
"github.com/google/uuid"
)
var _ ClientboundPacket = (*AddEntity)(nil)
var _ packet.Field = (*AddEntity)(nil)
// AddEntityPacket
// codec:gen
type AddEntity struct {
ID int32 `mc:"VarInt"`
UUID uuid.UUID `mc:"UUID"`
Type int32 `mc:"VarInt"`
X, Y, Z float64
XRot, YRot, YHeadRot int8
Data int32 `mc:"VarInt"`
VelocityX, VelocityY, VelocityZ int16
}
func (AddEntity) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundAddEntity
}

View File

@ -0,0 +1,20 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*Animate)(nil)
var _ packet.Field = (*Animate)(nil)
// AnimatePacket
// codec:gen
type Animate struct {
EntityID int32 `mc:"VarInt"`
Action uint8
}
func (Animate) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundAnimate
}

View File

@ -0,0 +1,25 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
// codec:gen
type StatsData struct {
CategoryID int32 `mc:"VarInt"`
StatID int32 `mc:"VarInt"`
Value int32 `mc:"VarInt"`
}
var _ ClientboundPacket = (*AwardStats)(nil)
var _ packet.Field = (*AwardStats)(nil)
// codec:gen
type AwardStats struct {
Stats []StatsData
}
func (AwardStats) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundAwardStats
}

View File

@ -0,0 +1,16 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
)
var _ ClientboundPacket = (*BlockChangedAck)(nil)
// codec:gen
type BlockChangedAck struct {
Sequence int32 `mc:"VarInt"`
}
func (BlockChangedAck) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockChangedAck
}

View File

@ -0,0 +1,19 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*BlockDestruction)(nil)
// codec:gen
type BlockDestruction struct {
ID int32 `mc:"VarInt"`
Position packet.Position
Progress uint8
}
func (BlockDestruction) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockDestruction
}

View File

@ -0,0 +1,13 @@
package client
import (
"github.com/Tnze/go-mc/nbt"
"github.com/Tnze/go-mc/net/packet"
)
// codec:gen
type BlockEntityData struct {
Position packet.Position
Type int32 `mc:"VarInt"`
Data nbt.RawMessage `mc:"NBT"`
}

View File

@ -0,0 +1,18 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
// codec:gen
type BlockEvent struct {
Position packet.Position
EventType uint8
Data uint8
Block int32 `mc:"VarInt"`
}
func (BlockEvent) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockEvent
}

View File

@ -0,0 +1,16 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
// codec:gen
type BlockUpdate struct {
Position packet.Position
BlockState int32 `mc:"VarInt"`
}
func (BlockUpdate) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockUpdate
}

View File

@ -0,0 +1,163 @@
package client
import (
"io"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/google/uuid"
)
// codec:gen
type BossEvent struct {
UUID uuid.UUID `mc:"UUID"`
BossEventOp BossEventOperation
}
// codec:gen
type BossEventOpAdd struct {
Message chat.Message
Progress float32
Color int32 `mc:"VarInt"`
Overlay int32 `mc:"VarInt"`
Flags uint8
}
// codec:gen
type BossEventOpRemove struct {
}
// codec:gen
type BossEventOpUpdate struct {
Progress float32
}
// codec:gen
type BossEventOpUpdateName struct {
Message chat.Message
}
// codec:gen
type BossEventOpUpdateStyle struct {
Color int32 `mc:"VarInt"`
Overlay int32 `mc:"VarInt"`
}
// codec:gen
type BossEventOpUpdateProperties struct {
Flags uint8
}
type BossEventOperation struct {
Operation int32 `mc:"VarInt"`
OpData any
}
func (c *BossEventOperation) ReadFrom(r io.Reader) (int64, error) {
o, err := (*pk.VarInt)(&c.Operation).ReadFrom(r)
if err != nil {
return o, err
}
var i int64
switch c.Operation {
case 0:
var op BossEventOpAdd
i, err = op.ReadFrom(r)
if err != nil {
return i, err
}
c.OpData = &op
case 1:
var op BossEventOpRemove
i, err = op.ReadFrom(r)
if err != nil {
return i, err
}
c.OpData = &op
case 2:
var op BossEventOpUpdate
i, err = op.ReadFrom(r)
if err != nil {
return i, err
}
c.OpData = &op
case 3:
var op BossEventOpUpdateName
i, err = op.ReadFrom(r)
if err != nil {
return i, err
}
c.OpData = &op
case 4:
var op BossEventOpUpdateStyle
i, err = op.ReadFrom(r)
if err != nil {
return i, err
}
c.OpData = &op
case 5:
var op BossEventOpUpdateProperties
i, err = op.ReadFrom(r)
if err != nil {
return i, err
}
c.OpData = &op
}
return o + i, nil
}
func (c *BossEventOperation) WriteTo(w io.Writer) (int64, error) {
o, err := (*pk.VarInt)(&c.Operation).WriteTo(w)
if err != nil {
return o, err
}
switch c.Operation {
case 0:
op := c.OpData.(*BossEventOpAdd)
i, err := op.WriteTo(w)
if err != nil {
return o + i, err
}
return o + i, nil
case 1:
op := c.OpData.(*BossEventOpRemove)
i, err := op.WriteTo(w)
if err != nil {
return o + i, err
}
return o + i, nil
case 2:
op := c.OpData.(*BossEventOpUpdate)
i, err := op.WriteTo(w)
if err != nil {
return o + i, err
}
return o + i, nil
case 3:
op := c.OpData.(*BossEventOpUpdateName)
i, err := op.WriteTo(w)
if err != nil {
return o + i, err
}
return o + i, nil
case 4:
op := c.OpData.(*BossEventOpUpdateStyle)
i, err := op.WriteTo(w)
if err != nil {
return o + i, err
}
return o + i, nil
case 5:
op := c.OpData.(*BossEventOpUpdateProperties)
i, err := op.WriteTo(w)
if err != nil {
return o + i, err
}
return o + i, nil
}
return o, nil
}

View File

@ -0,0 +1,7 @@
package client
// BundleDelimiter
//
// codec:gen
type BundleDelimiter struct {
}

View File

@ -0,0 +1,7 @@
package client
// codec:gen
type ChangeDifficulty struct {
Difficulty []int8
Locked bool
}

View File

@ -0,0 +1,6 @@
package client
// codec:gen
type ChunkBatchFinished struct {
BatchSize int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,7 @@
package client
// ChunkBatchStartPacket
//
// codec:gen
type ChunkBatchStart struct {
}

View File

@ -0,0 +1,8 @@
package client
//codec:gen
type ChunkBiomes struct {
ChunkX int32
ChunkZ int32
Data []byte `mc:"ByteArray"`
}

View File

@ -0,0 +1,5 @@
package client
//codec:gen
type ClearDialog struct {
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type ClearTitles struct {
Reset bool
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type CloseContainer struct {
WindowID int32 `mc:"VarInt"`
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
package client
import (
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen
type CommandSuggestionsMatch struct {
Match string
Tooltip pk.Option[chat.Message, *chat.Message]
}
//codec:gen
type CommandSuggestions struct {
ID int32 `mc:"VarInt"`
Start int32 `mc:"VarInt"`
Length int32 `mc:"VarInt"`
Matches []CommandSuggestionsMatch
}

View File

@ -0,0 +1,9 @@
package client
import "github.com/Tnze/go-mc/server/command"
//codec:gen
type Commands struct {
Nodes []command.Node
RootIndex int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,13 @@
package client
import (
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
)
//codec:gen
type SetContainerContent struct {
WindowID int32 `mc:"VarInt"`
StateID int32 `mc:"VarInt"`
Slots []slot.Slot
CarriedItem slot.Slot
}

View File

@ -0,0 +1,22 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*ContainerSetData)(nil)
var _ packet.Field = (*ContainerSetData)(nil)
// ContainerSetDataPacket
//
//codec:gen
type ContainerSetData struct {
ContainerID int8
ID int16
Value int16
}
func (ContainerSetData) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundContainerSetData
}

View File

@ -0,0 +1,24 @@
package client
import (
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*ContainerSetSlot)(nil)
var _ packet.Field = (*ContainerSetSlot)(nil)
// ContainerSetSlotPacket
//
//codec:gen
type ContainerSetSlot struct {
ContainerID int32 `mc:"VarInt"`
StateID int32 `mc:"VarInt"`
Slot int16
ItemStack slot.Slot
}
func (ContainerSetSlot) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundContainerSetSlot
}

View File

@ -0,0 +1,8 @@
package client
import pk "github.com/Tnze/go-mc/net/packet"
//codec:gen
type CookieRequest struct {
Key pk.Identifier
}

View File

@ -0,0 +1,21 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*Cooldown)(nil)
var _ pk.Field = (*Cooldown)(nil)
// CooldownPacket
//
//codec:gen
type Cooldown struct {
CooldownGroup pk.Identifier `mc:"Identifier"`
Duration int32 `mc:"VarInt"`
}
func (Cooldown) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCooldown
}

View File

@ -0,0 +1,21 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*CustomChatCompletions)(nil)
var _ packet.Field = (*CustomChatCompletions)(nil)
// CustomChatCompletionsPacket
//
//codec:gen
type CustomChatCompletions struct {
Action int32 `mc:"VarInt"`
Entries []string
}
func (CustomChatCompletions) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCustomChatCompletions
}

View File

@ -0,0 +1,9 @@
package client
import pk "github.com/Tnze/go-mc/net/packet"
//codec:gen
type CustomPayload struct {
Channel pk.Identifier
Data []byte `mc:"ByteArray"`
}

View File

@ -0,0 +1,12 @@
package client
//codec:gen
type ReportDetails struct {
Title string
Description string
}
//codec:gen
type CustomReportDetails struct {
Details []ReportDetails
}

View File

@ -0,0 +1,29 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*DamageEvent)(nil)
var _ pk.Field = (*DamageEvent)(nil)
//codec:gen
type DamageEventPos struct {
X, Y, Z float64
}
// DamageEventPacket
//
//codec:gen
type DamageEvent struct {
EntityID int32 `mc:"VarInt"`
SourceType int32 `mc:"VarInt"`
SourceCauseID int32 `mc:"VarInt"`
SourceDirectID int32 `mc:"VarInt"`
SourcePos pk.Option[DamageEventPos, *DamageEventPos]
}
func (DamageEvent) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDamageEvent
}

View File

@ -0,0 +1,21 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*DebugSample)(nil)
var _ packet.Field = (*DebugSample)(nil)
// DebugSamplePacket
//
//codec:gen
type DebugSample struct {
Sample []int64
DebugSampleType int32 `mc:"VarInt"`
}
func (DebugSample) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDebugSample
}

View File

@ -0,0 +1,20 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*DeleteChat)(nil)
var _ packet.Field = (*DeleteChat)(nil)
// DeleteChatPacket
//
//codec:gen
type DeleteChat struct {
MessageSignature []byte `mc:"ByteArray"`
}
func (DeleteChat) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDeleteChat
}

View File

@ -0,0 +1,8 @@
package client
import "github.com/Tnze/go-mc/chat"
//codec:gen
type Disconnect struct {
Reason chat.Message
}

View File

@ -0,0 +1,22 @@
package client
import (
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*DisguisedChat)(nil)
var _ packet.Field = (*DisguisedChat)(nil)
// DisguisedChatPacket
//
//codec:gen
type DisguisedChat struct {
Message chat.Message
ChatType []byte `mc:"ByteArray"`
}
func (DisguisedChat) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDisguisedChat
}

View File

@ -0,0 +1,21 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*EntityEvent)(nil)
var _ packet.Field = (*EntityEvent)(nil)
// EntityEventPacket
//
//codec:gen
type EntityEvent struct {
EntityID int32
EventID int8
}
func (EntityEvent) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundEntityEvent
}

View File

@ -0,0 +1,10 @@
package client
//codec:gen
type TeleportEntity struct {
EntityID int32 `mc:"VarInt"`
X, Y, Z float64
VelocityX, VelocityY, VelocityZ float64
Yaw, Pitch float32
OnGround bool
}

View File

@ -0,0 +1,25 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*Explode)(nil)
//codec:gen
type Vec3 struct {
X, Y, Z float64
}
//codec:gen
type Explode struct {
CenterX float64
CenterY float64
CenterZ float64
PlayerKnockbackVelocity pk.Option[Vec3, *Vec3]
}
func (Explode) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundExplode
}

View File

@ -0,0 +1,21 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
)
var _ ClientboundPacket = (*ForgetLevelChunk)(nil)
//codec:gen
type ChunkPos struct {
X, Z int32
}
//codec:gen
type ForgetLevelChunk struct {
Pos ChunkPos
}
func (ForgetLevelChunk) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundForgetLevelChunk
}

View File

@ -0,0 +1,17 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
)
var _ ClientboundPacket = (*GameEvent)(nil)
//codec:gen
type GameEvent struct {
Event uint8
Param float32
}
func (GameEvent) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundGameEvent
}

View File

@ -0,0 +1,8 @@
package client
//codec:gen
type OpenHorseScreen struct {
WindowID int32 `mc:"VarInt"`
InventoryColumnsSize int32 `mc:"VarInt"`
EntityID int32
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type HurtAnimation struct {
EntityID int32 `mc:"VarInt"`
Yaw float32
}

View File

@ -0,0 +1,11 @@
package client
//codec:gen
type InitializeWorldBorder struct {
X, Z float64
OldDiameter, NewDiameter float64
Speed int64 `mc:"VarLong"`
PortalTeleportBoundary int32 `mc:"VarInt"`
WarningBlocks int32 `mc:"VarInt"`
WarningTime int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type KeepAlive struct {
ID int64
}

View File

@ -0,0 +1,12 @@
package client
import "github.com/Tnze/go-mc/level"
var _ ClientboundPacket = (*LevelChunkWithLight)(nil)
//codec:gen
type LevelChunkWithLight struct {
X int32
Z int32
Data level.Chunk
}

View File

@ -0,0 +1,20 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*LevelEvent)(nil)
//codec:gen
type LevelEvent struct {
Type int32
Pos pk.Position
Data int32
GlobalEvent bool
}
func (LevelEvent) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLevelEvent
}

View File

@ -0,0 +1,14 @@
package client
import "git.konjactw.dev/patyhank/minego/codec/particle"
//codec:gen
type Particle struct {
LongDistance bool
AlwaysVisible bool
X, Y, Z float64
OffsetX, OffsetY, OffsetZ float32
MaxSpeed float32
Count int32
Particle particle.Particle
}

View File

@ -0,0 +1,47 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
)
var _ ClientboundPacket = (*Login)(nil)
//codec:gen
type GlobalPos struct {
Dimension string `mc:"Identifier"`
Pos pk.Position
}
//codec:gen
type CommonPlayerSpawnInfo struct {
DimensionType int32 `mc:"VarInt"`
Dimension string `mc:"Identifier"`
Seed int64
GameType uint8
PreviousGameType int8
IsDebug bool
IsFlat bool
LastDeathLocation pk.Option[GlobalPos, *GlobalPos]
PortalCooldown int32 `mc:"VarInt"`
SeaLevel int32 `mc:"VarInt"`
}
//codec:gen
type Login struct {
PlayerID int32 `mc:"VarInt"`
Hardcore bool
Levels []string `mc:"Identifier"`
MaxPlayers int32 `mc:"VarInt"`
ChunkRadius int32 `mc:"VarInt"`
SimulationDistance int32 `mc:"VarInt"`
ReducedDebugInfo bool
ShowDeathScreen bool
DoLimitedCrafting bool
CommonPlayerSpawnInfo CommonPlayerSpawnInfo
EnforcesSecureChat bool
}
func (Login) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLogin
}

View File

@ -0,0 +1,57 @@
package client
import (
"io"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen
type MapIcon struct {
Type int32 `mc:"VarInt"`
X, Z int8
Direction int8
DisplayName pk.Option[chat.Message, *chat.Message]
}
type MapColorPatch struct {
Columns uint8
Rows uint8
X, Z uint8
Data []pk.UnsignedByte
}
func (c *MapColorPatch) ReadFrom(r io.Reader) (n int64, err error) {
t, err := (*pk.UnsignedByte)(&c.Columns).ReadFrom(r)
if err != nil {
return t, err
}
if c.Columns <= 0 {
return t, err
}
a, err := (*pk.UnsignedByte)(&c.Rows).ReadFrom(r)
b, err := (*pk.UnsignedByte)(&c.X).ReadFrom(r)
d, err := (*pk.UnsignedByte)(&c.Z).ReadFrom(r)
e, err := pk.Array(&c.Data).ReadFrom(r)
return t + a + b + d + e, err
}
func (c MapColorPatch) WriteTo(w io.Writer) (n int64, err error) {
n, err = pk.UnsignedByte(c.Columns).WriteTo(w)
if c.Columns <= 0 {
return n, err
}
n, err = pk.UnsignedByte(c.Rows).WriteTo(w)
n, err = pk.UnsignedByte(c.X).WriteTo(w)
n, err = pk.UnsignedByte(c.Z).WriteTo(w)
n, err = pk.Array(&c.Data).WriteTo(w)
return n, err
}
//codec:gen
type MapData struct {
MapID int32 `mc:"VarInt"`
Scale int8
Locked bool
}

View File

@ -0,0 +1,32 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/slot"
slot2 "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
)
//codec:gen
type TradeOption struct {
Input slot.TradeSlot
Output slot2.Slot
HasSecondInput bool
//opt:optional:HasSecondInput
SecondInput slot.TradeSlot
TradeDisabled bool
TradeUses int32
MaxTradeUses int32
Experience int32
SpecialPrice int32
PriceMultiplier float32
Demand int32
}
//codec:gen
type MerchantOffers struct {
WindowID int32 `mc:"VarInt"`
Offers []TradeOption
Level int32 `mc:"VarInt"`
Experience int32 `mc:"VarInt"`
IsRegular bool
CanRestock bool
}

View File

@ -0,0 +1,8 @@
package client
//codec:gen
type UpdateEntityPosition struct {
EntityID int32 `mc:"VarInt"`
DeltaX, DeltaY, DeltaZ int16
OnGround bool
}

View File

@ -0,0 +1,11 @@
package client
import pk "github.com/Tnze/go-mc/net/packet"
//codec:gen
type UpdateEntityPositionAndRotation struct {
EntityID int32 `mc:"VarInt"`
DeltaX, DeltaY, DeltaZ int16
Yaw, Pitch pk.Angle
OnGround bool
}

View File

@ -0,0 +1,8 @@
package client
//codec:gen
type UpdateEntityRotation struct {
EntityID int32 `mc:"VarInt"`
Yaw, Pitch float32
OnGround bool
}

View File

@ -0,0 +1,17 @@
package client
import pk "github.com/Tnze/go-mc/net/packet"
//codec:gen
type MinecartStep struct {
X, Y, Z float64
VelocityX, VelocityY, VelocityZ float64
Yaw, Pitch pk.Angle
Weight float32
}
//codec:gen
type MoveMinecartAlongTrack struct {
EntityID int32 `mc:"VarInt"`
Steps []MinecartStep
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type MoveVehicle struct {
X, Y, Z float64
Yaw, Pitch float32
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type OpenBook struct {
Hand int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,10 @@
package client
import "github.com/Tnze/go-mc/chat"
//codec:gen
type OpenScreen struct {
WindowID int32 `mc:"VarInt"`
WindowType int32 `mc:"VarInt"`
WindowTitle chat.Message
}

View File

@ -0,0 +1,9 @@
package client
import pk "github.com/Tnze/go-mc/net/packet"
//codec:gen
type OpenSignEditor struct {
Location pk.Position
Front bool
}

View File

@ -0,0 +1,816 @@
//codec:ignore
package client
import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
)
type ClientboundPacket interface {
packet.Field
PacketID() packetid.ClientboundPacketID
}
type clientBoundPacketCreator func() ClientboundPacket
var ClientboundPackets = make(map[packetid.ClientboundPacketID]clientBoundPacketCreator)
func init() {
registerPacket(func() ClientboundPacket {
return &AddEntity{}
})
registerPacket(func() ClientboundPacket {
return &Animate{}
})
registerPacket(func() ClientboundPacket {
return &AwardStats{}
})
registerPacket(func() ClientboundPacket {
return &BlockChangedAck{}
})
registerPacket(func() ClientboundPacket {
return &BlockDestruction{}
})
registerPacket(func() ClientboundPacket {
return &BlockEntityData{}
})
registerPacket(func() ClientboundPacket {
return &BlockEvent{}
})
registerPacket(func() ClientboundPacket {
return &BlockUpdate{}
})
registerPacket(func() ClientboundPacket {
return &BossEvent{}
})
registerPacket(func() ClientboundPacket {
return &ChangeDifficulty{}
})
registerPacket(func() ClientboundPacket {
return &ChunkBatchFinished{}
})
registerPacket(func() ClientboundPacket {
return &ChunkBatchStart{}
})
registerPacket(func() ClientboundPacket {
return &ChunkBiomes{}
})
registerPacket(func() ClientboundPacket {
return &ClearTitles{}
})
registerPacket(func() ClientboundPacket {
return &CommandSuggestions{}
})
registerPacket(func() ClientboundPacket {
return &Commands{}
})
registerPacket(func() ClientboundPacket {
return &CloseContainer{}
})
registerPacket(func() ClientboundPacket {
return &SetContainerContent{}
})
registerPacket(func() ClientboundPacket {
return &ContainerSetData{}
})
registerPacket(func() ClientboundPacket {
return &ContainerSetSlot{}
})
registerPacket(func() ClientboundPacket {
return &CookieRequest{}
})
registerPacket(func() ClientboundPacket {
return &Cooldown{}
})
registerPacket(func() ClientboundPacket {
return &CustomChatCompletions{}
})
registerPacket(func() ClientboundPacket {
return &CustomPayload{}
})
registerPacket(func() ClientboundPacket {
return &DamageEvent{}
})
registerPacket(func() ClientboundPacket {
return &DebugSample{}
})
registerPacket(func() ClientboundPacket {
return &DeleteChat{}
})
registerPacket(func() ClientboundPacket {
return &Disconnect{}
})
registerPacket(func() ClientboundPacket {
return &DisguisedChat{}
})
registerPacket(func() ClientboundPacket {
return &EntityEvent{}
})
registerPacket(func() ClientboundPacket {
return &TeleportEntity{}
})
registerPacket(func() ClientboundPacket {
return &Explode{}
})
registerPacket(func() ClientboundPacket {
return &ForgetLevelChunk{}
})
registerPacket(func() ClientboundPacket {
return &GameEvent{}
})
registerPacket(func() ClientboundPacket {
return &OpenHorseScreen{}
})
registerPacket(func() ClientboundPacket {
return &HurtAnimation{}
})
registerPacket(func() ClientboundPacket {
return &InitializeWorldBorder{}
})
registerPacket(func() ClientboundPacket {
return &KeepAlive{}
})
registerPacket(func() ClientboundPacket {
return &LevelChunkWithLight{}
})
registerPacket(func() ClientboundPacket {
return &LevelEvent{}
})
registerPacket(func() ClientboundPacket {
return &Particle{}
})
registerPacket(func() ClientboundPacket {
return &UpdateLight{}
})
registerPacket(func() ClientboundPacket {
return &Login{}
})
registerPacket(func() ClientboundPacket {
return &MapData{}
})
registerPacket(func() ClientboundPacket {
return &MerchantOffers{}
})
registerPacket(func() ClientboundPacket {
return &UpdateEntityPosition{}
})
registerPacket(func() ClientboundPacket {
return &UpdateEntityPositionAndRotation{}
})
registerPacket(func() ClientboundPacket {
return &MoveMinecartAlongTrack{}
})
registerPacket(func() ClientboundPacket {
return &UpdateEntityRotation{}
})
registerPacket(func() ClientboundPacket {
return &MoveVehicle{}
})
registerPacket(func() ClientboundPacket {
return &OpenBook{}
})
registerPacket(func() ClientboundPacket {
return &OpenScreen{}
})
registerPacket(func() ClientboundPacket {
return &OpenSignEditor{}
})
registerPacket(func() ClientboundPacket {
return &Ping{}
})
registerPacket(func() ClientboundPacket {
return &PingResponse{}
})
registerPacket(func() ClientboundPacket {
return &PlaceGhostRecipe{}
})
registerPacket(func() ClientboundPacket {
return &PlayerAbilities{}
})
registerPacket(func() ClientboundPacket {
return &EndCombat{}
})
registerPacket(func() ClientboundPacket {
return &EnterCombat{}
})
registerPacket(func() ClientboundPacket {
return &CombatDeath{}
})
registerPacket(func() ClientboundPacket {
return &PlayerInfoRemove{}
})
registerPacket(func() ClientboundPacket {
return &PlayerInfoUpdate{}
})
registerPacket(func() ClientboundPacket {
return &LookAt{}
})
registerPacket(func() ClientboundPacket {
return &PlayerPosition{}
})
registerPacket(func() ClientboundPacket {
return &PlayerRotation{}
})
registerPacket(func() ClientboundPacket {
return &RecipeBookAdd{}
})
registerPacket(func() ClientboundPacket {
return &RecipeBookRemove{}
})
registerPacket(func() ClientboundPacket {
return &RecipeBookSettings{}
})
registerPacket(func() ClientboundPacket {
return &RemoveEntities{}
})
registerPacket(func() ClientboundPacket {
return &RemoveMobEffect{}
})
registerPacket(func() ClientboundPacket {
return &ResetScore{}
})
registerPacket(func() ClientboundPacket {
return &AddResourcePack{}
})
registerPacket(func() ClientboundPacket {
return &RemoveResourcePack{}
})
registerPacket(func() ClientboundPacket {
return &Respawn{}
})
registerPacket(func() ClientboundPacket {
return &SetHeadRotation{}
})
registerPacket(func() ClientboundPacket {
return &UpdateSectionsBlocks{}
})
registerPacket(func() ClientboundPacket {
return &SelectAdvancementsTab{}
})
registerPacket(func() ClientboundPacket {
return &ServerData{}
})
registerPacket(func() ClientboundPacket {
return &SetActionBarText{}
})
registerPacket(func() ClientboundPacket {
return &SetBorderCenter{}
})
registerPacket(func() ClientboundPacket {
return &SetBorderLerpSize{}
})
registerPacket(func() ClientboundPacket {
return &SetBorderSize{}
})
registerPacket(func() ClientboundPacket {
return &SetBorderWarningDelay{}
})
registerPacket(func() ClientboundPacket {
return &SetBorderWarningDistance{}
})
registerPacket(func() ClientboundPacket {
return &SetCamera{}
})
registerPacket(func() ClientboundPacket {
return &SetCenterChunk{}
})
registerPacket(func() ClientboundPacket {
return &SetRenderDistance{}
})
registerPacket(func() ClientboundPacket {
return &SetCursorItem{}
})
registerPacket(func() ClientboundPacket {
return &SetDefaultSpawnPosition{}
})
registerPacket(func() ClientboundPacket {
return &DisplayObjective{}
})
registerPacket(func() ClientboundPacket {
return &SetEntityMetadata{}
})
registerPacket(func() ClientboundPacket {
return &SetEntityLink{}
})
registerPacket(func() ClientboundPacket {
return &SetEntityVelocity{}
})
registerPacket(func() ClientboundPacket {
return &SetEquipment{}
})
registerPacket(func() ClientboundPacket {
return &SetExperience{}
})
registerPacket(func() ClientboundPacket {
return &SetHealth{}
})
registerPacket(func() ClientboundPacket {
return &SetHeldItem{}
})
registerPacket(func() ClientboundPacket {
return &UpdateObjectives{}
})
registerPacket(func() ClientboundPacket {
return &SetPassengers{}
})
registerPacket(func() ClientboundPacket {
return &SetPlayerInventory{}
})
registerPacket(func() ClientboundPacket {
return &UpdateTeams{}
})
registerPacket(func() ClientboundPacket {
return &UpdateScore{}
})
registerPacket(func() ClientboundPacket {
return &SetSimulationDistance{}
})
registerPacket(func() ClientboundPacket {
return &SetSubtitleText{}
})
registerPacket(func() ClientboundPacket {
return &SetTime{}
})
registerPacket(func() ClientboundPacket {
return &SetTitleText{}
})
registerPacket(func() ClientboundPacket {
return &SetTitleAnimationTimes{}
})
registerPacket(func() ClientboundPacket {
return &EntitySoundEffect{}
})
registerPacket(func() ClientboundPacket {
return &SoundEffect{}
})
registerPacket(func() ClientboundPacket {
return &StartConfiguration{}
})
registerPacket(func() ClientboundPacket {
return &StopSound{}
})
registerPacket(func() ClientboundPacket {
return &StoreCookie{}
})
registerPacket(func() ClientboundPacket {
return &SystemChatMessage{}
})
registerPacket(func() ClientboundPacket {
return &SetTabListHeaderAndFooter{}
})
registerPacket(func() ClientboundPacket {
return &TagQueryResponse{}
})
registerPacket(func() ClientboundPacket {
return &PickupItem{}
})
registerPacket(func() ClientboundPacket {
return &SynchronizeVehiclePosition{}
})
registerPacket(func() ClientboundPacket {
return &TestInstanceBlockStatus{}
})
registerPacket(func() ClientboundPacket {
return &SetTickingState{}
})
registerPacket(func() ClientboundPacket {
return &StepTick{}
})
registerPacket(func() ClientboundPacket {
return &Transfer{}
})
registerPacket(func() ClientboundPacket {
return &UpdateAdvancements{}
})
registerPacket(func() ClientboundPacket {
return &UpdateAttributes{}
})
registerPacket(func() ClientboundPacket {
return &EntityEffect{}
})
registerPacket(func() ClientboundPacket {
return &UpdateRecipes{}
})
registerPacket(func() ClientboundPacket {
return &UpdateTags{}
})
registerPacket(func() ClientboundPacket {
return &ProjectilePower{}
})
registerPacket(func() ClientboundPacket {
return &CustomReportDetails{}
})
registerPacket(func() ClientboundPacket {
return &ServerLinks{}
})
registerPacket(func() ClientboundPacket {
return &Waypoint{}
})
registerPacket(func() ClientboundPacket {
return &ClearDialog{}
})
registerPacket(func() ClientboundPacket {
return &ShowDialog{}
})
}
func registerPacket(creator clientBoundPacketCreator) {
ClientboundPackets[creator().PacketID()] = creator
}
func (AddEntity) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundAddEntity
}
func (Animate) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundAnimate
}
func (AwardStats) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundAwardStats
}
func (BlockChangedAck) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockChangedAck
}
func (BlockDestruction) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockDestruction
}
func (BlockEntityData) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockEntityData
}
func (BlockEvent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockEvent
}
func (BlockUpdate) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBlockUpdate
}
func (BossEvent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundBossEvent
}
func (ChangeDifficulty) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundChangeDifficulty
}
func (ChunkBatchFinished) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundChunkBatchFinished
}
func (ChunkBatchStart) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundChunkBatchStart
}
func (ChunkBiomes) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundChunksBiomes
}
func (ClearTitles) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundClearTitles
}
func (CommandSuggestions) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCommandSuggestions
}
func (Commands) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCommands
}
func (CloseContainer) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundContainerClose
}
func (SetContainerContent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundContainerSetContent
}
func (ContainerSetData) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundContainerSetData
}
func (ContainerSetSlot) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundContainerSetSlot
}
func (CookieRequest) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCookieRequest
}
func (Cooldown) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCooldown
}
func (CustomChatCompletions) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCustomChatCompletions
}
func (CustomPayload) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCustomPayload
}
func (DamageEvent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDamageEvent
}
func (DebugSample) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDebugSample
}
func (DeleteChat) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDeleteChat
}
func (Disconnect) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDisconnect
}
func (DisguisedChat) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundDisguisedChat
}
func (EntityEvent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundEntityEvent
}
func (TeleportEntity) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundEntityPositionSync
}
func (Explode) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundExplode
}
func (ForgetLevelChunk) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundForgetLevelChunk
}
func (GameEvent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundGameEvent
}
func (OpenHorseScreen) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundHorseScreenOpen
}
func (HurtAnimation) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundHurtAnimation
}
func (InitializeWorldBorder) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundInitializeBorder
}
func (KeepAlive) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundKeepAlive
}
func (LevelChunkWithLight) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLevelChunkWithLight
}
func (LevelEvent) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLevelEvent
}
func (Particle) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLevelParticles
}
func (UpdateLight) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLightUpdate
}
func (Login) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundLogin
}
func (MapData) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMapItemData
}
func (MerchantOffers) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMerchantOffers
}
func (UpdateEntityPosition) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMoveEntityPos
}
func (UpdateEntityPositionAndRotation) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMoveEntityPosRot
}
func (MoveMinecartAlongTrack) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMoveMinecartAlongTrack
}
func (UpdateEntityRotation) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMoveEntityRot
}
func (MoveVehicle) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundMoveVehicle
}
func (OpenBook) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundOpenBook
}
func (OpenScreen) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundOpenScreen
}
func (OpenSignEditor) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundOpenSignEditor
}
func (Ping) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPing
}
func (PingResponse) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPongResponse
}
func (PlaceGhostRecipe) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlaceGhostRecipe
}
func (PlayerAbilities) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerAbilities
}
func (EndCombat) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerCombatEnd
}
func (EnterCombat) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerCombatEnter
}
func (CombatDeath) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerCombatKill
}
func (PlayerInfoRemove) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerInfoRemove
}
func (PlayerInfoUpdate) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerInfoUpdate
}
func (LookAt) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerLookAt
}
func (PlayerPosition) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerPosition
}
func (PlayerRotation) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerRotation
}
func (RecipeBookAdd) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRecipeBookAdd
}
func (RecipeBookRemove) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRecipeBookRemove
}
func (RecipeBookSettings) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRecipeBookSettings
}
func (RemoveEntities) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRemoveEntities
}
func (RemoveMobEffect) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRemoveMobEffect
}
func (ResetScore) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundResetScore
}
func (AddResourcePack) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundResourcePackPop
}
func (RemoveResourcePack) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundResourcePackPush
}
func (Respawn) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRespawn
}
func (SetHeadRotation) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundRotateHead
}
func (UpdateSectionsBlocks) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSectionBlocksUpdate
}
func (SelectAdvancementsTab) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSelectAdvancementsTab
}
func (ServerData) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundServerData
}
func (SetActionBarText) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetActionBarText
}
func (SetBorderCenter) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetBorderCenter
}
func (SetBorderLerpSize) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetBorderLerpSize
}
func (SetBorderSize) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetBorderSize
}
func (SetBorderWarningDelay) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetBorderWarningDelay
}
func (SetBorderWarningDistance) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetBorderWarningDistance
}
func (SetCamera) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetCamera
}
func (SetCenterChunk) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetChunkCacheCenter
}
func (SetRenderDistance) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetChunkCacheRadius
}
func (SetCursorItem) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetCursorItem
}
func (SetDefaultSpawnPosition) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetDefaultSpawnPosition
}
func (DisplayObjective) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetDisplayObjective
}
func (SetEntityMetadata) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetEntityData
}
func (SetEntityLink) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetEntityLink
}
func (SetEntityVelocity) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetEntityMotion
}
func (SetEquipment) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetEquipment
}
func (SetExperience) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetExperience
}
func (SetHealth) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetHealth
}
func (SetHeldItem) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetHeldSlot
}
func (UpdateObjectives) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetObjective
}
func (SetPassengers) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetPassengers
}
func (SetPlayerInventory) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetPlayerInventory
}
func (UpdateTeams) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetPlayerTeam
}
func (UpdateScore) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetScore
}
func (SetSimulationDistance) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetSimulationDistance
}
func (SetSubtitleText) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetSubtitleText
}
func (SetTime) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetTime
}
func (SetTitleText) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetTitleText
}
func (SetTitleAnimationTimes) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSetTitlesAnimation
}
func (EntitySoundEffect) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSoundEntity
}
func (SoundEffect) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSound
}
func (StartConfiguration) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundStartConfiguration
}
func (StopSound) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundStopSound
}
func (StoreCookie) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundStoreCookie
}
func (SystemChatMessage) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundSystemChat
}
func (SetTabListHeaderAndFooter) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTabList
}
func (TagQueryResponse) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTagQuery
}
func (PickupItem) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTakeItemEntity
}
func (SynchronizeVehiclePosition) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTeleportEntity
}
func (TestInstanceBlockStatus) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTestInstanceBlockStatus
}
func (SetTickingState) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTickingState
}
func (StepTick) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTickingStep
}
func (Transfer) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundTransfer
}
func (UpdateAdvancements) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundUpdateAdvancements
}
func (UpdateAttributes) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundUpdateAttributes
}
func (EntityEffect) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundUpdateMobEffect
}
func (UpdateRecipes) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundUpdateRecipes
}
func (UpdateTags) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundUpdateTags
}
func (ProjectilePower) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundProjectilePower
}
func (CustomReportDetails) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundCustomReportDetails
}
func (ServerLinks) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundServerLinks
}
func (Waypoint) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundWaypoint
}
func (ClearDialog) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundClearDialog
}
func (ShowDialog) PacketID() packetid.ClientboundPacketID {
return packetid.ClientboundShowDialog
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type Ping struct {
ID int32
}

View File

@ -0,0 +1,9 @@
package client
import "git.konjactw.dev/patyhank/minego/codec/slot/display/recipe"
//codec:gen
type PlaceGhostRecipe struct {
WindowID int32 `mc:"VarInt"`
RecipeDisplay recipe.Display
}

View File

@ -0,0 +1,18 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
)
var _ ClientboundPacket = (*PlayerAbilities)(nil)
//codec:gen
type PlayerAbilities struct {
Flags int8
FlyingSpeed float32
WalkingSpeed float32
}
func (PlayerAbilities) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerAbilities
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type EndCombat struct {
Duration int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,5 @@
package client
//codec:gen
type EnterCombat struct {
}

View File

@ -0,0 +1,9 @@
package client
import "github.com/Tnze/go-mc/chat"
//codec:gen
type CombatDeath struct {
PlayerID int32 `mc:"VarInt"`
Message chat.Message
}

View File

@ -0,0 +1,10 @@
package client
import (
"github.com/google/uuid"
)
//codec:gen
type PlayerInfoRemove struct {
UUIDs []uuid.UUID `mc:"UUID"`
}

View File

@ -0,0 +1,225 @@
package client
import (
"io"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/chat/sign"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/Tnze/go-mc/yggdrasil/user"
"github.com/google/uuid"
)
type PlayerInfo interface {
pk.Field
playerInfoBitMask() int
}
type PlayerInfoUpdate struct {
Players map[uuid.UUID][]PlayerInfo
}
func (p PlayerInfoUpdate) WriteTo(w io.Writer) (n int64, err error) {
bitset := pk.NewFixedBitSet(8)
for _, infos := range p.Players {
for _, info := range infos {
bitset.Set(info.playerInfoBitMask(), true)
}
}
n1, err := bitset.WriteTo(w)
if err != nil {
return n1, err
}
n += n1
n2, err := pk.VarInt(len(p.Players)).WriteTo(w)
if err != nil {
return n1 + n2, err
}
n += n2
for playerUUID, infos := range p.Players {
n3, err := (*pk.UUID)(&playerUUID).WriteTo(w)
if err != nil {
return n1 + n2 + n3, err
}
n += n3
for _, info := range infos {
n4, err := info.WriteTo(w)
if err != nil {
return n1 + n2 + n3 + n4, err
}
n += n4
}
}
return
}
func (p *PlayerInfoUpdate) ReadFrom(r io.Reader) (n int64, err error) {
bitset := pk.NewFixedBitSet(8)
n1, err := bitset.ReadFrom(r)
if err != nil {
return n1, err
}
m := make(map[uuid.UUID][]PlayerInfo)
var playerLens pk.VarInt
n2, err := playerLens.ReadFrom(r)
if err != nil {
return n1 + n2, err
}
for i := 0; i < int(playerLens); i++ {
var playerUUID uuid.UUID
n3, err := (*pk.UUID)(&playerUUID).ReadFrom(r)
if err != nil {
return n1 + n2 + n3, err
}
var temp int64
var infos []PlayerInfo
if bitset.Get(0x01) {
n4, err := playerInfoRead(&infos, &PlayerInfoAddPlayer{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x02) {
n4, err := playerInfoRead(&infos, &PlayerInfoInitializeChat{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x04) {
n4, err := playerInfoRead(&infos, &PlayerInfoUpdateGameMode{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x08) {
n4, err := playerInfoRead(&infos, &PlayerInfoUpdateListed{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x10) {
n4, err := playerInfoRead(&infos, &PlayerInfoUpdateLatency{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x20) {
n4, err := playerInfoRead(&infos, &PlayerInfoUpdateDisplayName{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x40) {
n4, err := playerInfoRead(&infos, &PlayerInfoUpdateListPriority{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
if bitset.Get(0x80) {
n4, err := playerInfoRead(&infos, &PlayerInfoUpdateHat{}, r)
if err != nil {
return n1 + n2 + n3 + n4, err
}
temp += n4
}
m[playerUUID] = infos
}
return
}
func playerInfoRead(infos *[]PlayerInfo, info PlayerInfo, r io.Reader) (int64, error) {
n, err := info.ReadFrom(r)
if err != nil {
return n, err
}
*infos = append(*infos, info)
return n, err
}
//codec:gen
type PlayerInfoAddPlayer struct {
Name string
Properties []user.Property
}
//codec:gen
type PlayerInfoChatData struct {
ChatSessionID uuid.UUID `mc:"UUID"`
Session sign.Session
}
//codec:gen
type PlayerInfoInitializeChat struct {
Data pk.Option[PlayerInfoChatData, *PlayerInfoChatData]
}
//codec:gen
type PlayerInfoUpdateGameMode struct {
GameMode int32 `mc:"VarInt"`
}
//codec:gen
type PlayerInfoUpdateListed struct {
Listed bool
}
//codec:gen
type PlayerInfoUpdateLatency struct {
Ping int32 `mc:"VarInt"`
}
//codec:gen
type PlayerInfoUpdateDisplayName struct {
DisplayName pk.Option[chat.Message, *chat.Message]
}
//codec:gen
type PlayerInfoUpdateListPriority struct {
Priority int32 `mc:"VarInt"`
}
//codec:gen
type PlayerInfoUpdateHat struct {
Visible bool
}
func (PlayerInfoAddPlayer) playerInfoBitMask() int {
return 0x01
}
func (PlayerInfoInitializeChat) playerInfoBitMask() int {
return 0x02
}
func (PlayerInfoUpdateGameMode) playerInfoBitMask() int {
return 0x04
}
func (PlayerInfoUpdateListed) playerInfoBitMask() int {
return 0x08
}
func (PlayerInfoUpdateLatency) playerInfoBitMask() int {
return 0x10
}
func (PlayerInfoUpdateDisplayName) playerInfoBitMask() int {
return 0x20
}
func (PlayerInfoUpdateListPriority) playerInfoBitMask() int {
return 0x40
}
func (PlayerInfoUpdateHat) playerInfoBitMask() int {
return 0x80
}

View File

@ -0,0 +1,16 @@
package client
//codec:gen
type LookedAtEntity struct {
EntityID int32 `mc:"VarInt"`
LookType int32 `mc:"VarInt"`
}
//codec:gen
type LookAt struct {
LookType int32 `mc:"VarInt"` // Feet = 0 Eyes = 1
TargetX, TargetY, TargetZ float64
HasLookedAtEntity bool
//opt:optional:HasLookedAtEntity
LookedAtEntity *LookedAtEntity
}

View File

@ -0,0 +1,20 @@
package client
import (
"github.com/Tnze/go-mc/data/packetid"
)
var _ ClientboundPacket = (*PlayerPosition)(nil)
//codec:gen
type PlayerPosition struct {
ID int32 `mc:"VarInt"`
X, Y, Z float64
VelocityX, VelocityY, VelocityZ float64
YRot, XRot float32
Flags int32
}
func (PlayerPosition) ClientboundPacketID() packetid.ClientboundPacketID {
return packetid.ClientboundPlayerPosition
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type PlayerRotation struct {
Yaw float32
Pitch float32
}

Some files were not shown because too many files have changed in this diff Show More