aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/texturepack/BakedModelExtra.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-06 16:14:10 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-06 16:14:10 +0100
commitee21f2da76ea2218ef6a0c6fefa97befa654d115 (patch)
treeaeefb78518a83d37a025673f6cadaa7d89d87449 /src/main/kotlin/features/texturepack/BakedModelExtra.kt
parented3e9f0d70a758ac1c23c6c8d67eeb7105d13817 (diff)
downloadFirmament-ee21f2da76ea2218ef6a0c6fefa97befa654d115.tar.gz
Firmament-ee21f2da76ea2218ef6a0c6fefa97befa654d115.tar.bz2
Firmament-ee21f2da76ea2218ef6a0c6fefa97befa654d115.zip
Fix model unwrapping
Diffstat (limited to 'src/main/kotlin/features/texturepack/BakedModelExtra.kt')
-rw-r--r--src/main/kotlin/features/texturepack/BakedModelExtra.kt23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/kotlin/features/texturepack/BakedModelExtra.kt b/src/main/kotlin/features/texturepack/BakedModelExtra.kt
index 32f419a..6305748 100644
--- a/src/main/kotlin/features/texturepack/BakedModelExtra.kt
+++ b/src/main/kotlin/features/texturepack/BakedModelExtra.kt
@@ -1,11 +1,30 @@
-
package moe.nea.firmament.features.texturepack
+import net.fabricmc.fabric.api.renderer.v1.model.WrapperBakedModel as WrapperBakedModelFabric
import net.minecraft.client.render.model.BakedModel
+import net.minecraft.client.render.model.WrapperBakedModel
+import moe.nea.firmament.util.ErrorUtil
interface BakedModelExtra {
+ companion object {
+ @JvmStatic
+ fun cast(originalModel: BakedModel): BakedModelExtra? {
+ var p = originalModel
+ for (i in 0..256) {
+ p = when (p) {
+ is BakedModelExtra -> return p
+ is WrapperBakedModel -> p.wrapped
+ is WrapperBakedModelFabric -> WrapperBakedModelFabric.unwrap(p)
+ else -> break
+ }
+ }
+ ErrorUtil.softError("Could not find a baked model for $originalModel")
+ return null
+ }
+ }
+
var tintOverrides_firmament: TintOverrides?
fun getHeadModel_firmament(): BakedModel?
- fun setHeadModel_firmament(headModel: BakedModel?)
+ fun setHeadModel_firmament(headModel: BakedModel?)
}