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.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import com.mojang.math.Vector3f;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.world.entity.projectile.FireworkRocketEntity;

public class FireworkEntityRenderer extends EntityRenderer<FireworkRocketEntity> {
    private final ItemRenderer itemRenderer;
    
    public FireworkEntityRenderer(final EntityRenderDispatcher egm, final ItemRenderer ehh) {
        super(egm);
        this.itemRenderer = ehh;
    }
    
    @Override
    public void render(final FireworkRocketEntity ben, final float float2, final float float3, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        dhl.pushPose();
        dhl.mulPose(this.entityRenderDispatcher.cameraOrientation());
        dhl.mulPose(Vector3f.YP.rotationDegrees(180.0f));
        if (ben.isShotAtAngle()) {
            dhl.mulPose(Vector3f.ZP.rotationDegrees(180.0f));
            dhl.mulPose(Vector3f.YP.rotationDegrees(180.0f));
            dhl.mulPose(Vector3f.XP.rotationDegrees(90.0f));
        }
        this.itemRenderer.renderStatic(ben.getItem(), ItemTransforms.TransformType.GROUND, integer, OverlayTexture.NO_OVERLAY, dhl, ebz);
        dhl.popPose();
        super.render(ben, float2, float3, dhl, ebz, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final FireworkRocketEntity ben) {
        return TextureAtlas.LOCATION_BLOCKS;
    }
}
