item renderer: try to get block model first

Dirty hack.
This commit is contained in:
Moritz Zwerger 2023-11-14 18:21:13 +01:00
parent ba6b795dab
commit 442a06a6c9
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 28 additions and 1 deletions

View File

@ -33,6 +33,7 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ColorElement
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
import de.bixilon.minosoft.gui.rendering.models.item.ItemRenderUtil.getModel
class RawItemElement(
guiRenderer: GUIRenderer,
@ -77,7 +78,7 @@ class RawItemElement(
val textureSize = size - 1
val item = stack.item.item
val model = item.model
val model = item.getModel(guiRenderer)
if (model != null) {
val tints = context.tints.getItemTint(stack)
model.render(guiRenderer, offset, consumer, options, textureSize, stack, tints)

View File

@ -0,0 +1,26 @@
/*
* 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.gui.rendering.models.item
import de.bixilon.minosoft.data.registries.item.items.Item
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
object ItemRenderUtil {
@Deprecated("please let this be the last fucking hack in this game") // TODO
fun Item.getModel(gui: GUIRenderer): ItemRender? {
val block = gui.connection.registries.block[identifier]
return block?.model ?: block?.states?.default?.model ?: model
}
}