fix legacy shulker box model loading

This commit is contained in:
Moritz Zwerger 2023-11-10 08:05:56 +01:00
parent f5e3d29826
commit 7ced54d5dd
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 10 additions and 3 deletions

View File

@ -42,7 +42,7 @@ enum class DyeColors {
fun DyeColors.name(packFormat: Int) = when {
packFormat >= FLATTENING && this == LIGHT_GRAY -> "silver"
packFormat < FLATTENING && this == LIGHT_GRAY -> "silver"
else -> name.lowercase()
}
}

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.chunk.entities.renderer.storage.shulke
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.minosoft.assets.minecraft.MinecraftPackFormat.FLATTENING
import de.bixilon.minosoft.data.colors.DyeColors
import de.bixilon.minosoft.data.colors.DyeColors.Companion.name
import de.bixilon.minosoft.data.entities.block.container.storage.ShulkerBoxBlockEntity
@ -79,14 +80,20 @@ class ShulkerBoxRenderer(
)
override fun register(loader: ModelLoader) {
load(NAME, texture, loader)
if (loader.packFormat > FLATTENING) {
load(NAME, texture, loader) // was purple color instead
}
for (color in DyeColors) {
val texture = minecraft("entity/shulker/shulker_${color.name(loader.packFormat)}").texture()
val texture = color.texture(loader.packFormat)
load(NAME_COLOR[color.ordinal], texture, loader)
}
}
private fun DyeColors.texture(packFormat: Int): ResourceLocation {
return minecraft("entity/shulker/shulker_${name(packFormat)}").texture()
}
private fun load(name: ResourceLocation, texture: ResourceLocation, loader: ModelLoader) {
val texture = loader.context.textures.staticTextures.createTexture(texture)
loader.skeletal.register(name, TEMPLATE, override = mapOf(this.named to texture))