package net.minecraft.client.renderer.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 net.minecraft.world.entity.projectile.ItemSupplier;
import com.mojang.math.Vector3f;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.core.BlockPos;

public class ThrownItemRenderer<T extends Entity> extends EntityRenderer<T> {
    private final ItemRenderer itemRenderer;
    private final float scale;
    private final boolean fullBright;
    
    public ThrownItemRenderer(final EntityRenderDispatcher egm, final ItemRenderer ehh, final float float3, final boolean boolean4) {
        super(egm);
        this.itemRenderer = ehh;
        this.scale = float3;
        this.fullBright = boolean4;
    }
    
    public ThrownItemRenderer(final EntityRenderDispatcher egm, final ItemRenderer ehh) {
        this(egm, ehh, 1.0f, false);
    }
    
    @Override
    protected int getBlockLightLevel(final T aom, final BlockPos fu) {
        return this.fullBright ? 15 : super.getBlockLightLevel(aom, fu);
    }
    
    @Override
    public void render(final T aom, final float float2, final float float3, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        if (((Entity)aom).tickCount < 2 && this.entityRenderDispatcher.camera.getEntity().distanceToSqr((Entity)aom) < 12.25) {
            return;
        }
        dhl.pushPose();
        dhl.scale(this.scale, this.scale, this.scale);
        dhl.mulPose(this.entityRenderDispatcher.cameraOrientation());
        dhl.mulPose(Vector3f.YP.rotationDegrees(180.0f));
        this.itemRenderer.renderStatic(((ItemSupplier)aom).getItem(), ItemTransforms.TransformType.GROUND, integer, OverlayTexture.NO_OVERLAY, dhl, ebz);
        dhl.popPose();
        super.render(aom, float2, float3, dhl, ebz, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final Entity aom) {
        return TextureAtlas.LOCATION_BLOCKS;
    }
}
