multipart models: AND condition

This fixes a block model loading crash in 1.19.3
This commit is contained in:
Bixilon 2022-12-08 16:35:03 +01:00
parent 29d1074c45
commit 84a6b4d1a9
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -113,6 +113,15 @@ class MultipartRootModel(
}
return@let
}
val and = it["AND"]
if (and is List<*>) {
val andCondition: MutableMap<BlockProperties, Set<Any>> = mutableMapOf()
for (andData in and) {
andCondition += getCondition(andData.unsafeCast())
}
condition += andCondition
return@let
}
condition += getCondition(it)
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -23,14 +23,10 @@ interface RootModel {
fun getModelForState(blockState: BlockState): UnbakedModel
companion object {
operator fun invoke(modeLoader: ModelLoader, data: Map<String, Any>): RootModel? {
val variants = data["variants"]
val multipart = data["multipart"]
return when {
variants != null -> SimpleRootModel(modeLoader, variants.unsafeCast())
multipart != null -> MultipartRootModel(modeLoader, multipart.unsafeCast())
else -> TODO("Don't know what type of block state model to choose: $data")
}
operator fun invoke(modeLoader: ModelLoader, data: Map<String, Any>): RootModel {
data["variants"]?.let { return SimpleRootModel(modeLoader, it.unsafeCast()) }
data["multipart"]?.let { return MultipartRootModel(modeLoader, it.unsafeCast()) }
TODO("Don't know what type of block state model to choose: $data")
}
}
}