mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
port custom block model
This commit is contained in:
parent
b16eab2278
commit
4c4bea729d
@ -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
|
||||
}
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user