better error in level packet decoder

This commit is contained in:
adman
2025-12-16 00:03:14 +01:00
parent 66ff4b6d1e
commit cb38382a07
+5 -1
View File
@@ -2,6 +2,7 @@ package level
import ( import (
"encoding/binary" "encoding/binary"
"errors"
"fmt" "fmt"
"io" "io"
"math" "math"
@@ -91,10 +92,13 @@ func UnpackBlockData(r io.Reader) (blocks [BlocksPerChunkSection]int32, err erro
case 1, 2, 3, 4: case 1, 2, 3, 4:
blocksSlice, err = UnpackArrayPalette(r, bitsPerEntry, BlocksPerChunkSection) blocksSlice, err = UnpackArrayPalette(r, bitsPerEntry, BlocksPerChunkSection)
case 5, 6, 7, 8: case 5, 6, 7, 8:
panic("unimplemented") err = errors.New("unimplemented")
default: default:
blocksSlice, err = UnpackLongData(r, bitsPerEntry, BlocksPerChunkSection) blocksSlice, err = UnpackLongData(r, bitsPerEntry, BlocksPerChunkSection)
} }
if err != nil {
return
}
blocks = [BlocksPerChunkSection]int32(blocksSlice) blocks = [BlocksPerChunkSection]int32(blocksSlice)
return return
} }