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.core.BlockPos;
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 egm) {
        super(egm);
        this.model = new ShulkerBulletModel<ShulkerBullet>();
    }
    
    @Override
    protected int getBlockLightLevel(final ShulkerBullet beu, final BlockPos fu) {
        return 15;
    }
    
    @Override
    public void render(final ShulkerBullet beu, final float float2, final float float3, final PoseStack dhl, final MultiBufferSource ebz, final int integer) {
        dhl.pushPose();
        final float float4 = Mth.rotlerp(beu.yRotO, beu.yRot, float3);
        final float float5 = Mth.lerp(float3, beu.xRotO, beu.xRot);
        final float float6 = beu.tickCount + float3;
        dhl.translate(0.0, 0.15000000596046448, 0.0);
        dhl.mulPose(Vector3f.YP.rotationDegrees(Mth.sin(float6 * 0.1f) * 180.0f));
        dhl.mulPose(Vector3f.XP.rotationDegrees(Mth.cos(float6 * 0.1f) * 180.0f));
        dhl.mulPose(Vector3f.ZP.rotationDegrees(Mth.sin(float6 * 0.15f) * 360.0f));
        dhl.scale(-0.5f, -0.5f, 0.5f);
        this.model.setupAnim(beu, 0.0f, 0.0f, 0.0f, float4, float5);
        final VertexConsumer dhp11 = ebz.getBuffer(this.model.renderType(ShulkerBulletRenderer.TEXTURE_LOCATION));
        this.model.renderToBuffer(dhl, dhp11, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f);
        dhl.scale(1.5f, 1.5f, 1.5f);
        final VertexConsumer dhp12 = ebz.getBuffer(ShulkerBulletRenderer.RENDER_TYPE);
        this.model.renderToBuffer(dhl, dhp12, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 0.15f);
        dhl.popPose();
        super.render(beu, float2, float3, dhl, ebz, integer);
    }
    
    @Override
    public ResourceLocation getTextureLocation(final ShulkerBullet beu) {
        return ShulkerBulletRenderer.TEXTURE_LOCATION;
    }
    
    static {
        TEXTURE_LOCATION = new ResourceLocation("textures/entity/shulker/spark.png");
        RENDER_TYPE = RenderType.entityTranslucent(ShulkerBulletRenderer.TEXTURE_LOCATION);
    }
}
