package net.minecraft.client.renderer.entity;

import net.minecraft.world.entity.Entity;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.Mth;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.SkullModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.projectile.WitherSkull;

public class WitherSkullRenderer extends EntityRenderer<WitherSkull> {
    private static final ResourceLocation WITHER_INVULNERABLE_LOCATION;
    private static final ResourceLocation WITHER_LOCATION;
    private final SkullModel model;
    
    public WitherSkullRenderer(final EntityRenderDispatcher dvf) {
        super(dvf);
        this.model = new SkullModel();
    }
    
    @Override
    protected int getBlockLightLevel(final WitherSkull azl, final float float2) {
        return 15;
    }
    
    @Override
    public void render(final WitherSkull azl, final float float2, final float float3, final PoseStack cyl, final MultiBufferSource dqt, final int integer) {
        cyl.pushPose();
        cyl.scale(-1.0f, -1.0f, 1.0f);
        final float float4 = Mth.rotlerp(azl.yRotO, azl.yRot, float3);
        final float float5 = Mth.lerp(float3, azl.xRotO, azl.xRot);
        final VertexConsumer cyo10 = dqt.getBuffer(this.model.renderType(this.getTextureLocation(azl)));
        this.model.setupAnim(0.0f, float4, float5);
        this.model.renderToBuffer(cyl, cyo10, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f);
        cyl.popPose();
        super.render(azl, float2, float3, cyl, dqt, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final WitherSkull azl) {
        return azl.isDangerous() ? WitherSkullRenderer.WITHER_INVULNERABLE_LOCATION : WitherSkullRenderer.WITHER_LOCATION;
    }
    
    static {
        WITHER_INVULNERABLE_LOCATION = new ResourceLocation("textures/entity/wither/wither_invulnerable.png");
        WITHER_LOCATION = new ResourceLocation("textures/entity/wither/wither.png");
    }
}
