make void black, add preloading resource packs
This commit is contained in:
parent
c5abf07dad
commit
841ce5ace8
|
@ -22,19 +22,21 @@ func Chunk2Img(c *chunk.Chunk) *image.RGBA {
|
|||
col := color.RGBA{0, 0, 0, 255}
|
||||
|
||||
block_rid := c.Block(x, height, z, 0)
|
||||
b, found := world.BlockByRuntimeID(block_rid)
|
||||
if found {
|
||||
col = b.Color()
|
||||
}
|
||||
|
||||
/*
|
||||
if col.R == 255 && col.B == 255 {
|
||||
name, nbt := b.EncodeBlock()
|
||||
fmt.Printf("unknown color %s %s %s\n", reflect.TypeOf(b), name, nbt)
|
||||
b.Color()
|
||||
if block_rid == 0 && height == 0 { // void
|
||||
col = color.RGBA{0, 0, 0, 255}
|
||||
} else {
|
||||
b, found := world.BlockByRuntimeID(block_rid)
|
||||
if found {
|
||||
col = b.Color()
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if col.R == 255 && col.B == 255 {
|
||||
name, nbt := b.EncodeBlock()
|
||||
fmt.Printf("unknown color %d %s %s %s\n", block_rid, reflect.TypeOf(b), name, nbt)
|
||||
b.Color()
|
||||
}
|
||||
*/
|
||||
}
|
||||
if height_liquid > height {
|
||||
bw := &block.Water{}
|
||||
wcol := bw.Color()
|
||||
|
|
4
main.go
4
main.go
|
@ -26,6 +26,7 @@ const TOKEN_FILE = "token.json"
|
|||
var G_src oauth2.TokenSource
|
||||
var G_xbl_token *auth.XBLToken
|
||||
var G_debug bool
|
||||
var G_preload_packs bool
|
||||
var G_exit []func() = []func(){}
|
||||
|
||||
var pool = packet.NewPool()
|
||||
|
@ -104,10 +105,13 @@ func main() {
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
flag.BoolVar(&G_debug, "debug", false, "debug mode")
|
||||
flag.BoolVar(&G_preload_packs, "preload", false, "preload resourcepacks for proxy")
|
||||
enable_dns := flag.Bool("dns", false, "enable dns server for consoles")
|
||||
|
||||
subcommands.Register(subcommands.HelpCommand(), "")
|
||||
subcommands.ImportantFlag("debug")
|
||||
subcommands.ImportantFlag("dns")
|
||||
subcommands.ImportantFlag("preload")
|
||||
subcommands.HelpCommand()
|
||||
|
||||
{ // interactive input
|
||||
|
|
14
utils.go
14
utils.go
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/sandertv/gophertunnel/minecraft/auth"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/login"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
"github.com/sandertv/gophertunnel/minecraft/resource"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
@ -152,9 +153,22 @@ func spawn_conn(ctx context.Context, clientConn *minecraft.Conn, serverConn *min
|
|||
}
|
||||
|
||||
func create_proxy(ctx context.Context, server_address string) (l *minecraft.Listener, clientConn, serverConn *minecraft.Conn, err error) {
|
||||
var packs []*resource.Pack
|
||||
if G_preload_packs {
|
||||
fmt.Println("Preloading resourcepacks")
|
||||
serverConn, err = connect_server(ctx, server_address, nil)
|
||||
if err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("failed to connect to %s: %s", server_address, err)
|
||||
}
|
||||
serverConn.Close()
|
||||
packs = serverConn.ResourcePacks()
|
||||
fmt.Printf("%d packs loaded\n", len(packs))
|
||||
}
|
||||
|
||||
_status := minecraft.NewStatusProvider("Server")
|
||||
listener, err := minecraft.ListenConfig{
|
||||
StatusProvider: _status,
|
||||
ResourcePacks: packs,
|
||||
}.Listen("raknet", ":19132")
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
|
Loading…
Reference in New Issue