diff --git a/.gitignore b/.gitignore index 81ce0d9..70cd13b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ token.json *.mcpack *.zip *.pcap +*.pcap2 *.bmp *.bin *.log diff --git a/go.mod b/go.mod index 8599b4d..a2e3c87 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/bedrock-tool/bedrocktool go 1.19 //replace github.com/sandertv/gophertunnel => ./gophertunnel -replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.24.11-1 +replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.24.13-1 //replace github.com/df-mc/dragonfly => ./dragonfly replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.8.5-1 @@ -29,7 +29,7 @@ require ( github.com/df-mc/atomic v1.10.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.0 github.com/jinzhu/copier v0.3.5 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/klauspost/compress v1.15.11 // indirect diff --git a/go.sum b/go.sum index 373eeb8..be9f035 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,8 @@ github.com/olebeck/dragonfly v0.8.5-1 h1:+z1WO0W4jCc1jcPMGDz85AxLWz59haEakD0yAVE github.com/olebeck/dragonfly v0.8.5-1/go.mod h1:CHQ21j4LjSwHgUeMk06tcxEW6U+SI7avLCUeSvp9AXo= github.com/olebeck/gophertunnel v1.24.11-1 h1:DKEqjK5nAcjlwejHAD/SHeolAM6y9EkyjJcMuoK7VVY= github.com/olebeck/gophertunnel v1.24.11-1/go.mod h1:dYFetA6r62huhc1EgR9p8VFAFtKOuGgVE/iXf5CzZ4o= +github.com/olebeck/gophertunnel v1.24.13-1 h1:3Sj22hVFAGCnPMJAewoSeuC9N8ikzcWo0DvJNBnXvs0= +github.com/olebeck/gophertunnel v1.24.13-1/go.mod h1:dYFetA6r62huhc1EgR9p8VFAFtKOuGgVE/iXf5CzZ4o= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/subcommands/world/world.go b/subcommands/world/world.go index 76cb78b..1274aca 100644 --- a/subcommands/world/world.go +++ b/subcommands/world/world.go @@ -56,6 +56,7 @@ type WorldState struct { chunks map[protocol.ChunkPos]*chunk.Chunk blockNBT map[protocol.SubChunkPos][]map[string]any openItemContainers map[byte]*itemContainer + airRid uint32 Dim world.Dimension WorldName string @@ -82,6 +83,7 @@ func NewWorldState() *WorldState { Dim: nil, WorldName: "world", PlayerPos: TPlayerPos{}, + airRid: 6692, } w.ui = NewMapUI(w) return w @@ -169,13 +171,11 @@ func (c *WorldCMD) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{ return pk, nil } - defer w.SaveAndReset() - err = proxy.Run(ctx, server_address) if err != nil { fmt.Fprintln(os.Stderr, err) - return 1 } + w.SaveAndReset() return 0 } @@ -197,7 +197,7 @@ func (w *WorldState) ProcessLevelChunk(pk *packet.LevelChunk) { return } - ch, blockNBTs, err := chunk.NetworkDecode(6692, pk.RawPayload, int(pk.SubChunkCount), w.Dim.Range(), w.ispre118) + ch, blockNBTs, err := chunk.NetworkDecode(w.airRid, pk.RawPayload, int(pk.SubChunkCount), w.Dim.Range(), w.ispre118) if err != nil { logrus.Error(err) return @@ -308,7 +308,7 @@ func (w *WorldState) Reset() { // writes the world to a folder, resets all the chunks func (w *WorldState) SaveAndReset() { - logrus.Infof("Saving world %s", w.WorldName) + logrus.Infof("Saving world %s %d chunks", w.WorldName, len(w.chunks)) // open world folder := path.Join("worlds", fmt.Sprintf("%s/%s", w.ServerName, w.WorldName)) @@ -461,14 +461,15 @@ func (w *WorldState) OnConnect(proxy *utils.ProxyContext) { w.proxy = proxy gd := w.proxy.Server.GameData() - /* - if len(gd.CustomBlocks) > 0 { + if len(gd.CustomBlocks) > 0 { + logrus.Info("Using Custom Blocks") + /* for _, be := range gd.CustomBlocks { b := block.ServerCustomBlock(be) world.RegisterBlock(b) } - } - */ + */ + } if w.withPacks { go func() { @@ -526,7 +527,7 @@ func (w *WorldState) OnConnect(proxy *utils.ProxyContext) { Parameters: []protocol.CommandParameter{ { Name: "name", - Type: protocol.CommandArgTypeFilepath, + Type: protocol.CommandArgTypeString, Optional: false, }, }, diff --git a/utils/utils.go b/utils/utils.go index 77368a2..2f19cf1 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -13,6 +13,7 @@ import ( "regexp" "strings" + "github.com/google/uuid" "github.com/sandertv/gophertunnel/minecraft" "github.com/sirupsen/logrus" @@ -81,10 +82,12 @@ func ConnectServer(ctx context.Context, address string, ClientData *login.Client logrus.Infof("Connecting to %s\n", address) serverConn, err = minecraft.Dialer{ - TokenSource: GetTokenSource(), - ClientData: cd, - PacketFunc: packet_func, - DownloadPacks: want_packs, + TokenSource: GetTokenSource(), + ClientData: cd, + PacketFunc: packet_func, + DownloadResourcePack: func(id uuid.UUID, version string) bool { + return want_packs + }, }.DialContext(ctx, "raknet", address) if err != nil { return nil, err