package net.minecraft.world.entity.projectile;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.entity.Mob;
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 SmallFireball extends Fireball {
    public SmallFireball(final EntityType<? extends SmallFireball> aku, final Level bjw) {
        super(aku, bjw);
    }
    
    public SmallFireball(final Level bjw, final LivingEntity akz, final double double3, final double double4, final double double5) {
        super(EntityType.SMALL_FIREBALL, akz, double3, double4, double5, bjw);
    }
    
    public SmallFireball(final Level bjw, 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, bjw);
    }
    
    @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();
                if (!akq3.fireImmune()) {
                    final int integer4 = akq3.getRemainingFireTicks();
                    akq3.setSecondsOnFire(5);
                    final boolean boolean5 = akq3.hurt(DamageSource.fireball(this, this.owner), 5.0f);
                    if (boolean5) {
                        this.doEnchantDamageEffects(this.owner, akq3);
                    }
                    else {
                        akq3.setRemainingFireTicks(integer4);
                    }
                }
            }
            else if (this.owner == null || !(this.owner instanceof Mob) || this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
                final BlockHitResult cvg3 = (BlockHitResult)cvi;
                final BlockPos fk4 = cvg3.getBlockPos().relative(cvg3.getDirection());
                if (this.level.isEmptyBlock(fk4)) {
                    this.level.setBlockAndUpdate(fk4, Blocks.FIRE.defaultBlockState());
                }
            }
            this.remove();
        }
    }
    
    @Override
    public boolean isPickable() {
        return false;
    }
    
    @Override
    public boolean hurt(final DamageSource ajz, final float float2) {
        return false;
    }
}
