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
require (
github.com/Tnze/go-mc v1.20.3-0.20241224032005-539b4a3a7f03
github.com/google/uuid v1.6.0
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476
golang.org/x/sync v0.16.0
)
require github.com/go-gl/mathgl v1.2.0
replace github.com/Tnze/go-mc v1.20.3-0.20241224032005-539b4a3a7f03 => git.konjactw.dev/falloutBot/go-mc v0.0.0-20250823092154-f0bb92bdb98a
require (
git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826135316-7b60edc24881
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-20250823092154-f0bb92bdb98a/go.mod h1:e3pBU8tqRfYDHrhtZRtyfGdYijA86b1fF3XgnEDSgHk=
git.konjactw.dev/patyhank/go-mc v1.20.3-0.20250619063151-133e3fab4ac2 h1:KiA1OsQQGjrKxev45URJPwvyuVwen9Bb4TzjEg/ojz8=
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-20250826114052-b9763dbf8c9f h1:U7Ay0O+6w/3shRUCilTz5idjMJ9pfHBg6bLTUKwqbU0=
git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826114052-b9763dbf8c9f/go.mod h1:/KAQOP2x0pA8xEQuNkQa4d1TMKoyfLvUKmFqUJ8keDc=
git.konjactw.dev/falloutBot/go-mc v0.0.0-20250826135316-7b60edc24881 h1:4kwONJ/u4HvLS1zTfid+NXc+3MkAceiLlwLwAzCoXh4=
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/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/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/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/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=

View File

@ -19,14 +19,16 @@ import (
"strings"
"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/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 (

View File

@ -25,6 +25,14 @@ type ClientOptions struct {
AuthProvider auth.Provider
}
type ConnectOptions struct {
FakeHost string
type ProxyConfig struct {
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 (
"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"
"github.com/Tnze/go-mc/data/packetid"
)
type PacketHandler interface {
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))
HandlePacket(ctx context.Context, p client.ClientboundPacket)
}

View File

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

View File

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

View File

@ -1,13 +1,15 @@
package bot
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/metadata"
"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 {
@ -32,4 +34,7 @@ type Entity interface {
Metadata() map[uint8]metadata.Metadata
Equipment() map[int8]slot.Slot
SetPosition(pos mgl64.Vec3)
SetRotation(rot mgl64.Vec2)
}

View File

@ -7,6 +7,12 @@ import (
"net"
"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/bot"
"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/protocol/packet/game/client"
"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 {
conn *mcnet.Conn
packetHandler bot.PacketHandler
packetHandler *packetHandler
eventHandler bot.EventHandler
connected bool
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)
if err != nil {
return err
@ -156,6 +164,15 @@ func (b *botClient) handlePackets(ctx context.Context) error {
}
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]
if !ok {
continue
@ -163,12 +180,10 @@ func (b *botClient) handlePackets(ctx context.Context) error {
pkt := creator()
_, err := pkt.ReadFrom(bytes.NewReader(p.Data))
if err != nil {
// fmt.Printf("Decoding: 0x%x %s %s\n", p.ID, pktID.String(), err.Error())
continue
}
group.Go(func() error {
b.packetHandler.HandlePacket(ctx, pkt)
return nil
})
b.packetHandler.HandlePacket(ctx, pkt)
}
}
}

View File

@ -5,10 +5,11 @@ import (
"errors"
"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"
"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 {

View File

@ -3,20 +3,23 @@ package client
import (
"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"
"github.com/Tnze/go-mc/data/packetid"
)
func newPacketHandler() bot.PacketHandler {
func newPacketHandler() *packetHandler {
return &packetHandler{
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 {
handlerMap map[packetid.ClientboundPacketID][]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)) {
@ -29,13 +32,16 @@ func (ph *packetHandler) AddGenericPacketHandler(handler func(ctx context.Contex
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) {
f := ph.handlerMap[p.PacketID()]
if f != nil {
for _, handler := range f {
handler(ctx, p)
}
for _, handler := range f {
handler(ctx, p)
}
for _, handler := range ph.genericMap {
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
import "github.com/Tnze/go-mc/chat"
import "git.konjactw.dev/falloutBot/go-mc/chat"
type ContainerOpenEvent struct {
WindowID int32

View File

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

View File

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

View File

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

View File

@ -4,10 +4,12 @@ import (
"container/heap"
"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/protocol"
"github.com/Tnze/go-mc/level/block"
"github.com/go-gl/mathgl/mgl64"
)
// Node 表示 A* 演算法中的節點

View File

@ -6,13 +6,15 @@ import (
"math"
"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/game/world"
"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/server"
pk "github.com/Tnze/go-mc/net/packet"
"github.com/go-gl/mathgl/mgl64"
)
type Player struct {
@ -27,8 +29,9 @@ type Player struct {
// New 創建新的 Player 實例
func New(c bot.Client) *Player {
pl := &Player{
c: c,
entity: &world.Entity{},
c: c,
entity: &world.Entity{},
stateID: 1,
}
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) {
c.WritePacket(ctx, &server.KeepAlive{
_ = c.WritePacket(ctx, &server.KeepAlive{
ID: p.ID,
})
})
@ -49,10 +52,51 @@ func New(c bot.Client) *Player {
}
})
bot.AddHandler(c, func(ctx context.Context, p *client.PlayerPosition) {
pl.entity.SetPosition(mgl64.Vec3{p.X, p.Y, p.Z})
pl.entity.SetRotation(mgl64.Vec2{float64(p.XRot), float64(p.YRot)})
fmt.Println(p)
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.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) {
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
}
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 看向指定位置
func (p *Player) LookAt(target mgl64.Vec3) error {
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)
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{
Yaw: yaw,
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)
}
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*5)
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)
}
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
}
@ -329,3 +397,15 @@ func (p *Player) OpenMenu(command string) (bot.Container, error) {
// 返回客戶端的容器處理器
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
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/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 {

View File

@ -6,17 +6,19 @@ import (
"errors"
"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/protocol"
"git.konjactw.dev/patyhank/minego/pkg/protocol/metadata"
cp "git.konjactw.dev/patyhank/minego/pkg/protocol/packet/game/client"
"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 {
@ -42,6 +44,7 @@ func NewWorld(c bot.Client) *World {
w.columns[p.Pos] = p.Data
})
bot.AddHandler(c, func(ctx context.Context, p *cp.ForgetLevelChunk) {
w.chunkLock.Lock()
defer w.chunkLock.Unlock()
@ -147,7 +150,8 @@ func (w *World) GetBlock(pos protocol.Position) (block.Block, error) {
blockX := pos[0] & 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
if sectionY < 0 || int(sectionY) >= len(chunk.Sections) {
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) {
w.chunkLock.Lock()
defer w.chunkLock.Unlock()
var blocks []block.Block
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) {
w.chunkLock.Lock()
defer w.chunkLock.Unlock()
visited := make(map[protocol.Position]bool)
queue := list.New()
start := pos

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,9 +3,10 @@ package component
import (
"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"
"github.com/Tnze/go-mc/nbt"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen

View File

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

View File

@ -6,7 +6,7 @@ import (
"errors"
"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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
package component
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"
"github.com/Tnze/go-mc/net/packet"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
package component
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"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
package component
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"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen

View File

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

View File

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

View File

@ -1,9 +1,10 @@
package component
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"
"github.com/Tnze/go-mc/chat"
pk "github.com/Tnze/go-mc/net/packet"
)
//codec:gen

View File

@ -5,7 +5,7 @@ package metadata
import (
"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) {

View File

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

View File

@ -1,12 +1,13 @@
package metadata
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/particle"
"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 {

View File

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

View File

@ -6,7 +6,7 @@ import (
"errors"
"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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ package server
import (
"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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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