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.core.BlockPos;
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 egm) {
        super(egm);
        this.model = new SkullModel();
    }
    
    @Override
    protected int getBlockLightLevel(final WitherSkull bff, final BlockPos fu) {
        return 15;
    }
    
    @Override
    public void render(final WitherSkull bff, final float float2, final float float3, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        dhl.pushPose();
        dhl.scale(-1.0f, -1.0f, 1.0f);
        final float float4 = Mth.rotlerp(bff.yRotO, bff.yRot, float3);
        final float float5 = Mth.lerp(float3, bff.xRotO, bff.xRot);
        final VertexConsumer dhp10 = ebz.getBuffer(this.model.renderType(this.getTextureLocation(bff)));
        this.model.setupAnim(0.0f, float4, float5);
        this.model.renderToBuffer(dhl, dhp10, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f);
        dhl.popPose();
        super.render(bff, float2, float3, dhl, ebz, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final WitherSkull bff) {
        return bff.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");
    }
}
