Skip to content

Commit

Permalink
Fix ArmorFeatureRendererMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Dec 5, 2023
1 parent b4a9a6d commit b487d79
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import com.mmodding.mmodding_lib.library.glint.client.GlintPack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.render.OverlayTexture;
Expand All @@ -20,25 +18,29 @@
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ArmorFeatureRenderer.class)
public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, A extends BipedEntityModel<T>> {

@Unique
private ItemStack ref;

@Shadow
protected abstract Identifier getArmorTexture(ArmorItem item, boolean legs, @Nullable String overlay);

@WrapOperation(method = "renderArmor", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;", ordinal = 0))
private Item renderArmor(ItemStack stack, Operation<Item> original, @Share("itemStack") LocalRef<ItemStack> ref) {
ref.set(stack);
private Item renderArmor(ItemStack stack, Operation<Item> original) {
this.ref = stack;
return original.call(stack);
}

@Inject(method = "renderArmorParts", at = @At(value = "HEAD"), cancellable = true)
private void renderArmorParts(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, ArmorItem item, boolean usesSecondLayer, A model, boolean legs, float red, float green, float blue, @Nullable String overlay, CallbackInfo ci, @Share("itemStack") LocalRef<ItemStack> ref) {
GlintPack.of(ref.get()).ifPresent(glintPack -> {
private void renderArmorParts(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, ArmorItem item, boolean usesSecondLayer, A model, boolean legs, float red, float green, float blue, @Nullable String overlay, CallbackInfo ci) {
GlintPack.of(this.ref).ifPresent(glintPack -> {
VertexConsumer vertexConsumer = glintPack.getArmorConsumer(
vertexConsumers,
RenderLayer.getArmorCutoutNoCull(this.getArmorTexture(item, legs, overlay)),
Expand Down

0 comments on commit b487d79

Please sign in to comment.