package net.minecraft.world.entity.projectile;

import net.minecraft.world.damagesource.DamageSource;
import java.util.Iterator;
import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.EntityType;

public class DragonFireball extends AbstractHurtingProjectile {
    public DragonFireball(final EntityType<? extends DragonFireball> aku, final Level bjw) {
        super(aku, bjw);
    }
    
    public DragonFireball(final Level bjw, final double double2, final double double3, final double double4, final double double5, final double double6, final double double7) {
        super(EntityType.DRAGON_FIREBALL, double2, double3, double4, double5, double6, double7, bjw);
    }
    
    public DragonFireball(final Level bjw, final LivingEntity akz, final double double3, final double double4, final double double5) {
        super(EntityType.DRAGON_FIREBALL, akz, double3, double4, double5, bjw);
    }
    
    @Override
    protected void onHit(final HitResult cvi) {
        super.onHit(cvi);
        if (cvi.getType() == HitResult.Type.ENTITY && ((EntityHitResult)cvi).getEntity().is(this.owner)) {
            return;
        }
        if (!this.level.isClientSide) {
            final List<LivingEntity> list3 = this.level.<LivingEntity>getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(4.0, 2.0, 4.0));
            final AreaEffectCloud akp4 = new AreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ());
            akp4.setOwner(this.owner);
            akp4.setParticle(ParticleTypes.DRAGON_BREATH);
            akp4.setRadius(3.0f);
            akp4.setDuration(600);
            akp4.setRadiusPerTick((7.0f - akp4.getRadius()) / akp4.getDuration());
            akp4.addEffect(new MobEffectInstance(MobEffects.HARM, 1, 1));
            if (!list3.isEmpty()) {
                for (final LivingEntity akz6 : list3) {
                    final double double7 = this.distanceToSqr(akz6);
                    if (double7 < 16.0) {
                        akp4.setPos(akz6.getX(), akz6.getY(), akz6.getZ());
                        break;
                    }
                }
            }
            this.level.levelEvent(2006, new BlockPos(this), 0);
            this.level.addFreshEntity(akp4);
            this.remove();
        }
    }
    
    @Override
    public boolean isPickable() {
        return false;
    }
    
    @Override
    public boolean hurt(final DamageSource ajz, final float float2) {
        return false;
    }
    
    @Override
    protected ParticleOptions getTrailParticle() {
        return ParticleTypes.DRAGON_BREATH;
    }
    
    @Override
    protected boolean shouldBurn() {
        return false;
    }
}
