package net.minecraft.world.entity.projectile;

import net.minecraft.world.damagesource.DamageSource;
import java.util.Iterator;
import java.util.List;
import net.minecraft.world.entity.Entity;
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.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> aoq, final Level bqb) {
        super(aoq, bqb);
    }
    
    public DragonFireball(final Level bqb, 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, bqb);
    }
    
    public DragonFireball(final Level bqb, final LivingEntity aoy, final double double3, final double double4, final double double5) {
        super(EntityType.DRAGON_FIREBALL, aoy, double3, double4, double5, bqb);
    }
    
    @Override
    protected void onHit(final HitResult dej) {
        super.onHit(dej);
        final Entity aom3 = this.getOwner();
        if (dej.getType() == HitResult.Type.ENTITY && ((EntityHitResult)dej).getEntity().is(aom3)) {
            return;
        }
        if (!this.level.isClientSide) {
            final List<LivingEntity> list4 = this.level.<LivingEntity>getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(4.0, 2.0, 4.0));
            final AreaEffectCloud aol5 = new AreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ());
            if (aom3 instanceof LivingEntity) {
                aol5.setOwner((LivingEntity)aom3);
            }
            aol5.setParticle(ParticleTypes.DRAGON_BREATH);
            aol5.setRadius(3.0f);
            aol5.setDuration(600);
            aol5.setRadiusPerTick((7.0f - aol5.getRadius()) / aol5.getDuration());
            aol5.addEffect(new MobEffectInstance(MobEffects.HARM, 1, 1));
            if (!list4.isEmpty()) {
                for (final LivingEntity aoy7 : list4) {
                    final double double8 = this.distanceToSqr(aoy7);
                    if (double8 < 16.0) {
                        aol5.setPos(aoy7.getX(), aoy7.getY(), aoy7.getZ());
                        break;
                    }
                }
            }
            this.level.levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
            this.level.addFreshEntity(aol5);
            this.remove();
        }
    }
    
    @Override
    public boolean isPickable() {
        return false;
    }
    
    @Override
    public boolean hurt(final DamageSource anw, final float float2) {
        return false;
    }
    
    @Override
    protected ParticleOptions getTrailParticle() {
        return ParticleTypes.DRAGON_BREATH;
    }
    
    @Override
    protected boolean shouldBurn() {
        return false;
    }
}
