From fbe94315a45082bdf50d0a95583725352e3f20ec Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 17 Apr 2024 16:17:52 +0200 Subject: Add armor retexturing for skyblock items --- .../features/texturepack/CustomSkyBlockTextures.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt index 66c0036..3fb5e9c 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt @@ -14,6 +14,7 @@ import net.minecraft.block.SkullBlock import net.minecraft.client.MinecraftClient import net.minecraft.client.render.RenderLayer import net.minecraft.client.util.ModelIdentifier +import net.minecraft.item.ItemStack import net.minecraft.util.Identifier import moe.nea.firmament.events.CustomItemModelEvent import moe.nea.firmament.events.TickEvent @@ -70,6 +71,23 @@ object CustomSkyBlockTextures : FirmamentFeature { return Identifier("firmskyblock", "textures/placedskull/$id.png") } + fun getArmorTexture( + itemStack: ItemStack, secondLayer: Boolean, + overlay: String? + ): Identifier? { + val modelIdentifier = CustomItemModelEvent.getModelIdentifier(itemStack) ?: return null + // Vanilla scheme: "textures/models/armor/" + var10000 + "_layer_" + (secondLayer ? 2 : 1) + (overlay == null ? "" : "_" + overlay) + ".png"; + val overlayPart = if (overlay != null) "_$overlay" else "" + val identifier = Identifier( + modelIdentifier.namespace, + "textures/models/armor/${modelIdentifier.path}_layer_${if (secondLayer) 2 else 1}$overlayPart.png" + ) + if (MC.resourceManager.getResource(identifier).isPresent) { + return identifier + } + return null + } + fun modifySkullTexture( type: SkullBlock.SkullType?, profile: GameProfile?, -- cgit