package com.acethewildfire.acesbs.entity.custom;

import com.acethewildfire.acesbs.item.ModItems;
import com.acethewildfire.acesbs.sounds.ModSounds;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.ai.goal.BowAttackGoal;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.mob.SkeletonEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;

public class VulgarBones extends SkeletonEntity {
    public VulgarBones(EntityType<? extends SkeletonEntity> entityType, World world) {
        super(entityType, world);
    }

    @Override
    protected SoundEvent getAmbientSound() {
        return ModSounds.VULGAR_BONES_AMBIENT;
    }

    @Override
    protected SoundEvent getHurtSound(DamageSource source) {
        return ModSounds.VULGAR_BONES_HURT;
    }

    @Override
    protected SoundEvent getDeathSound() {
        return ModSounds.VULGAR_BONES_DEATH;
    }

    @Override
    public int getMinAmbientSoundDelay() {
        return 200 + this.random.nextInt(200);
    }

    @Override
    protected void initEquipment(Random random, LocalDifficulty localDifficulty) {
        super.initEquipment(random, localDifficulty);
        this.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD));
//        this.equipStack(EquipmentSlot.OFFHAND, new ItemStack(ModItems.CIGARETTE));
    }

    @Override
    protected void initGoals() {
        super.initGoals();
        // Remove existing bow/ranged attack goal
        this.goalSelector.getGoals().removeIf(goalEntry ->
                goalEntry.getGoal() instanceof BowAttackGoal<?>
        );

        // Add melee attack AI
        this.goalSelector.add(4, new MeleeAttackGoal(this, 1.0, false));
    }
}
