package net.minecraft.client.renderer.entity;

import net.minecraft.world.entity.Entity;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Blocks;
import com.mojang.math.Vector3f;
import net.minecraft.util.Mth;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.world.entity.item.PrimedTnt;

public class TntRenderer extends EntityRenderer<PrimedTnt> {
    public TntRenderer(final EntityRenderDispatcher dvf) {
        super(dvf);
        this.shadowRadius = 0.5f;
    }
    
    @Override
    public void render(final PrimedTnt awc, final float float2, final float float3, final PoseStack cyl, final MultiBufferSource dqt, final int integer) {
        cyl.pushPose();
        cyl.translate(0.0, 0.5, 0.0);
        if (awc.getLife() - float3 + 1.0f < 10.0f) {
            float float4 = 1.0f - (awc.getLife() - float3 + 1.0f) / 10.0f;
            float4 = Mth.clamp(float4, 0.0f, 1.0f);
            float4 *= float4;
            float4 *= float4;
            final float float5 = 1.0f + float4 * 0.3f;
            cyl.scale(float5, float5, float5);
        }
        cyl.mulPose(Vector3f.YP.rotationDegrees(-90.0f));
        cyl.translate(-0.5, -0.5, 0.5);
        cyl.mulPose(Vector3f.YP.rotationDegrees(90.0f));
        TntMinecartRenderer.renderWhiteSolidBlock(Blocks.TNT.defaultBlockState(), cyl, dqt, integer, awc.getLife() / 5 % 2 == 0);
        cyl.popPose();
        super.render(awc, float2, float3, cyl, dqt, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final PrimedTnt awc) {
        return TextureAtlas.LOCATION_BLOCKS;
    }
}
