diff --git a/level/anvil/chunk.go b/level/anvil/chunk.go index 6bb0d84..1f8ffd8 100644 --- a/level/anvil/chunk.go +++ b/level/anvil/chunk.go @@ -42,7 +42,7 @@ func (c Chunk) ToStorage(version string) (toChunk *level.Chunk, err error) { if err != nil { return } - toChunk.Sections[i].BlockCount = int16(level.CountStorage(toChunk.Sections[i].Blocks, 0)) + toChunk.Sections[i].BlockCount = int16(level.BlocksPerChunkSection - level.CountStorage(toChunk.Sections[i].Blocks, 0)) } else { toChunk.Sections[i].Blocks, err = f.FullWith(0) //TODO PALLETE index 0 if avial if err != nil { diff --git a/level/anvil/level_test.go b/level/anvil/level_test.go index 8434dd5..f070d6f 100644 --- a/level/anvil/level_test.go +++ b/level/anvil/level_test.go @@ -75,20 +75,20 @@ func TestConverToPacket(t *testing.T) { t.Errorf("Failed to read chunk: %v", err) return } - var chunk anvil.Chunk - err = nbt.Format.Decode(n.Value, &chunk) + var anvilChunk anvil.Chunk + err = nbt.Format.Decode(n.Value, &anvilChunk) if err != nil { t.Errorf("Failed to decode chunk: %v", err) return } - var packetChunk *level.Chunk - packetChunk, err = chunk.ToStorage("1.21.11") + var anvilPacketableChunk *level.Chunk + anvilPacketableChunk, err = anvilChunk.ToStorage("1.21.11") if err != nil { t.Errorf("Failed to convert chunk: %v", err) return } buffer := bytes.NewBuffer(nil) - err = packetChunk.WriteChunkData(buffer) + err = anvilPacketableChunk.WriteChunkData(buffer) if err != nil { t.Errorf("Failed to write chunk data: %v", err) return @@ -120,8 +120,8 @@ func TestConverToPacket(t *testing.T) { return a.Equals(b) }) - if !aChunk.Equals(packetChunk) { - t.Errorf("Chunk is different: %v", cmp.Diff(aChunk, packetChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{}))) + if !aChunk.Equals(anvilPacketableChunk) { + t.Errorf("Chunk is different: %v", cmp.Diff(aChunk, anvilPacketableChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{}))) } if !bChunk.Equals(aChunk) { t.Errorf("Chunk is different: %v", cmp.Diff(bChunk, aChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{}))) diff --git a/level/anvil/testdata/chunk00.bin b/level/anvil/testdata/chunk00.bin new file mode 100644 index 0000000..156be94 Binary files /dev/null and b/level/anvil/testdata/chunk00.bin differ