package net.minecraft.client.renderer.entity.layers;

import net.minecraft.world.entity.Entity;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer;

public class Deadmau5EarsLayer extends RenderLayer<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> {
    public Deadmau5EarsLayer(final RenderLayerParent<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> dwv) {
        super(dwv);
    }
    
    @Override
    public void render(final PoseStack cyl, final MultiBufferSource dqt, final int integer, final AbstractClientPlayer dpy, final float float5, final float float6, final float float7, final float float8, final float float9, final float float10) {
        if (!"deadmau5".equals(dpy.getName().getString()) || !dpy.isSkinLoaded() || dpy.isInvisible()) {
            return;
        }
        final VertexConsumer cyo12 = dqt.getBuffer(RenderType.entitySolid(dpy.getSkinTextureLocation()));
        final int integer2 = LivingEntityRenderer.getOverlayCoords(dpy, 0.0f);
        for (int integer3 = 0; integer3 < 2; ++integer3) {
            final float float11 = Mth.lerp(float7, dpy.yRotO, dpy.yRot) - Mth.lerp(float7, dpy.yBodyRotO, dpy.yBodyRot);
            final float float12 = Mth.lerp(float7, dpy.xRotO, dpy.xRot);
            cyl.pushPose();
            cyl.mulPose(Vector3f.YP.rotationDegrees(float11));
            cyl.mulPose(Vector3f.XP.rotationDegrees(float12));
            cyl.translate(0.375f * (integer3 * 2 - 1), 0.0, 0.0);
            cyl.translate(0.0, -0.375, 0.0);
            cyl.mulPose(Vector3f.XP.rotationDegrees(-float12));
            cyl.mulPose(Vector3f.YP.rotationDegrees(-float11));
            final float float13 = 1.3333334f;
            cyl.scale(1.3333334f, 1.3333334f, 1.3333334f);
            ((RenderLayer<T, PlayerModel>)this).getParentModel().renderEars(cyl, cyo12, integer, integer2);
            cyl.popPose();
        }
    }
}
