package net.mcreator.customoregen.item;

import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Item;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Block;

import net.mcreator.customoregen.init.CustomOreGenModItems;
import net.mcreator.customoregen.config.ModConfigs;

public class SharddiamondpaxelItem extends PickaxeItem {
	public SharddiamondpaxelItem() {
		super(new Tier() {
			public int getUses() {
				return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelDurability.get() : 1000;
			}

			public float getSpeed() {
				return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelSpeed.get().floatValue() : 6.5f;
			}

			public float getAttackDamageBonus() {
				return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelAttackDamage.get().floatValue() : 4.0f;
			}

			public int getEnchantmentValue() {
				return 14;
			}

			public Ingredient getRepairIngredient() {
				return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
			}

			// 1.21 - new method required - returns diamond-tier incorrect blocks
			public TagKey<Block> getIncorrectBlocksForDrops() {
				return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
			}
		}, new Item.Properties());
	}

	@Override
	public int getMaxDamage(ItemStack stack) {
		return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelDurability.get() : 1000;
	}

	@Override
	public float getDestroySpeed(ItemStack stack, BlockState state) {
		// Effective on all blocks that pickaxe, shovel, or axe can mine
		if (state.is(BlockTags.MINEABLE_WITH_PICKAXE) ||
		    state.is(BlockTags.MINEABLE_WITH_SHOVEL) ||
		    state.is(BlockTags.MINEABLE_WITH_AXE)) {
			return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelSpeed.get().floatValue() : 6.5f;
		}
		return super.getDestroySpeed(stack, state);
	}

	@Override
	public boolean isCorrectToolForDrops(ItemStack stack, BlockState state) {
		// Can mine blocks that require pickaxe, shovel, or axe
		// In 1.21, we check the tags directly without needing to check tier level
		if (state.is(BlockTags.MINEABLE_WITH_PICKAXE) ||
		    state.is(BlockTags.MINEABLE_WITH_SHOVEL) ||
		    state.is(BlockTags.MINEABLE_WITH_AXE)) {
			// For diamond-tier blocks, we need to verify our tool is diamond-tier
			// Since this is a diamond-equivalent tool, it should work on all non-obsidian blocks
			// The parent class PickaxeItem handles the actual tier check
			return super.isCorrectToolForDrops(stack, state);
		}
		return false;
	}
}
