package net.minecraft.world.entity.projectile;

import net.minecraft.world.phys.HitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.EntityType;

public class SmallFireball extends Fireball {
    public SmallFireball(final EntityType<? extends SmallFireball> aoq, final Level bqb) {
        super(aoq, bqb);
    }
    
    public SmallFireball(final Level bqb, final LivingEntity aoy, final double double3, final double double4, final double double5) {
        super(EntityType.SMALL_FIREBALL, aoy, double3, double4, double5, bqb);
    }
    
    public SmallFireball(final Level bqb, final double double2, final double double3, final double double4, final double double5, final double double6, final double double7) {
        super(EntityType.SMALL_FIREBALL, double2, double3, double4, double5, double6, double7, bqb);
    }
    
    @Override
    protected void onHitEntity(final EntityHitResult dei) {
        super.onHitEntity(dei);
        if (this.level.isClientSide) {
            return;
        }
        final Entity aom3 = dei.getEntity();
        if (!aom3.fireImmune()) {
            final Entity aom4 = this.getOwner();
            final int integer5 = aom3.getRemainingFireTicks();
            aom3.setSecondsOnFire(5);
            final boolean boolean6 = aom3.hurt(DamageSource.fireball(this, aom4), 5.0f);
            if (!boolean6) {
                aom3.setRemainingFireTicks(integer5);
            }
            else if (aom4 instanceof LivingEntity) {
                this.doEnchantDamageEffects((LivingEntity)aom4, aom3);
            }
        }
    }
    
    @Override
    protected void onHitBlock(final BlockHitResult deh) {
        super.onHitBlock(deh);
        if (this.level.isClientSide) {
            return;
        }
        final Entity aom3 = this.getOwner();
        if (aom3 == null || !(aom3 instanceof Mob) || this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
            final BlockHitResult deh2 = deh;
            final BlockPos fu5 = deh2.getBlockPos().relative(deh2.getDirection());
            if (this.level.isEmptyBlock(fu5)) {
                this.level.setBlockAndUpdate(fu5, BaseFireBlock.getState(this.level, fu5));
            }
        }
    }
    
    @Override
    protected void onHit(final HitResult dej) {
        super.onHit(dej);
        if (!this.level.isClientSide) {
            this.remove();
        }
    }
    
    @Override
    public boolean isPickable() {
        return false;
    }
    
    @Override
    public boolean hurt(final DamageSource anw, final float float2) {
        return false;
    }
}
