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 com.mojang.math.Vector3f;
import net.minecraft.util.Mth;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.ShulkerBulletModel;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.projectile.ShulkerBullet;

public class ShulkerBulletRenderer extends EntityRenderer<ShulkerBullet> {
    private static final ResourceLocation TEXTURE_LOCATION;
    private static final RenderType RENDER_TYPE;
    private final ShulkerBulletModel<ShulkerBullet> model;
    
    public ShulkerBulletRenderer(final EntityRenderDispatcher dvf) {
        super(dvf);
        this.model = new ShulkerBulletModel<ShulkerBullet>();
    }
    
    @Override
    protected int getBlockLightLevel(final ShulkerBullet aza, final float float2) {
        return 15;
    }
    
    @Override
    public void render(final ShulkerBullet aza, final float float2, final float float3, final PoseStack cyl, final MultiBufferSource dqt, final int integer) {
        cyl.pushPose();
        final float float4 = Mth.rotlerp(aza.yRotO, aza.yRot, float3);
        final float float5 = Mth.lerp(float3, aza.xRotO, aza.xRot);
        final float float6 = aza.tickCount + float3;
        cyl.translate(0.0, 0.15000000596046448, 0.0);
        cyl.mulPose(Vector3f.YP.rotationDegrees(Mth.sin(float6 * 0.1f) * 180.0f));
        cyl.mulPose(Vector3f.XP.rotationDegrees(Mth.cos(float6 * 0.1f) * 180.0f));
        cyl.mulPose(Vector3f.ZP.rotationDegrees(Mth.sin(float6 * 0.15f) * 360.0f));
        cyl.scale(-0.5f, -0.5f, 0.5f);
        this.model.setupAnim(aza, 0.0f, 0.0f, 0.0f, float4, float5);
        final VertexConsumer cyo11 = dqt.getBuffer(this.model.renderType(ShulkerBulletRenderer.TEXTURE_LOCATION));
        this.model.renderToBuffer(cyl, cyo11, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f);
        cyl.scale(1.5f, 1.5f, 1.5f);
        final VertexConsumer cyo12 = dqt.getBuffer(ShulkerBulletRenderer.RENDER_TYPE);
        this.model.renderToBuffer(cyl, cyo12, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 0.15f);
        cyl.popPose();
        super.render(aza, float2, float3, cyl, dqt, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final ShulkerBullet aza) {
        return ShulkerBulletRenderer.TEXTURE_LOCATION;
    }
    
    static {
        TEXTURE_LOCATION = new ResourceLocation("textures/entity/shulker/spark.png");
        RENDER_TYPE = RenderType.entityTranslucent(ShulkerBulletRenderer.TEXTURE_LOCATION);
    }
}
