package net.minecraft.world.entity.projectile;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.damagesource.DamageSource;
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 LargeFireball extends Fireball {
    public int explosionPower;
    
    public LargeFireball(final EntityType<? extends LargeFireball> aku, final Level bjw) {
        super(aku, bjw);
        this.explosionPower = 1;
    }
    
    public LargeFireball(final Level bjw, 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, bjw);
        this.explosionPower = 1;
    }
    
    public LargeFireball(final Level bjw, final LivingEntity akz, final double double3, final double double4, final double double5) {
        super(EntityType.FIREBALL, akz, double3, double4, double5, bjw);
        this.explosionPower = 1;
    }
    
    @Override
    protected void onHit(final HitResult cvi) {
        super.onHit(cvi);
        if (!this.level.isClientSide) {
            if (cvi.getType() == HitResult.Type.ENTITY) {
                final Entity akq3 = ((EntityHitResult)cvi).getEntity();
                akq3.hurt(DamageSource.fireball(this, this.owner), 6.0f);
                this.doEnchantDamageEffects(this.owner, akq3);
            }
            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
    public void addAdditionalSaveData(final CompoundTag jt) {
        super.addAdditionalSaveData(jt);
        jt.putInt("ExplosionPower", this.explosionPower);
    }
    
    @Override
    public void readAdditionalSaveData(final CompoundTag jt) {
        super.readAdditionalSaveData(jt);
        if (jt.contains("ExplosionPower", 99)) {
            this.explosionPower = jt.getInt("ExplosionPower");
        }
    }
}
