package at.petrak.hexcasting.fabric.mixin;

import at.petrak.hexcasting.common.items.ItemJewelerHammer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BlockBehaviour.class)
public class FabricBlockBehaviorMixin {
    @Inject(method = "getDestroyProgress", at = @At("HEAD"), cancellable = true)
    private void destroyProgress(BlockState blockState, Player player, BlockGetter blockGetter, BlockPos blockPos,
        CallbackInfoReturnable<Float> cir) {
        if (ItemJewelerHammer.shouldFailToBreak(player, blockState, blockPos)) {
            cir.setReturnValue(0F);
        }
    }
}
