From b4ac40c838a61800523bb1839d3351e51c2db919 Mon Sep 17 00:00:00 2001 From: TwistedAsylumMC Date: Fri, 6 Sep 2024 16:25:12 +0100 Subject: [PATCH] chunk/encoding.go: Check if block version is pre-1.13 instead of missing states field --- server/world/chunk/encoding.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/world/chunk/encoding.go b/server/world/chunk/encoding.go index 6e3e07114..63d26ef68 100644 --- a/server/world/chunk/encoding.go +++ b/server/world/chunk/encoding.go @@ -68,9 +68,9 @@ func (blockPaletteEncoding) decode(buf *bytes.Buffer) (uint32, error) { version, _ := m["version"].(int32) // Now check for a state field. - stateI, ok := m["states"] - if !ok { - // If it doesn't exist, this is likely a pre-1.13 block state, so decode the meta value instead. + stateI, _ := m["states"] + if version < 17694723 { + // This entry is a pre-1.13 block state, so decode the meta value instead. meta, _ := m["val"].(int16) // Upgrade the pre-1.13 state into a post-1.13 state. @@ -83,6 +83,10 @@ func (blockPaletteEncoding) decode(buf *bytes.Buffer) (uint32, error) { name = state.Name stateI = state.State version = state.Version + } else if stateI == nil { + // The state is a post-1.13 block state, but the states field is missing, likely due to a broken world + // conversion. + stateI = make(map[string]any) } state, ok := stateI.(map[string]any) if !ok {