Skip to content

Commit a9c5e30

Browse files
committed
fix: schem palette ordering
1 parent 076e2c2 commit a9c5e30

File tree

1 file changed

+7
-6
lines changed
  • common/src/main/kotlin/com/lambda/util/extension

1 file changed

+7
-6
lines changed

common/src/main/kotlin/com/lambda/util/extension/World.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ private fun StructureTemplate.readSpongeV1OrException(
9494
// ?.let { fastVectorOf(it[0], it[1], it[2]) }
9595
// ?.takeIf { 274945015809L times 16 < it } ?: 0L
9696

97-
val paletteMax = nbt.getInt("PaletteMax")
9897
val palette = nbt.getCompound("Palette")
9998

100-
check(palette.size == paletteMax) {
101-
"Block palette size does not match the provided size (corrupted?)"
102-
}
103-
99+
val paletteMax = nbt.getInt("PaletteMax")
104100
val newPalette = NbtList()
105101

106-
palette.keys.forEach { key ->
102+
if (palette.size != paletteMax) return IllegalStateException("Block palette size does not match the provided size (corrupted?)")
103+
104+
palette.keys
105+
.sortedBy { palette.getInt(it) }
106+
.forEach { key ->
107107
val resource = key.substringBefore('[')
108108
val blockState = NbtCompound()
109109

@@ -116,6 +116,7 @@ private fun StructureTemplate.readSpongeV1OrException(
116116
?.associate { it.substringBefore('=') to it.substringAfter('=') }
117117
?.forEach { (key, value) -> blockState.putString(key, value) }
118118

119+
// Populate the list using the correct indices
119120
newPalette.add(NbtCompound().apply {
120121
putString("Name", resource)
121122
put("Properties", blockState)

0 commit comments

Comments
 (0)