package com.acethewildfire.acesbs.item.custom;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.List;


public class SmeltingShovel extends ShovelItem {

    public SmeltingShovel(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
        super(material, attackDamage, attackSpeed, settings);
    }

    @Override
    public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) {
        if (!world.isClient() && miner instanceof PlayerEntity player) {

            List<ItemStack> drops = Block.getDroppedStacks(state, (ServerWorld) world, pos, null, player, stack);

            for (ItemStack drop : drops) {
                stack.damage(drop.getCount(), miner, EquipmentSlot.MAINHAND);
            }
        }

        return super.postMine(stack, world, state, pos, miner);
    }
}
