fix block count calculation in chunk sections; improve variable naming in tests
This commit is contained in:
@@ -42,7 +42,7 @@ func (c Chunk) ToStorage(version string) (toChunk *level.Chunk, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
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 {
|
} else {
|
||||||
toChunk.Sections[i].Blocks, err = f.FullWith(0) //TODO PALLETE index 0 if avial
|
toChunk.Sections[i].Blocks, err = f.FullWith(0) //TODO PALLETE index 0 if avial
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -75,20 +75,20 @@ func TestConverToPacket(t *testing.T) {
|
|||||||
t.Errorf("Failed to read chunk: %v", err)
|
t.Errorf("Failed to read chunk: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var chunk anvil.Chunk
|
var anvilChunk anvil.Chunk
|
||||||
err = nbt.Format.Decode(n.Value, &chunk)
|
err = nbt.Format.Decode(n.Value, &anvilChunk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to decode chunk: %v", err)
|
t.Errorf("Failed to decode chunk: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var packetChunk *level.Chunk
|
var anvilPacketableChunk *level.Chunk
|
||||||
packetChunk, err = chunk.ToStorage("1.21.11")
|
anvilPacketableChunk, err = anvilChunk.ToStorage("1.21.11")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to convert chunk: %v", err)
|
t.Errorf("Failed to convert chunk: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buffer := bytes.NewBuffer(nil)
|
buffer := bytes.NewBuffer(nil)
|
||||||
err = packetChunk.WriteChunkData(buffer)
|
err = anvilPacketableChunk.WriteChunkData(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to write chunk data: %v", err)
|
t.Errorf("Failed to write chunk data: %v", err)
|
||||||
return
|
return
|
||||||
@@ -120,8 +120,8 @@ func TestConverToPacket(t *testing.T) {
|
|||||||
return a.Equals(b)
|
return a.Equals(b)
|
||||||
})
|
})
|
||||||
|
|
||||||
if !aChunk.Equals(packetChunk) {
|
if !aChunk.Equals(anvilPacketableChunk) {
|
||||||
t.Errorf("Chunk is different: %v", cmp.Diff(aChunk, packetChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{})))
|
t.Errorf("Chunk is different: %v", cmp.Diff(aChunk, anvilPacketableChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{})))
|
||||||
}
|
}
|
||||||
if !bChunk.Equals(aChunk) {
|
if !bChunk.Equals(aChunk) {
|
||||||
t.Errorf("Chunk is different: %v", cmp.Diff(bChunk, aChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{})))
|
t.Errorf("Chunk is different: %v", cmp.Diff(bChunk, aChunk, storageComparer, cmpopts.IgnoreUnexported(level.Chunk{}, level.Section{}, level.Storage{})))
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user