aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexture.java
blob: 7c6f69ead063036125b0e2070199be9ffb44630a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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<ArmorMaterial.Layer> overrideLayers(
        ArmorMaterial instance,
        Operation<List<ArmorMaterial.Layer>> original,
        @Local ItemStack itemStack
    ) {
        var overrides = CustomGlobalArmorOverrides.overrideArmor(itemStack);
        if (overrides == null)
            return original.call(instance);
        return overrides;
    }
}