refactor chunk version handling; improve logging in equality checks and storage import logic

This commit is contained in:
adman
2026-05-05 13:30:21 +02:00
parent e5231dfdb6
commit 00ea02a529
3 changed files with 10 additions and 9 deletions
+9 -4
View File
@@ -1,15 +1,18 @@
package level
import "io"
import (
"io"
"log/slog"
)
type Chunk struct {
Sections []Section
version string
Version string
}
func ReadChunkFromChunkPacketData(r io.Reader, version string, worldHeight int) (c *Chunk, err error) {
c = &Chunk{}
c.version = version
c.Version = version
nSections := worldHeight / ChunkWidth
c.Sections = make([]Section, nSections)
@@ -33,10 +36,12 @@ func (c *Chunk) WriteChunkData(w io.Writer) (err error) {
}
func (c *Chunk) Equals(other *Chunk) bool {
if c.version != other.version {
if c.Version != other.Version {
slog.Debug("Chunk versions don't match: ", "version 1", c.Version, "version2", other.Version)
return false
}
if len(c.Sections) != len(other.Sections) {
slog.Debug("Chunk section len does not match: ", "chunk1 len", len(c.Sections), "chunk 2 len", len(other.Sections))
return false
}
for i, s := range c.Sections {