From fac6103658b2c8d6bab3598606d57041cfe16e0c Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Tue, 28 May 2024 22:25:27 +0200 Subject: Add armor texture overrides --- .../mixins/custommodels/PatchArmorTexture.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java (limited to 'src/main/java/moe/nea/firmament') diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java new file mode 100644 index 0000000..bfbfcc5 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins.custommodels; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import moe.nea.firmament.features.texturepack.CustomGlobalArmorOverrides; +import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; +import net.minecraft.item.ArmorMaterial; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.List; + +@Mixin(ArmorFeatureRenderer.class) +public class PatchArmorTexture { + @WrapOperation( + method = "renderArmor", + at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ArmorMaterial;layers()Ljava/util/List;")) + private List overrideLayers( + ArmorMaterial instance, + Operation> original, + @Local ItemStack itemStack + ) { + var overrides = CustomGlobalArmorOverrides.overrideArmor(itemStack); + if (overrides == null) + return original.call(instance); + return overrides; + } +} -- cgit