package net.minecraft.world.entity.projectile;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.GameRules;
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 LargeFireball extends Fireball {
    public int explosionPower;
    
    public LargeFireball(final EntityType<? extends LargeFireball> aoq, final Level bqb) {
        super(aoq, bqb);
        this.explosionPower = 1;
    }
    
    public LargeFireball(final Level bqb, final double double2, final double double3, final double double4, final double double5, final double double6, final double double7) {
        super(EntityType.FIREBALL, double2, double3, double4, double5, double6, double7, bqb);
        this.explosionPower = 1;
    }
    
    public LargeFireball(final Level bqb, final LivingEntity aoy, final double double3, final double double4, final double double5) {
        super(EntityType.FIREBALL, aoy, double3, double4, double5, bqb);
        this.explosionPower = 1;
    }
    
    @Override
    protected void onHit(final HitResult dej) {
        super.onHit(dej);
        if (!this.level.isClientSide) {
            final boolean boolean3 = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
            this.level.explode(null, this.getX(), this.getY(), this.getZ(), (float)this.explosionPower, boolean3, boolean3 ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE);
            this.remove();
        }
    }
    
    @Override
    protected void onHitEntity(final EntityHitResult dei) {
        super.onHitEntity(dei);
        if (this.level.isClientSide) {
            return;
        }
        final Entity aom3 = dei.getEntity();
        final Entity aom4 = this.getOwner();
        aom3.hurt(DamageSource.fireball(this, aom4), 6.0f);
        if (aom4 instanceof LivingEntity) {
            this.doEnchantDamageEffects((LivingEntity)aom4, aom3);
        }
    }
    
    @Override
    public void addAdditionalSaveData(final CompoundTag le) {
        super.addAdditionalSaveData(le);
        le.putInt("ExplosionPower", this.explosionPower);
    }
    
    @Override
    public void readAdditionalSaveData(final CompoundTag le) {
        super.readAdditionalSaveData(le);
        if (le.contains("ExplosionPower", 99)) {
            this.explosionPower = le.getInt("ExplosionPower");
        }
    }
}
