update /save

This commit is contained in:
Tnze
2021-12-20 00:55:41 +08:00
parent 1bce379779
commit 8eaae6a202
28 changed files with 40 additions and 44 deletions

View File

@ -32,7 +32,7 @@ func main() {
s := server.Server{
ListPingHandler: serverInfo,
LoginHandler: &server.MojangLoginHandler{
OnlineMode: true,
OnlineMode: false,
Threshold: 256,
},
GamePlay: &server.Game{

View File

@ -11,42 +11,36 @@ import (
// Column is 16* chunk
type Column struct {
DataVersion int
Level struct {
Heightmaps map[string][]int64
Structures struct {
References map[string][]int64
Starts map[string]struct {
ID string `nbt:"id"`
}
}
// Entities
// LiquidTicks
// PostProcessing
Sections []Chunk
// TileEntities
// TileTicks
InhabitedTime int64
IsLightOn byte `nbt:"isLightOn"`
LastUpdate int64
Status string
PosX int32 `nbt:"xPos"`
PosZ int32 `nbt:"zPos"`
Biomes []int32
DataVersion int32
XPos int32 `nbt:"xPos"`
YPos int32 `nbt:"yPos"`
ZPos int32 `nbt:"zPos"`
BlockEntities nbt.RawMessage `nbt:"block_entities"`
Structures nbt.RawMessage `nbt:"structures"`
Heightmaps struct {
MotionBlocking []int64 `nbt:"MOTION_BLOCKING"`
MotionBlockingNoLeaves []int64 `nbt:"MOTION_BLOCKING_NO_LEAVES"`
OceanFloor []int64 `nbt:"OCEAN_FLOOR"`
WorldSurface []int64 `nbt:"WORLD_SURFACE"`
}
Sections []struct {
Y byte
BlockStates struct {
Palette []BlockState `nbt:"palette"`
Data []int64 `nbt:"data"`
} `nbt:"block_states"`
Biomes struct {
Palette []string `nbt:"palette"`
Data []int64 `nbt:"data"`
} `nbt:"biomes"`
SkyLight []byte
BlockLight []byte
} `nbt:"sections"`
}
type Chunk struct {
Palette []Block
Y byte
BlockLight []byte
BlockStates []int64
SkyLight []byte
}
type Block struct {
type BlockState struct {
Name string
Properties map[string]interface{}
Properties nbt.RawMessage
}
// Load read column data from []byte

View File

@ -6,18 +6,17 @@ import (
)
func TestColumn(t *testing.T) {
var c Column
r, err := region.Open("testdata/region/r.0.0.mca")
if err != nil {
t.Fatal(err)
}
defer r.Close()
var c Column
data, err := r.ReadSector(0, 0)
if err != nil {
t.Fatal(err)
}
err = c.Load(data)
if err != nil {
t.Fatal(err)
@ -36,10 +35,13 @@ func BenchmarkColumn_Load(b *testing.B) {
defer r.Close()
for i := 0; i < b.N; i++ {
x, y := (i%1024)/32, (i%1024)%32
//x, y := rand.Intn(32), rand.Intn(32)
x, z := (i%1024)/32, (i%1024)%32
//x, z := rand.Intn(32), rand.Intn(32)
if !r.ExistSector(x, z) {
continue
}
data, err := r.ReadSector(x, y)
data, err := r.ReadSector(x, z)
if err != nil {
b.Fatal(err)
}

View File

@ -121,8 +121,8 @@ func sectorLoc(offset int32) (sec, num int32) {
}
// ReadSector find and read the Chunk data from region
func (r *Region) ReadSector(x, y int) (data []byte, err error) {
offset, _ := sectorLoc(r.offsets[x][y])
func (r *Region) ReadSector(x, z int) (data []byte, err error) {
offset, _ := sectorLoc(r.offsets[x][z])
if offset == 0 {
return nil, errors.New("sector not exist")

BIN
save/testdata/DIM-1/data/raids.dat vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,9 +1,9 @@
{
"minecraft:adventure/adventuring_time": {
"criteria": {
"minecraft:plains": "2019-07-31 15:56:59 +0800"
"minecraft:forest": "2021-12-19 20:04:35 +0800"
},
"done": false
},
"DataVersion": 1976
"DataVersion": 2865
}

Binary file not shown.

BIN
save/testdata/entities/r.-1.-1.mca vendored Normal file

Binary file not shown.

BIN
save/testdata/entities/r.-1.0.mca vendored Normal file

Binary file not shown.

BIN
save/testdata/entities/r.0.-1.mca vendored Normal file

Binary file not shown.

BIN
save/testdata/entities/r.0.0.mca vendored Normal file

Binary file not shown.

BIN
save/testdata/icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Binary file not shown.

BIN
save/testdata/poi/r.-1.-1.mca vendored Normal file

Binary file not shown.

BIN
save/testdata/poi/r.0.-1.mca vendored Normal file

Binary file not shown.

BIN
save/testdata/poi/r.0.0.mca vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
{"stats":{"minecraft:custom":{"minecraft:time_since_rest":6,"minecraft:play_one_minute":6,"minecraft:leave_game":1,"minecraft:time_since_death":6}},"DataVersion":1976}
{"stats":{"minecraft:custom":{"minecraft:time_since_rest":14,"minecraft:leave_game":1,"minecraft:play_time":14,"minecraft:time_since_death":14,"minecraft:total_world_time":77}},"DataVersion":2865}

View File

@ -152,7 +152,7 @@ func (s *SimpleDim) LoadChunk(pos ChunkPos, c *Chunk) {
func (s *SimpleDim) Info() DimInfo {
return DimInfo{
Name: "minecraft:overworld",
HashedSeed: 0,
HashedSeed: 1234567,
}
}