Skip to content

Commit

Permalink
chunk/encoding.go: Check if block version is pre-1.13 instead of miss…
Browse files Browse the repository at this point in the history
…ing states field
  • Loading branch information
TwistedAsylumMC committed Sep 6, 2024
1 parent 42801f6 commit b4ac40c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/world/chunk/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Check failure on line 71 in server/world/chunk/encoding.go

View workflow job for this annotation

GitHub Actions / Build

unnecessary assignment to the blank identifier (S1005)
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.
Expand All @@ -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 {
Expand Down

0 comments on commit b4ac40c

Please sign in to comment.