block models: allow loading of models with broken block properties

This commit is contained in:
Bixilon 2023-09-28 13:43:21 +02:00
parent 642c381484
commit ea183139a7
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 10 additions and 3 deletions

View File

@ -18,6 +18,9 @@ import de.bixilon.minosoft.data.registries.blocks.properties.BlockProperties
import de.bixilon.minosoft.gui.rendering.models.block.state.DirectBlockModel
import de.bixilon.minosoft.gui.rendering.models.block.state.apply.BlockStateApply
import de.bixilon.minosoft.gui.rendering.models.loader.BlockLoader
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
interface VariantBlockModel : DirectBlockModel {
@ -28,8 +31,12 @@ interface VariantBlockModel : DirectBlockModel {
for (pair in variant.split(',')) {
val (key, rawValue) = pair.split('=', limit = 2)
val (property, value) = BlockProperties.parseProperty(key, rawValue)
properties[property] = value
try {
val (property, value) = BlockProperties.parseProperty(key, rawValue)
properties[property] = value
} catch (error: Throwable) {
Log.log(LogMessageType.LOADING, LogLevels.WARN) { error }
}
}
return properties

View File

@ -201,7 +201,7 @@ internal class ChatComponentTest {
}
@Test
fun hypixelMotd() {
fun hypixelMotd() { // ↓ Note that extra paragraph
val string = " §aHypixel Network §c[1.8-1.19]\n §c§lLUNAR MAPS §7§l§ §6§lCOSMETICS §7| §d§lSKYBLOCK 0.17.3"
val component = ChatComponent.of(string)