fixup codes

This commit is contained in:
2025-08-26 12:06:00 +08:00
committed by 蒟蒻
parent 093fdaaecf
commit 9ae126c648
252 changed files with 627 additions and 369 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"kiroAgent.configureMCP": "Disabled"
}

9
go.mod
View File

@ -5,12 +5,13 @@ go 1.24.0
toolchain go1.24.4 toolchain go1.24.4
require ( require (
github.com/Tnze/go-mc v1.20.3-0.20241224032005-539b4a3a7f03
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476
golang.org/x/sync v0.16.0 golang.org/x/sync v0.16.0
) )
require github.com/go-gl/mathgl v1.2.0 require (
git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826135316-7b60edc24881
replace github.com/Tnze/go-mc v1.20.3-0.20241224032005-539b4a3a7f03 => git.konjactw.dev/falloutBot/go-mc v0.0.0-20250823092154-f0bb92bdb98a github.com/go-gl/mathgl v1.2.0
golang.org/x/net v0.43.0
)

10
go.sum
View File

@ -1,12 +1,14 @@
git.konjactw.dev/falloutBot/go-mc v0.0.0-20250823092154-f0bb92bdb98a h1:M/FJZNEoOLsf/x5mscvCCYLfkOdSUYZvbGwHqPQOB/U= git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826114052-b9763dbf8c9f h1:U7Ay0O+6w/3shRUCilTz5idjMJ9pfHBg6bLTUKwqbU0=
git.konjactw.dev/falloutBot/go-mc v0.0.0-20250823092154-f0bb92bdb98a/go.mod h1:e3pBU8tqRfYDHrhtZRtyfGdYijA86b1fF3XgnEDSgHk= git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826114052-b9763dbf8c9f/go.mod h1:/KAQOP2x0pA8xEQuNkQa4d1TMKoyfLvUKmFqUJ8keDc=
git.konjactw.dev/patyhank/go-mc v1.20.3-0.20250619063151-133e3fab4ac2 h1:KiA1OsQQGjrKxev45URJPwvyuVwen9Bb4TzjEg/ojz8= git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826135316-7b60edc24881 h1:4kwONJ/u4HvLS1zTfid+NXc+3MkAceiLlwLwAzCoXh4=
git.konjactw.dev/patyhank/go-mc v1.20.3-0.20250619063151-133e3fab4ac2/go.mod h1:e3pBU8tqRfYDHrhtZRtyfGdYijA86b1fF3XgnEDSgHk= git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826135316-7b60edc24881/go.mod h1:/KAQOP2x0pA8xEQuNkQa4d1TMKoyfLvUKmFqUJ8keDc=
github.com/go-gl/mathgl v1.2.0 h1:v2eOj/y1B2afDxF6URV1qCYmo1KW08lAMtTbOn3KXCY= github.com/go-gl/mathgl v1.2.0 h1:v2eOj/y1B2afDxF6URV1qCYmo1KW08lAMtTbOn3KXCY=
github.com/go-gl/mathgl v1.2.0/go.mod h1:pf9+b5J3LFP7iZ4XXaVzZrCle0Q/vNpB/vDe5+3ulRE= github.com/go-gl/mathgl v1.2.0/go.mod h1:pf9+b5J3LFP7iZ4XXaVzZrCle0Q/vNpB/vDe5+3ulRE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4= golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4=
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=

View File

@ -19,14 +19,16 @@ import (
"strings" "strings"
"time" "time"
"github.com/google/uuid"
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/falloutBot/go-mc/net"
"git.konjactw.dev/falloutBot/go-mc/net/CFB8"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/login/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/login/client"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/login/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/login/server"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net"
"github.com/Tnze/go-mc/net/CFB8"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/google/uuid"
) )
var ( var (

View File

@ -25,6 +25,14 @@ type ClientOptions struct {
AuthProvider auth.Provider AuthProvider auth.Provider
} }
type ConnectOptions struct { type ProxyConfig struct {
FakeHost string Type string `json:"type" toml:"type"`
Host string `json:"host" toml:"host"`
Username string `json:"username" toml:"username"`
Password string `json:"password" toml:"password"`
}
type ConnectOptions struct {
FakeHost string `json:"fake_host,omitempty" toml:"fake_host,omitempty"`
Proxy *ProxyConfig `json:"proxy,omitempty" toml:"proxy,omitempty"`
} }

View File

@ -3,12 +3,15 @@ package bot
import ( import (
"context" "context"
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type PacketHandler interface { type PacketHandler interface {
AddPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p client.ClientboundPacket)) AddPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p client.ClientboundPacket))
AddRawPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p packet.Packet))
AddGenericPacketHandler(handler func(ctx context.Context, p client.ClientboundPacket)) AddGenericPacketHandler(handler func(ctx context.Context, p client.ClientboundPacket))
HandlePacket(ctx context.Context, p client.ClientboundPacket) HandlePacket(ctx context.Context, p client.ClientboundPacket)
} }

View File

@ -1,8 +1,9 @@
package bot package bot
import ( import (
"git.konjactw.dev/falloutBot/go-mc/level/item"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/level/item"
) )
type Container interface { type Container interface {

View File

@ -1,8 +1,9 @@
package bot package bot
import ( import (
"git.konjactw.dev/patyhank/minego/pkg/protocol"
"github.com/go-gl/mathgl/mgl64" "github.com/go-gl/mathgl/mgl64"
"git.konjactw.dev/patyhank/minego/pkg/protocol"
) )
type Player interface { type Player interface {
@ -13,6 +14,7 @@ type Player interface {
FlyTo(pos mgl64.Vec3) error FlyTo(pos mgl64.Vec3) error
WalkTo(pos mgl64.Vec3) error WalkTo(pos mgl64.Vec3) error
LookAt(vec3 mgl64.Vec3) error LookAt(vec3 mgl64.Vec3) error
UpdateLocation()
BreakBlock(pos protocol.Position) error BreakBlock(pos protocol.Position) error
PlaceBlock(pos protocol.Position) error PlaceBlock(pos protocol.Position) error
@ -22,4 +24,7 @@ type Player interface {
UseItem(hand int8) error UseItem(hand int8) error
OpenMenu(command string) (Container, error) OpenMenu(command string) (Container, error)
Command(command string) error
Chat(message string) error
CheckServer()
} }

View File

@ -1,13 +1,15 @@
package bot package bot
import ( import (
"github.com/go-gl/mathgl/mgl64"
"github.com/google/uuid"
"git.konjactw.dev/falloutBot/go-mc/data/entity"
"git.konjactw.dev/falloutBot/go-mc/level/block"
"git.konjactw.dev/patyhank/minego/pkg/protocol" "git.konjactw.dev/patyhank/minego/pkg/protocol"
"git.konjactw.dev/patyhank/minego/pkg/protocol/metadata" "git.konjactw.dev/patyhank/minego/pkg/protocol/metadata"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/data/entity"
"github.com/Tnze/go-mc/level/block"
"github.com/go-gl/mathgl/mgl64"
"github.com/google/uuid"
) )
type World interface { type World interface {
@ -32,4 +34,7 @@ type Entity interface {
Metadata() map[uint8]metadata.Metadata Metadata() map[uint8]metadata.Metadata
Equipment() map[int8]slot.Slot Equipment() map[int8]slot.Slot
SetPosition(pos mgl64.Vec3)
SetRotation(rot mgl64.Vec2)
} }

View File

@ -7,6 +7,12 @@ import (
"net" "net"
"strconv" "strconv"
"golang.org/x/sync/errgroup"
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
mcnet "git.konjactw.dev/falloutBot/go-mc/net"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/auth" "git.konjactw.dev/patyhank/minego/pkg/auth"
"git.konjactw.dev/patyhank/minego/pkg/bot" "git.konjactw.dev/patyhank/minego/pkg/bot"
"git.konjactw.dev/patyhank/minego/pkg/game/inventory" "git.konjactw.dev/patyhank/minego/pkg/game/inventory"
@ -14,15 +20,11 @@ import (
"git.konjactw.dev/patyhank/minego/pkg/game/world" "git.konjactw.dev/patyhank/minego/pkg/game/world"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
mcnet "github.com/Tnze/go-mc/net"
pk "github.com/Tnze/go-mc/net/packet"
"golang.org/x/sync/errgroup"
) )
type botClient struct { type botClient struct {
conn *mcnet.Conn conn *mcnet.Conn
packetHandler bot.PacketHandler packetHandler *packetHandler
eventHandler bot.EventHandler eventHandler bot.EventHandler
connected bool connected bool
authProvider auth.Provider authProvider auth.Provider
@ -91,7 +93,13 @@ func (b *botClient) Connect(ctx context.Context, addr string, options *bot.Conne
} }
} }
dialer := &mcnet.DefaultDialer var dialer mcnet.MCDialer = &mcnet.DefaultDialer
if options != nil && options.Proxy != nil {
dialer, err = socks5(options.Proxy)
if err != nil {
return err
}
}
b.conn, err = dialer.DialMCContext(ctx, addr) b.conn, err = dialer.DialMCContext(ctx, addr)
if err != nil { if err != nil {
return err return err
@ -156,6 +164,15 @@ func (b *botClient) handlePackets(ctx context.Context) error {
} }
continue continue
} }
hs, ok := b.packetHandler.rawMap[pktID]
for _, h := range hs {
group.Go(func() error {
h(ctx, p)
return nil
})
}
creator, ok := client.ClientboundPackets[pktID] creator, ok := client.ClientboundPackets[pktID]
if !ok { if !ok {
continue continue
@ -163,12 +180,10 @@ func (b *botClient) handlePackets(ctx context.Context) error {
pkt := creator() pkt := creator()
_, err := pkt.ReadFrom(bytes.NewReader(p.Data)) _, err := pkt.ReadFrom(bytes.NewReader(p.Data))
if err != nil { if err != nil {
// fmt.Printf("Decoding: 0x%x %s %s\n", p.ID, pktID.String(), err.Error())
continue continue
} }
group.Go(func() error { b.packetHandler.HandlePacket(ctx, pkt)
b.packetHandler.HandlePacket(ctx, pkt)
return nil
})
} }
} }
} }

View File

@ -5,10 +5,11 @@ import (
"errors" "errors"
"time" "time"
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/auth" "git.konjactw.dev/patyhank/minego/pkg/auth"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet"
) )
func (b *botClient) login() error { func (b *botClient) login() error {

View File

@ -3,20 +3,23 @@ package client
import ( import (
"context" "context"
"git.konjactw.dev/patyhank/minego/pkg/bot" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
func newPacketHandler() bot.PacketHandler { func newPacketHandler() *packetHandler {
return &packetHandler{ return &packetHandler{
handlerMap: make(map[packetid.ClientboundPacketID][]func(ctx context.Context, p client.ClientboundPacket)), handlerMap: make(map[packetid.ClientboundPacketID][]func(ctx context.Context, p client.ClientboundPacket)),
rawMap: make(map[packetid.ClientboundPacketID][]func(ctx context.Context, p pk.Packet)),
} }
} }
type packetHandler struct { type packetHandler struct {
handlerMap map[packetid.ClientboundPacketID][]func(ctx context.Context, p client.ClientboundPacket) handlerMap map[packetid.ClientboundPacketID][]func(ctx context.Context, p client.ClientboundPacket)
genericMap []func(ctx context.Context, p client.ClientboundPacket) genericMap []func(ctx context.Context, p client.ClientboundPacket)
rawMap map[packetid.ClientboundPacketID][]func(ctx context.Context, p pk.Packet)
} }
func (ph *packetHandler) AddPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p client.ClientboundPacket)) { func (ph *packetHandler) AddPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p client.ClientboundPacket)) {
@ -29,13 +32,16 @@ func (ph *packetHandler) AddGenericPacketHandler(handler func(ctx context.Contex
ph.genericMap = append(ph.genericMap, handler) ph.genericMap = append(ph.genericMap, handler)
} }
func (ph *packetHandler) AddRawPacketHandler(id packetid.ClientboundPacketID, handler func(ctx context.Context, p pk.Packet)) {
ph.rawMap[id] = append(ph.rawMap[id], handler)
}
func (ph *packetHandler) HandlePacket(ctx context.Context, p client.ClientboundPacket) { func (ph *packetHandler) HandlePacket(ctx context.Context, p client.ClientboundPacket) {
f := ph.handlerMap[p.PacketID()] f := ph.handlerMap[p.PacketID()]
if f != nil { for _, handler := range f {
for _, handler := range f { handler(ctx, p)
handler(ctx, p)
}
} }
for _, handler := range ph.genericMap { for _, handler := range ph.genericMap {
handler(ctx, p) handler(ctx, p)
} }

48
pkg/client/proxy.go Normal file
View File

@ -0,0 +1,48 @@
package client
import (
"context"
"fmt"
"golang.org/x/net/proxy"
mcnet "git.konjactw.dev/falloutBot/go-mc/net"
"git.konjactw.dev/patyhank/minego/pkg/bot"
)
// createSOCKS5Dialer 建立 SOCKS5 dialer
func socks5(proxyConfig *bot.ProxyConfig) (mcnet.MCDialer, error) {
var auth *proxy.Auth
if proxyConfig.Username != "" || proxyConfig.Password != "" {
auth = &proxy.Auth{
User: proxyConfig.Username,
Password: proxyConfig.Password,
}
}
dialer, err := proxy.SOCKS5("tcp", proxyConfig.Host, auth, proxy.Direct)
if err != nil {
return nil, fmt.Errorf("failed to create SOCKS5 proxy dialer: %w", err)
}
return &socks5MCDialer{
dialer: dialer,
}, nil
}
// socks5MCDialer 實作 mcnet.MCDialer 介面,使用 SOCKS5 proxy
type socks5MCDialer struct {
dialer proxy.Dialer
}
func (d *socks5MCDialer) DialMCContext(ctx context.Context, address string) (*mcnet.Conn, error) {
// 使用 SOCKS5 proxy 建立連線
conn, err := d.dialer.Dial("tcp", address)
if err != nil {
return nil, fmt.Errorf("failed to dial through SOCKS5 proxy: %w", err)
}
// 將 net.Conn 包裝成 mcnet.Conn
return mcnet.WrapConn(conn), nil
}

View File

@ -1,6 +1,6 @@
package inventory package inventory
import "github.com/Tnze/go-mc/chat" import "git.konjactw.dev/falloutBot/go-mc/chat"
type ContainerOpenEvent struct { type ContainerOpenEvent struct {
WindowID int32 WindowID int32

View File

@ -3,10 +3,11 @@ package inventory
import ( import (
"context" "context"
"git.konjactw.dev/falloutBot/go-mc/level/item"
"git.konjactw.dev/patyhank/minego/pkg/bot" "git.konjactw.dev/patyhank/minego/pkg/bot"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/level/item"
) )
// Container 代表一個容器 // Container 代表一個容器

View File

@ -80,8 +80,10 @@ func (m *Manager) CurrentContainerID() int32 {
func (m *Manager) Close() { func (m *Manager) Close() {
if m.currentContainerID != -1 { if m.currentContainerID != -1 {
_ = m.c.WritePacket(context.Background(), &server.ContainerClose{WindowID: m.currentContainerID}) _ = m.c.WritePacket(context.Background(), &server.ContainerClose{WindowID: m.currentContainerID})
m.currentContainerID = -1
} else { } else {
_ = m.c.WritePacket(context.Background(), &server.ContainerClose{WindowID: 0}) _ = m.c.WritePacket(context.Background(), &server.ContainerClose{WindowID: 0})
m.currentContainerID = -1
} }
} }

View File

@ -1,6 +1,6 @@
package player package player
import "github.com/Tnze/go-mc/chat" import "git.konjactw.dev/falloutBot/go-mc/chat"
type MessageEvent struct { type MessageEvent struct {
Message chat.Message Message chat.Message

View File

@ -4,10 +4,12 @@ import (
"container/heap" "container/heap"
"math" "math"
"github.com/go-gl/mathgl/mgl64"
"git.konjactw.dev/falloutBot/go-mc/level/block"
"git.konjactw.dev/patyhank/minego/pkg/bot" "git.konjactw.dev/patyhank/minego/pkg/bot"
"git.konjactw.dev/patyhank/minego/pkg/protocol" "git.konjactw.dev/patyhank/minego/pkg/protocol"
"github.com/Tnze/go-mc/level/block"
"github.com/go-gl/mathgl/mgl64"
) )
// Node 表示 A* 演算法中的節點 // Node 表示 A* 演算法中的節點

View File

@ -6,13 +6,15 @@ import (
"math" "math"
"time" "time"
"github.com/go-gl/mathgl/mgl64"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/bot" "git.konjactw.dev/patyhank/minego/pkg/bot"
"git.konjactw.dev/patyhank/minego/pkg/game/world" "git.konjactw.dev/patyhank/minego/pkg/game/world"
"git.konjactw.dev/patyhank/minego/pkg/protocol" "git.konjactw.dev/patyhank/minego/pkg/protocol"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/go-gl/mathgl/mgl64"
) )
type Player struct { type Player struct {
@ -27,8 +29,9 @@ type Player struct {
// New 創建新的 Player 實例 // New 創建新的 Player 實例
func New(c bot.Client) *Player { func New(c bot.Client) *Player {
pl := &Player{ pl := &Player{
c: c, c: c,
entity: &world.Entity{}, entity: &world.Entity{},
stateID: 1,
} }
c.PacketHandler().AddGenericPacketHandler(func(ctx context.Context, pk client.ClientboundPacket) { c.PacketHandler().AddGenericPacketHandler(func(ctx context.Context, pk client.ClientboundPacket) {
@ -36,7 +39,7 @@ func New(c bot.Client) *Player {
}) })
bot.AddHandler(c, func(ctx context.Context, p *client.KeepAlive) { bot.AddHandler(c, func(ctx context.Context, p *client.KeepAlive) {
c.WritePacket(ctx, &server.KeepAlive{ _ = c.WritePacket(ctx, &server.KeepAlive{
ID: p.ID, ID: p.ID,
}) })
}) })
@ -49,10 +52,51 @@ func New(c bot.Client) *Player {
} }
}) })
bot.AddHandler(c, func(ctx context.Context, p *client.PlayerPosition) { bot.AddHandler(c, func(ctx context.Context, p *client.PlayerPosition) {
pl.entity.SetPosition(mgl64.Vec3{p.X, p.Y, p.Z}) fmt.Println(p)
pl.entity.SetRotation(mgl64.Vec2{float64(p.XRot), float64(p.YRot)}) position := pl.entity.Position()
if p.Flags&0x01 != 0 {
position[0] += p.X
} else {
position[0] = p.X
}
if p.Flags&0x02 != 0 {
position[1] += p.Y
} else {
position[1] = p.Y
}
if p.Flags&0x04 != 0 {
position[2] += p.Z
} else {
position[2] = p.Z
}
pl.entity.SetPosition(position)
rot := pl.entity.Rotation()
if p.Flags&0x08 != 0 {
rot[0] += float64(p.XRot)
} else {
rot[0] = float64(p.XRot)
}
if p.Flags&0x10 != 0 {
rot[1] += float64(p.YRot)
} else {
rot[1] = float64(p.YRot)
}
pl.entity.SetRotation(rot)
c.WritePacket(context.Background(), &server.AcceptTeleportation{TeleportID: p.ID}) c.WritePacket(context.Background(), &server.AcceptTeleportation{TeleportID: p.ID})
c.WritePacket(context.Background(), &server.MovePlayerPosRot{
X: p.X,
FeetY: p.Y,
Z: p.Z,
Yaw: p.XRot,
Pitch: p.YRot,
Flags: 0x00,
})
}) })
bot.AddHandler(c, func(ctx context.Context, p *client.PlayerRotation) { bot.AddHandler(c, func(ctx context.Context, p *client.PlayerRotation) {
pl.entity.SetRotation(mgl64.Vec2{float64(p.Yaw), float64(p.Pitch)}) pl.entity.SetRotation(mgl64.Vec2{float64(p.Yaw), float64(p.Pitch)})
@ -173,6 +217,17 @@ func (p *Player) WalkTo(pos mgl64.Vec3) error {
return nil return nil
} }
func (p *Player) UpdateLocation() {
_ = p.c.WritePacket(context.Background(), &server.MovePlayerPosRot{
X: p.entity.Position().X(),
FeetY: p.entity.Position().Y(),
Z: p.entity.Position().Z(),
Yaw: float32(p.entity.Rotation().X()),
Pitch: float32(p.entity.Rotation().Y()),
Flags: 0x00,
})
}
// LookAt 看向指定位置 // LookAt 看向指定位置
func (p *Player) LookAt(target mgl64.Vec3) error { func (p *Player) LookAt(target mgl64.Vec3) error {
if p.c == nil { if p.c == nil {
@ -191,6 +246,8 @@ func (p *Player) LookAt(target mgl64.Vec3) error {
yaw := float32(math.Atan2(-direction.X(), direction.Z()) * 180 / math.Pi) yaw := float32(math.Atan2(-direction.X(), direction.Z()) * 180 / math.Pi)
pitch := float32(math.Asin(-direction.Y()) * 180 / math.Pi) pitch := float32(math.Asin(-direction.Y()) * 180 / math.Pi)
p.entity.SetRotation(mgl64.Vec2{float64(yaw), float64(pitch)})
return p.c.WritePacket(context.Background(), &server.MovePlayerRot{ return p.c.WritePacket(context.Background(), &server.MovePlayerRot{
Yaw: yaw, Yaw: yaw,
Pitch: pitch, Pitch: pitch,
@ -290,13 +347,24 @@ func (p *Player) OpenContainer(pos protocol.Position) (bot.Container, error) {
return nil, fmt.Errorf("failed to open container: %w", err) return nil, fmt.Errorf("failed to open container: %w", err)
} }
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*10) ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*5)
defer cancelFunc() defer cancelFunc()
for p.c.Inventory().Container() == nil && ctx.Err() == nil { for ctx.Err() == nil && p.c.Inventory().CurrentContainerID() <= 0 {
time.Sleep(time.Millisecond * 50) time.Sleep(time.Millisecond * 50)
} }
for ctx.Err() == nil && p.c.Inventory().Container().SlotCount() == 0 {
time.Sleep(time.Millisecond * 50)
}
if ctx.Err() != nil {
return nil, fmt.Errorf("failed to open container: %w", ctx.Err())
}
if p.c.Inventory().CurrentContainerID() <= 0 {
return nil, fmt.Errorf("failed to open container: no container opened")
}
return p.c.Inventory().Container(), nil return p.c.Inventory().Container(), nil
} }
@ -329,3 +397,15 @@ func (p *Player) OpenMenu(command string) (bot.Container, error) {
// 返回客戶端的容器處理器 // 返回客戶端的容器處理器
return p.c.Inventory().Container(), nil return p.c.Inventory().Container(), nil
} }
func (p *Player) Command(msg string) error {
return p.c.WritePacket(context.Background(), &server.ChatCommand{
Command: msg,
})
}
func (p *Player) Chat(msg string) error {
return p.c.WritePacket(context.Background(), &server.Chat{
Message: msg,
})
}

View File

@ -1,11 +1,13 @@
package world package world
import ( import (
"git.konjactw.dev/patyhank/minego/pkg/protocol/metadata"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/data/entity"
"github.com/go-gl/mathgl/mgl64" "github.com/go-gl/mathgl/mgl64"
"github.com/google/uuid" "github.com/google/uuid"
"git.konjactw.dev/falloutBot/go-mc/data/entity"
"git.konjactw.dev/patyhank/minego/pkg/protocol/metadata"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
) )
type Entity struct { type Entity struct {

View File

@ -6,17 +6,19 @@ import (
"errors" "errors"
"sync" "sync"
"github.com/go-gl/mathgl/mgl64"
"golang.org/x/exp/constraints"
"git.konjactw.dev/falloutBot/go-mc/data/entity"
"git.konjactw.dev/falloutBot/go-mc/level"
"git.konjactw.dev/falloutBot/go-mc/level/block"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/bot" "git.konjactw.dev/patyhank/minego/pkg/bot"
"git.konjactw.dev/patyhank/minego/pkg/protocol" "git.konjactw.dev/patyhank/minego/pkg/protocol"
"git.konjactw.dev/patyhank/minego/pkg/protocol/metadata" "git.konjactw.dev/patyhank/minego/pkg/protocol/metadata"
cp "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" cp "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/data/entity"
"github.com/Tnze/go-mc/level"
"github.com/Tnze/go-mc/level/block"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/go-gl/mathgl/mgl64"
"golang.org/x/exp/constraints"
) )
type World struct { type World struct {
@ -42,6 +44,7 @@ func NewWorld(c bot.Client) *World {
w.columns[p.Pos] = p.Data w.columns[p.Pos] = p.Data
}) })
bot.AddHandler(c, func(ctx context.Context, p *cp.ForgetLevelChunk) { bot.AddHandler(c, func(ctx context.Context, p *cp.ForgetLevelChunk) {
w.chunkLock.Lock() w.chunkLock.Lock()
defer w.chunkLock.Unlock() defer w.chunkLock.Unlock()
@ -147,7 +150,8 @@ func (w *World) GetBlock(pos protocol.Position) (block.Block, error) {
blockX := pos[0] & 15 blockX := pos[0] & 15
blockZ := pos[2] & 15 blockZ := pos[2] & 15
blockIdx := (pos[1] << 8) | (blockZ << 4) | blockX blockY := pos[1] & 15
blockIdx := (blockY << 8) | (blockZ << 4) | blockX
sectionY := pos[1] >> 4 sectionY := pos[1] >> 4
if sectionY < 0 || int(sectionY) >= len(chunk.Sections) { if sectionY < 0 || int(sectionY) >= len(chunk.Sections) {
return nil, errors.New("invalid section Y coordinate") return nil, errors.New("invalid section Y coordinate")
@ -186,9 +190,6 @@ func (w *World) SetBlock(pos protocol.Position, blk block.Block) error {
} }
func (w *World) GetNearbyBlocks(pos protocol.Position, radius int32) ([]block.Block, error) { func (w *World) GetNearbyBlocks(pos protocol.Position, radius int32) ([]block.Block, error) {
w.chunkLock.Lock()
defer w.chunkLock.Unlock()
var blocks []block.Block var blocks []block.Block
for dx := -radius; dx <= radius; dx++ { for dx := -radius; dx <= radius; dx++ {
@ -207,8 +208,6 @@ func (w *World) GetNearbyBlocks(pos protocol.Position, radius int32) ([]block.Bl
} }
func (w *World) FindNearbyBlock(pos protocol.Position, radius int32, blk block.Block) (protocol.Position, error) { func (w *World) FindNearbyBlock(pos protocol.Position, radius int32, blk block.Block) (protocol.Position, error) {
w.chunkLock.Lock()
defer w.chunkLock.Unlock()
visited := make(map[protocol.Position]bool) visited := make(map[protocol.Position]bool)
queue := list.New() queue := list.New()
start := pos start := pos

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -3,9 +3,10 @@ package component
import ( import (
"io" "io"
"git.konjactw.dev/falloutBot/go-mc/nbt"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -3,8 +3,9 @@ package component
import ( import (
"io" "io"
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
type ChickenVariant struct { type ChickenVariant struct {

View File

@ -6,7 +6,7 @@ import (
"errors" "errors"
"io" "io"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
func (c *AttributeModifiers) ReadFrom(r io.Reader) (n int64, err error) { func (c *AttributeModifiers) ReadFrom(r io.Reader) (n int64, err error) {

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,9 +1,10 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
) )
//codec:gen //codec:gen

View File

@ -3,9 +3,10 @@ package component
import ( import (
"io" "io"
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/net/packet"
) )
type JukeboxPlayable struct { type JukeboxPlayable struct {

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,9 +1,10 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/net/packet"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,9 +1,10 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -3,8 +3,9 @@ package component
import ( import (
"io" "io"
"git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/net/packet"
) )
type ProvidesTrimMaterial struct { type ProvidesTrimMaterial struct {

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/nbt"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,9 +1,10 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package component package component
import ( import (
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -1,9 +1,10 @@
package component package component
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
) )
//codec:gen //codec:gen

View File

@ -5,7 +5,7 @@ package metadata
import ( import (
"io" "io"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
func (c *Rotation) ReadFrom(r io.Reader) (n int64, err error) { func (c *Rotation) ReadFrom(r io.Reader) (n int64, err error) {

View File

@ -3,7 +3,7 @@ package metadata
import ( import (
"io" "io"
pk "github.com/Tnze/go-mc/net/packet" pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
type MetadataType int32 type MetadataType int32

View File

@ -1,12 +1,13 @@
package metadata package metadata
import ( import (
"git.konjactw.dev/falloutBot/go-mc/chat"
"git.konjactw.dev/falloutBot/go-mc/nbt"
pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
"git.konjactw.dev/patyhank/minego/pkg/protocol/component" "git.konjactw.dev/patyhank/minego/pkg/protocol/component"
"git.konjactw.dev/patyhank/minego/pkg/protocol/particle" "git.konjactw.dev/patyhank/minego/pkg/protocol/particle"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot" "git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/nbt"
pk "github.com/Tnze/go-mc/net/packet"
) )
type Byte struct { type Byte struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigClearDialog struct { type ConfigClearDialog struct {

View File

@ -6,7 +6,7 @@ import (
"errors" "errors"
"io" "io"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
func (c *ConfigClearDialog) ReadFrom(r io.Reader) (n int64, err error) { func (c *ConfigClearDialog) ReadFrom(r io.Reader) (n int64, err error) {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigCookieRequest struct { type ConfigCookieRequest struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigCustomPayload struct { type ConfigCustomPayload struct {

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigCustomReportDetails struct { type ConfigCustomReportDetails struct {

View File

@ -1,8 +1,8 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/chat" "git.konjactw.dev/falloutBot/go-mc/chat"
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
) )
//codec:gen //codec:gen

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigFinishConfiguration struct { type ConfigFinishConfiguration struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigKeepAlive struct { type ConfigKeepAlive struct {

View File

@ -1,8 +1,8 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet" pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
type ClientboundPacket interface { type ClientboundPacket interface {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigPing struct { type ConfigPing struct {

View File

@ -1,8 +1,8 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
"github.com/Tnze/go-mc/nbt" "git.konjactw.dev/falloutBot/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigResetChat struct { type ConfigResetChat struct {

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigResourcePackPop struct { type ConfigResourcePackPop struct {

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigResourcePackPush struct { type ConfigResourcePackPush struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type KnownPack struct { type KnownPack struct {

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigServerLinks struct { type ConfigServerLinks struct {

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigShowDialog struct { type ConfigShowDialog struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigStoreCookie struct { type ConfigStoreCookie struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigTransfer struct { type ConfigTransfer struct {

View File

@ -1,6 +1,6 @@
package client package client
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigUpdateEnabledFeatures struct { type ConfigUpdateEnabledFeatures struct {

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigUpdateTags struct { type ConfigUpdateTags struct {

View File

@ -1,8 +1,9 @@
package server package server
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigClientInformation struct { type ConfigClientInformation struct {

View File

@ -5,7 +5,7 @@ package server
import ( import (
"io" "io"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
func (c *ConfigCustomClickAction) ReadFrom(r io.Reader) (n int64, err error) { func (c *ConfigCustomClickAction) ReadFrom(r io.Reader) (n int64, err error) {

View File

@ -1,8 +1,9 @@
package server package server
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigCookieResponse struct { type ConfigCookieResponse struct {

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
"github.com/Tnze/go-mc/nbt" "git.konjactw.dev/falloutBot/go-mc/nbt"
) )
//codec:gen //codec:gen

View File

@ -1,8 +1,9 @@
package server package server
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigCustomPayload struct { type ConfigCustomPayload struct {

View File

@ -1,6 +1,6 @@
package server package server
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigFinishConfiguration struct { type ConfigFinishConfiguration struct {

View File

@ -1,6 +1,6 @@
package server package server
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigKeepAlive struct { type ConfigKeepAlive struct {

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
pk "github.com/Tnze/go-mc/net/packet" pk "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
type ServerboundPacket interface { type ServerboundPacket interface {

View File

@ -1,6 +1,6 @@
package server package server
import "github.com/Tnze/go-mc/data/packetid" import "git.konjactw.dev/falloutBot/go-mc/data/packetid"
//codec:gen //codec:gen
type ConfigPong struct { type ConfigPong struct {

View File

@ -1,8 +1,9 @@
package server package server
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/server"
"github.com/Tnze/go-mc/data/packetid"
) )
type ConfigResourcePack struct { type ConfigResourcePack struct {

View File

@ -1,8 +1,9 @@
package server package server
import ( import (
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/patyhank/minego/pkg/protocol/packet/configuration/client" "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/configuration/client"
"github.com/Tnze/go-mc/data/packetid"
) )
//codec:gen //codec:gen

View File

@ -1,9 +1,10 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
"github.com/google/uuid" "github.com/google/uuid"
"git.konjactw.dev/falloutBot/go-mc/data/packetid"
"git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
var _ ClientboundPacket = (*AddEntity)(nil) var _ ClientboundPacket = (*AddEntity)(nil)

View File

@ -1,8 +1,8 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
var _ ClientboundPacket = (*Animate)(nil) var _ ClientboundPacket = (*Animate)(nil)

View File

@ -1,8 +1,8 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
// codec:gen // codec:gen

View File

@ -1,7 +1,7 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
) )
var _ ClientboundPacket = (*BlockChangedAck)(nil) var _ ClientboundPacket = (*BlockChangedAck)(nil)

View File

@ -1,8 +1,8 @@
package client package client
import ( import (
"github.com/Tnze/go-mc/data/packetid" "git.konjactw.dev/falloutBot/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet" "git.konjactw.dev/falloutBot/go-mc/net/packet"
) )
var _ ClientboundPacket = (*BlockDestruction)(nil) var _ ClientboundPacket = (*BlockDestruction)(nil)

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