port custom block model

This commit is contained in:
Bixilon 2023-03-29 12:52:47 +02:00
parent b16eab2278
commit 4c4bea729d
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,22 @@
/*
* Minosoft
* Copyright (C) 2020-2023 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.blocks.types.legacy
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.protocol.versions.Version
interface CustomBlockModel {
fun getModelName(version: Version) = modelName
val modelName: ResourceLocation? get() = null
}

View File

@ -38,7 +38,7 @@ class BlockLoader(private val loader: ModelLoader) {
}
fun loadState(block: Block): DirectBlockModel? {
val file = (if (block is CustomBlockModel) block.getModelName(version) else block.identifier).blockState()
val file = (if (block is CustomBlockModel) block.getModelName(version) else block.identifier)?.blockState() ?: return null
val data = assets[file].readJsonObject()
return DirectBlockModel.deserialize(this, data)