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{ s := server.Server{
ListPingHandler: serverInfo, ListPingHandler: serverInfo,
LoginHandler: &server.MojangLoginHandler{ LoginHandler: &server.MojangLoginHandler{
OnlineMode: true, OnlineMode: false,
Threshold: 256, Threshold: 256,
}, },
GamePlay: &server.Game{ GamePlay: &server.Game{

View File

@ -11,42 +11,36 @@ import (
// Column is 16* chunk // Column is 16* chunk
type Column struct { type Column struct {
DataVersion int DataVersion int32
Level struct { XPos int32 `nbt:"xPos"`
Heightmaps map[string][]int64 YPos int32 `nbt:"yPos"`
Structures struct { ZPos int32 `nbt:"zPos"`
References map[string][]int64 BlockEntities nbt.RawMessage `nbt:"block_entities"`
Starts map[string]struct { Structures nbt.RawMessage `nbt:"structures"`
ID string `nbt:"id"` 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 {
// 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
}
}
type Chunk struct {
Palette []Block
Y byte Y byte
BlockLight []byte BlockStates struct {
BlockStates []int64 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 SkyLight []byte
BlockLight []byte
} `nbt:"sections"`
} }
type Block struct { type BlockState struct {
Name string Name string
Properties map[string]interface{} Properties nbt.RawMessage
} }
// Load read column data from []byte // Load read column data from []byte

View File

@ -6,18 +6,17 @@ import (
) )
func TestColumn(t *testing.T) { func TestColumn(t *testing.T) {
var c Column
r, err := region.Open("testdata/region/r.0.0.mca") r, err := region.Open("testdata/region/r.0.0.mca")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer r.Close() defer r.Close()
var c Column
data, err := r.ReadSector(0, 0) data, err := r.ReadSector(0, 0)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
err = c.Load(data) err = c.Load(data)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -36,10 +35,13 @@ func BenchmarkColumn_Load(b *testing.B) {
defer r.Close() defer r.Close()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
x, y := (i%1024)/32, (i%1024)%32 x, z := (i%1024)/32, (i%1024)%32
//x, y := rand.Intn(32), rand.Intn(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 { if err != nil {
b.Fatal(err) 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 // ReadSector find and read the Chunk data from region
func (r *Region) ReadSector(x, y int) (data []byte, err error) { func (r *Region) ReadSector(x, z int) (data []byte, err error) {
offset, _ := sectorLoc(r.offsets[x][y]) offset, _ := sectorLoc(r.offsets[x][z])
if offset == 0 { if offset == 0 {
return nil, errors.New("sector not exist") 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": { "minecraft:adventure/adventuring_time": {
"criteria": { "criteria": {
"minecraft:plains": "2019-07-31 15:56:59 +0800" "minecraft:forest": "2021-12-19 20:04:35 +0800"
}, },
"done": false "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 { func (s *SimpleDim) Info() DimInfo {
return DimInfo{ return DimInfo{
Name: "minecraft:overworld", Name: "minecraft:overworld",
HashedSeed: 0, HashedSeed: 1234567,
} }
} }