fix for hive, save world seed, allow non void generator
This commit is contained in:
parent
62924b69a7
commit
19f13a113e
6
go.mod
6
go.mod
|
@ -16,11 +16,13 @@ require (
|
|||
|
||||
//replace github.com/sandertv/gophertunnel => ./gophertunnel
|
||||
|
||||
//replace github.com/sandertv/go-raknet => ./go-raknet
|
||||
|
||||
//replace github.com/df-mc/dragonfly => ./dragonfly
|
||||
|
||||
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
|
||||
replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.8.2-6
|
||||
|
||||
require (
|
||||
github.com/brentp/intintmap v0.0.0-20190211203843-30dc0ade9af9 // indirect
|
||||
|
@ -31,7 +33,7 @@ require (
|
|||
github.com/jinzhu/copier v0.3.5
|
||||
github.com/klauspost/compress v1.15.9 // indirect
|
||||
github.com/muhammadmuzzammil1998/jsonc v1.0.0 // indirect
|
||||
github.com/sandertv/go-raknet v1.11.1 // indirect
|
||||
github.com/sandertv/go-raknet v1.11.1
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -39,6 +39,8 @@ github.com/muhammadmuzzammil1998/jsonc v1.0.0 h1:8o5gBQn4ZA3NBA9DlTujCj2a4w0tqWr
|
|||
github.com/muhammadmuzzammil1998/jsonc v1.0.0/go.mod h1:saF2fIVw4banK0H4+/EuqfFLpRnoy5S+ECwTOCcRcSU=
|
||||
github.com/olebeck/dragonfly v0.8.2-5 h1:0G9dhTQ1Oae1KnmgRjNeqYPQ/PsLFGwMWtQYAJkPICI=
|
||||
github.com/olebeck/dragonfly v0.8.2-5/go.mod h1:xgpCDhHoP03RygPaTrzzDwsSTcEZhxNPMV3CAxETj+I=
|
||||
github.com/olebeck/dragonfly v0.8.2-6 h1:h7GoXbNMS1OTOfm/QK7QQ3VF4By5Scfk/7Sd0LJ13s0=
|
||||
github.com/olebeck/dragonfly v0.8.2-6/go.mod h1:xgpCDhHoP03RygPaTrzzDwsSTcEZhxNPMV3CAxETj+I=
|
||||
github.com/olebeck/gophertunnel v1.24.6 h1:Mnpzk9e+eMdfx/wbEsmwQabEbalNzFRu+3iMEBzaVSg=
|
||||
github.com/olebeck/gophertunnel v1.24.6/go.mod h1:dMOw79FHxr2azEqiGH20AwdljisAN1kqwu5SjPBnZ5k=
|
||||
github.com/olebeck/gophertunnel v1.24.7 h1:EMYLDMxGxzPtoI/Y77KHPcfelkGS+QcjdtStGIqtYFE=
|
||||
|
|
32
utils.go
32
utils.go
|
@ -21,6 +21,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/sandertv/gophertunnel/minecraft"
|
||||
//"github.com/sandertv/gophertunnel/minecraft/gatherings"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/login"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
|
@ -74,6 +75,19 @@ func server_input(server string) (address, name string, err error) {
|
|||
s := strings.Split(server, ".")
|
||||
name = strings.Join(s[:len(s)-1], ".")
|
||||
address = server
|
||||
/*} else if strings.HasPrefix(server, "gathering:") {
|
||||
gathering_info := strings.Split(server, ":")
|
||||
if len(gathering_info) < 2 {
|
||||
return "", "", fmt.Errorf("use: gathering:<uuid>")
|
||||
}
|
||||
gathering_id := gathering_info[1]
|
||||
g := gatherings.NewGathering(GetTokenSource(), gathering_id)
|
||||
address, err = g.Address()
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return address, gathering_id, nil
|
||||
} */
|
||||
} else {
|
||||
// if an actual server address if given
|
||||
// add port if necessary
|
||||
|
@ -154,6 +168,21 @@ func spawn_conn(ctx context.Context, clientConn *minecraft.Conn, serverConn *min
|
|||
return nil
|
||||
}
|
||||
|
||||
type dummyProto struct {
|
||||
id int32
|
||||
ver string
|
||||
}
|
||||
|
||||
func (p dummyProto) ID() int32 { return p.id }
|
||||
func (p dummyProto) Ver() string { return p.ver }
|
||||
func (p dummyProto) Packets() packet.Pool { return packet.NewPool() }
|
||||
func (p dummyProto) ConvertToLatest(pk packet.Packet, _ *minecraft.Conn) []packet.Packet {
|
||||
return []packet.Packet{pk}
|
||||
}
|
||||
func (p dummyProto) ConvertFromLatest(pk packet.Packet, _ *minecraft.Conn) []packet.Packet {
|
||||
return []packet.Packet{pk}
|
||||
}
|
||||
|
||||
func create_proxy(ctx context.Context, server_address string) (l *minecraft.Listener, clientConn, serverConn *minecraft.Conn, err error) {
|
||||
/*
|
||||
if strings.HasSuffix(server_address, ".pcap") {
|
||||
|
@ -179,6 +208,9 @@ func create_proxy(ctx context.Context, server_address string) (l *minecraft.List
|
|||
listener, err := minecraft.ListenConfig{
|
||||
StatusProvider: _status,
|
||||
ResourcePacks: packs,
|
||||
AcceptedProtocols: []minecraft.Protocol{
|
||||
dummyProto{id: 544, ver: "1.19.20"},
|
||||
},
|
||||
}.Listen("raknet", ":19132")
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
|
19
world.go
19
world.go
|
@ -42,6 +42,7 @@ type TPlayerPos struct {
|
|||
|
||||
type WorldState struct {
|
||||
ispre118 bool
|
||||
voidgen bool
|
||||
chunks map[protocol.ChunkPos]*chunk.Chunk
|
||||
entities map[int64]world.SaveableEntity
|
||||
blockNBT map[protocol.SubChunkPos][]map[string]any
|
||||
|
@ -99,8 +100,9 @@ func init() {
|
|||
}
|
||||
|
||||
type WorldCMD struct {
|
||||
server_address string
|
||||
packs bool
|
||||
server_address string
|
||||
packs bool
|
||||
enableGenerator bool
|
||||
}
|
||||
|
||||
func (*WorldCMD) Name() string { return "worlds" }
|
||||
|
@ -109,6 +111,7 @@ func (*WorldCMD) Synopsis() string { return "download a world from a server" }
|
|||
func (p *WorldCMD) SetFlags(f *flag.FlagSet) {
|
||||
f.StringVar(&p.server_address, "address", "", "remote server address")
|
||||
f.BoolVar(&p.packs, "packs", false, "save resourcepacks to the worlds")
|
||||
f.BoolVar(&p.enableGenerator, "gen", false, "if true, doesnt make the saved world a void world")
|
||||
}
|
||||
func (c *WorldCMD) Usage() string {
|
||||
return c.Name() + ": " + c.Synopsis() + "\n" + SERVER_ADDRESS_HELP
|
||||
|
@ -316,7 +319,8 @@ func (w *WorldState) SaveAndReset() {
|
|||
|
||||
// set gamerules
|
||||
ld := provider.LevelDat()
|
||||
for _, gr := range w.ServerConn.GameData().GameRules {
|
||||
gd := w.ServerConn.GameData()
|
||||
for _, gr := range gd.GameRules {
|
||||
switch gr.Name {
|
||||
case "commandblockoutput":
|
||||
ld.CommandBlockOutput = gr.Value.(bool)
|
||||
|
@ -384,9 +388,13 @@ func (w *WorldState) SaveAndReset() {
|
|||
}
|
||||
}
|
||||
|
||||
ld.RandomSeed = int64(gd.WorldSeed)
|
||||
|
||||
// void world
|
||||
ld.FlatWorldLayers = `{"biome_id":1,"block_layers":[{"block_data":0,"block_id":0,"count":1},{"block_data":0,"block_id":0,"count":2},{"block_data":0,"block_id":0,"count":1}],"encoding_version":3,"structure_options":null}`
|
||||
ld.Generator = 2
|
||||
if w.voidgen {
|
||||
ld.FlatWorldLayers = `{"biome_id":1,"block_layers":[{"block_data":0,"block_id":0,"count":1},{"block_data":0,"block_id":0,"count":2},{"block_data":0,"block_id":0,"count":1}],"encoding_version":3,"structure_options":null}`
|
||||
ld.Generator = 2
|
||||
}
|
||||
|
||||
provider.SaveSettings(s)
|
||||
provider.Close()
|
||||
|
@ -418,6 +426,7 @@ func (c *WorldCMD) handleConn(ctx context.Context, l *minecraft.Listener, cc, sc
|
|||
w.ServerName = server_name
|
||||
w.ClientConn = cc
|
||||
w.ServerConn = sc
|
||||
w.voidgen = !c.enableGenerator
|
||||
|
||||
if c.packs {
|
||||
fmt.Println("reformatting packs")
|
||||
|
|
Loading…
Reference in New Issue