package net.minecraft.world.entity.monster;

import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.nbt.CompoundTag;
import javax.annotation.Nullable;
import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.item.Items;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.monster.piglin.Piglin;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.EntityType;

public class WitherSkeleton extends AbstractSkeleton {
    public WitherSkeleton(final EntityType<? extends WitherSkeleton> aoq, final Level bqb) {
        super(aoq, bqb);
        this.setPathfindingMalus(BlockPathTypes.LAVA, 8.0f);
    }
    
    @Override
    protected void registerGoals() {
        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Piglin.class, true));
        super.registerGoals();
    }
    
    @Override
    protected SoundEvent getAmbientSound() {
        return SoundEvents.WITHER_SKELETON_AMBIENT;
    }
    
    @Override
    protected SoundEvent getHurtSound(final DamageSource anw) {
        return SoundEvents.WITHER_SKELETON_HURT;
    }
    
    @Override
    protected SoundEvent getDeathSound() {
        return SoundEvents.WITHER_SKELETON_DEATH;
    }
    
    @Override
    SoundEvent getStepSound() {
        return SoundEvents.WITHER_SKELETON_STEP;
    }
    
    @Override
    protected void dropCustomDeathLoot(final DamageSource anw, final int integer, final boolean boolean3) {
        super.dropCustomDeathLoot(anw, integer, boolean3);
        final Entity aom5 = anw.getEntity();
        if (aom5 instanceof Creeper) {
            final Creeper bbn6 = (Creeper)aom5;
            if (bbn6.canDropMobsSkull()) {
                bbn6.increaseDroppedSkulls();
                this.spawnAtLocation(Items.WITHER_SKELETON_SKULL);
            }
        }
    }
    
    @Override
    protected void populateDefaultEquipmentSlots(final DifficultyInstance ane) {
        this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD));
    }
    
    @Override
    protected void populateDefaultEquipmentEnchantments(final DifficultyInstance ane) {
    }
    
    @Nullable
    @Override
    public SpawnGroupData finalizeSpawn(final LevelAccessor bqc, final DifficultyInstance ane, final MobSpawnType apb, @Nullable final SpawnGroupData apo, @Nullable final CompoundTag le) {
        final SpawnGroupData apo2 = super.finalizeSpawn(bqc, ane, apb, apo, le);
        this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0);
        this.reassessWeaponGoal();
        return apo2;
    }
    
    @Override
    protected float getStandingEyeHeight(final Pose apj, final EntityDimensions aon) {
        return 2.1f;
    }
    
    @Override
    public boolean doHurtTarget(final Entity aom) {
        if (!super.doHurtTarget(aom)) {
            return false;
        }
        if (aom instanceof LivingEntity) {
            ((LivingEntity)aom).addEffect(new MobEffectInstance(MobEffects.WITHER, 200));
        }
        return true;
    }
    
    @Override
    protected AbstractArrow getArrow(final ItemStack bki, final float float2) {
        final AbstractArrow beg4 = super.getArrow(bki, float2);
        beg4.setSecondsOnFire(100);
        return beg4;
    }
    
    @Override
    public boolean canBeAffected(final MobEffectInstance aog) {
        return aog.getEffect() != MobEffects.WITHER && super.canBeAffected(aog);
    }
}
