dont download resource packs when not needed

This commit is contained in:
olebeck 2022-08-24 03:41:05 +02:00
parent 5b34cb6bdc
commit 62924b69a7
5 changed files with 11 additions and 8 deletions

2
go.mod
View File

@ -18,7 +18,7 @@ require (
//replace github.com/df-mc/dragonfly => ./dragonfly
replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.24.8-1
replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.24.8-2
replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.8.2-5

2
go.sum
View File

@ -45,6 +45,8 @@ github.com/olebeck/gophertunnel v1.24.7 h1:EMYLDMxGxzPtoI/Y77KHPcfelkGS+QcjdtStG
github.com/olebeck/gophertunnel v1.24.7/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
github.com/olebeck/gophertunnel v1.24.8-1 h1:ECZs6y/ZtvUjhIPlu3RjJr8c5QkOdxdQnoO+4iR4TEk=
github.com/olebeck/gophertunnel v1.24.8-1/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
github.com/olebeck/gophertunnel v1.24.8-2 h1:T7WY2M/GrKTOgcH1RcDiB8LNlhK+PEzGdHSaYP4V518=
github.com/olebeck/gophertunnel v1.24.8-2/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
github.com/olebeck/gophertunnel v1.24.8 h1:jdqBOABDAE1yISqzm9IxIrI+/lJApLBjTieynXUSalw=
github.com/olebeck/gophertunnel v1.24.8/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

Binary file not shown.

View File

@ -245,7 +245,7 @@ func (c *SkinCMD) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{}
return 1
}
serverConn, err := connect_server(ctx, address, nil)
serverConn, err := connect_server(ctx, address, nil, false)
if err != nil {
fmt.Fprint(os.Stderr, err)
return 1

View File

@ -107,7 +107,7 @@ func server_url_to_name(server string) string {
return host
}
func connect_server(ctx context.Context, address string, ClientData *login.ClientData) (serverConn *minecraft.Conn, err error) {
func connect_server(ctx context.Context, address string, ClientData *login.ClientData, want_packs bool) (serverConn *minecraft.Conn, err error) {
var packet_func func(header packet.Header, payload []byte, src, dst net.Addr) = nil
if G_debug {
packet_func = PacketLogger
@ -120,9 +120,10 @@ func connect_server(ctx context.Context, address string, ClientData *login.Clien
fmt.Printf("Connecting to %s\n", address)
serverConn, err = minecraft.Dialer{
TokenSource: GetTokenSource(),
ClientData: cd,
PacketFunc: packet_func,
TokenSource: GetTokenSource(),
ClientData: cd,
PacketFunc: packet_func,
DownloadPacks: want_packs,
}.DialContext(ctx, "raknet", address)
if err != nil {
return nil, err
@ -165,7 +166,7 @@ func create_proxy(ctx context.Context, server_address string) (l *minecraft.List
var packs []*resource.Pack
if G_preload_packs {
fmt.Println("Preloading resourcepacks")
serverConn, err = connect_server(ctx, server_address, nil)
serverConn, err = connect_server(ctx, server_address, nil, true)
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to connect to %s: %s", server_address, err)
}
@ -193,7 +194,7 @@ func create_proxy(ctx context.Context, server_address string) (l *minecraft.List
clientConn = c.(*minecraft.Conn)
cd := clientConn.ClientData()
serverConn, err = connect_server(ctx, server_address, &cd)
serverConn, err = connect_server(ctx, server_address, &cd, false)
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to connect to %s: %s", server_address, err)
}