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 egm) {
        super(egm);
        this.shadowRadius = 0.5f;
    }
    
    @Override
    public void render(final PrimedTnt bbh, final float float2, final float float3, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        dhl.pushPose();
        dhl.translate(0.0, 0.5, 0.0);
        if (bbh.getLife() - float3 + 1.0f < 10.0f) {
            float float4 = 1.0f - (bbh.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;
            dhl.scale(float5, float5, float5);
        }
        dhl.mulPose(Vector3f.YP.rotationDegrees(-90.0f));
        dhl.translate(-0.5, -0.5, 0.5);
        dhl.mulPose(Vector3f.YP.rotationDegrees(90.0f));
        TntMinecartRenderer.renderWhiteSolidBlock(Blocks.TNT.defaultBlockState(), dhl, ebz, integer, bbh.getLife() / 5 % 2 == 0);
        dhl.popPose();
        super.render(bbh, float2, float3, dhl, ebz, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final PrimedTnt bbh) {
        return TextureAtlas.LOCATION_BLOCKS;
    }
}
