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,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
}

View File

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

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type ProjectilePower struct {
EntityID int32
Power float64
}

View File

@ -0,0 +1,29 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/slot/display/recipe"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen
type RecipeIngredients struct {
Data []pk.IDSet
}
//codec:gen
type Recipe struct {
RecipeID int32 `mc:"VarInt"`
Display recipe.Display
GroupID int32 `mc:"VarInt"`
CategoryID int32 `mc:"VarInt"`
HasIngredients bool
//opt:optional:HasIngredients
Ingredients RecipeIngredients
Flags int8
}
//codec:gen
type RecipeBookAdd struct {
Recipes []Recipe
Replace bool
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type RecipeBookRemove struct {
Recipes []int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,12 @@
package client
//codec:gen
type RecipeBookSettings struct {
CraftingRecipeBookOpen bool
CraftingRecipeBookFilterEnabled bool
SmeltingRecipeBookOpen bool
SmeltingRecipeBookFilterEnabled bool
BlastingFurnaceRecipeBookOpen bool
SmokingRecipeBookOpen bool
SmokingRecipeBookFilterEnabled bool
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type RemoveEntities struct {
EntityIDs []int32 `mc:"VarInt"`
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type RemoveMobEffect struct {
EntityID int32
EffectID int32
}

View File

@ -0,0 +1,9 @@
package client
//codec:gen
type ResetScore struct {
EntityName string
HasObjectiveName bool
//opt:optional:HasObjectiveName
ObjectiveName string
}

View File

@ -0,0 +1,12 @@
package client
import (
"github.com/google/uuid"
)
//codec:gen
type RemoveResourcePack struct {
HasUUID bool
//opt:optional:HasUUID
UUID uuid.UUID `mc:"UUID"`
}

View File

@ -0,0 +1,17 @@
package client
import (
"github.com/Tnze/go-mc/chat"
"github.com/google/uuid"
)
//codec:gen
type AddResourcePack struct {
UUID uuid.UUID `mc:"UUID"`
URL string
Hash string
Forced bool
HasPromptMessage bool
//opt:optional:HasPromptMessage
PromptMessage chat.Message
}

View File

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

View File

@ -0,0 +1,9 @@
package client
import pk "github.com/Tnze/go-mc/net/packet"
//codec:gen
type SetHeadRotation struct {
EntityID int32 `mc:"VarInt"`
HeadYaw pk.Angle
}

View File

@ -0,0 +1,35 @@
package client
//codec:gen
type UpdateSectionsBlocks struct {
ChunkSectionPosition int64
Blocks []int64 `mc:"VarLong"`
}
func (s *UpdateSectionsBlocks) SetSectionPos(x, y, z int32) {
s.ChunkSectionPosition = ((int64(x) & 0x3FFFFF) << 42) | (int64(y) & 0xFFFFF) | ((int64(z) & 0x3FFFFF) << 20)
}
func (s UpdateSectionsBlocks) ToSectionPos() (x, y, z int32) {
sectionX := int32(s.ChunkSectionPosition >> 42)
sectionY := int32(s.ChunkSectionPosition << 44 >> 44)
sectionZ := int32(s.ChunkSectionPosition >> 22 >> 42)
return sectionX, sectionY, sectionZ
}
func (s *UpdateSectionsBlocks) AddBlock(x, y, z int, stateID int32) {
s.Blocks = append(s.Blocks, int64(stateID)<<12|(int64(x)<<8|int64(y)<<4|int64(z)))
}
func (s UpdateSectionsBlocks) ParseBlocks() map[[3]int32]int32 {
m := make(map[[3]int32]int32)
for _, block := range s.Blocks {
blockStateId := block >> 12
blockLocalX := (block >> 8) & 0xF
blockLocalY := block & 0xF
blockLocalZ := (block >> 4) & 0xF
m[[3]int32{int32(blockLocalX), int32(blockLocalY), int32(blockLocalZ)}] = int32(blockStateId)
}
return m
}

View File

@ -0,0 +1,8 @@
package client
//codec:gen
type SelectAdvancementsTab struct {
HasIdentifier bool
//opt:optional:HasIdentifier
Identifier string `mc:"Identifier"`
}

View File

@ -0,0 +1,13 @@
package client
import (
"github.com/Tnze/go-mc/chat"
)
//codec:gen
type ServerData struct {
MOTD chat.Message
HasIcon bool
//opt:optional:HasIcon
Icon []int8 `mc:"Byte"`
}

View File

@ -0,0 +1,18 @@
package client
import "github.com/Tnze/go-mc/chat"
//codec:gen
type ServerLinkData struct {
IsBuiltin bool
//opt:enum:IsBuiltin:true
Type int32 `mc:"VarInt"`
//opt:enum:IsBuiltin:false
Name chat.Message
URL string
}
//codec:gen
type ServerLinks struct {
Links []ServerLinkData
}

View File

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

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type SetBorderCenter struct {
X, Z float64
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type SetBorderLerpSize struct {
OldDiameter, NewDiameter float64
Speed int64 `mc:"VarLong"`
}

View File

@ -0,0 +1,6 @@
package client
//codec:gen
type SetBorderSize struct {
Diameter float64
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,10 @@
package client
import (
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
)
//codec:gen
type SetCursorItem struct {
CarriedItem slot.Slot
}

View File

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

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type DisplayObjective struct {
Position int32 `mc:"VarInt"`
ScoreName string
}

View File

@ -0,0 +1,11 @@
package client
import (
"git.konjactw.dev/patyhank/minego/codec/metadata"
)
//codec:gen
type SetEntityMetadata struct {
EntityID int32 `mc:"VarInt"`
Metadata metadata.EntityMetadata
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type SetEntityLink struct {
AttachedEntityID int32
HoldingEntityID int32 // leader, -1 to detach
}

View File

@ -0,0 +1,7 @@
package client
//codec:gen
type SetEntityVelocity struct {
EntityID int32 `mc:"VarInt"`
VelocityX, VelocityY, VelocityZ int16
}

View File

@ -0,0 +1,68 @@
package client
import (
"io"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
)
type EquipmentData struct {
Slot int8
Item slot.Slot
}
type Equipment []EquipmentData
func (e Equipment) WriteTo(w io.Writer) (n int64, err error) {
for i, equipment := range e {
b := equipment.Slot
if len(e)-1 == i {
b |= -128
}
n1, err := pk.Byte(b).WriteTo(w)
n += n1
if err != nil {
return n, err
}
n2, err := equipment.Item.WriteTo(w)
n += n2
if err != nil {
return n, err
}
}
return
}
func (e *Equipment) ReadFrom(r io.Reader) (n int64, err error) {
for {
var b pk.Byte
n1, err := b.ReadFrom(r)
n += n1
if err != nil {
return n, err
}
var equipment EquipmentData
equipment.Slot = int8(b & 127)
n2, err := equipment.Item.ReadFrom(r)
n += n2
if err != nil {
return n, err
}
*e = append(*e, equipment)
if n&-128 == 0 {
break
}
}
return
}
//codec:gen
type SetEquipment struct {
EntityID int32 `mc:"VarInt"`
Equipment
}

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