Example usage for net.minecraftforge.common ForgeHooks canToolHarvestBlock

List of usage examples for net.minecraftforge.common ForgeHooks canToolHarvestBlock

Introduction

In this page you can find the example usage for net.minecraftforge.common ForgeHooks canToolHarvestBlock.

Prototype

public static boolean canToolHarvestBlock(IWorldReader world, BlockPos pos, @Nonnull ItemStack stack) 

Source Link

Usage

From source file:buildcraft.core.properties.WorldPropertyIsOre.java

License:Minecraft Mod Public

private void initBlockHarvestTools() {
    // Make sure the static code block in the ForgeHooks class is run
    ForgeHooks.canToolHarvestBlock(Blocks.coal_ore, 0, new ItemStack(Items.diamond_pickaxe));
}

From source file:buildcraft.core.robots.AIRobotBreak.java

License:Minecraft Mod Public

private float getBreakSpeed(EntityRobotBase robot, ItemStack usingItem, Block block, int meta) {
    ItemStack stack = usingItem;//from   ww w  . ja  v  a2s  . c  o  m
    float f = stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, block, meta);

    if (f > 1.0F) {
        int i = EnchantmentHelper.getEfficiencyModifier(robot);
        ItemStack itemstack = usingItem;

        if (i > 0 && itemstack != null) {
            float f1 = i * i + 1;

            boolean canHarvest = ForgeHooks.canToolHarvestBlock(block, meta, itemstack);

            if (!canHarvest && f <= 1.0F) {
                f += f1 * 0.08F;
            } else {
                f += f1;
            }
        }
    }

    return f;
}

From source file:buildcraft.robotics.ai.AIRobotBreak.java

License:Minecraft Mod Public

private float getBreakSpeed(EntityRobotBase robot, ItemStack usingItem, Block block, int meta) {
    ItemStack stack = usingItem;/*from w  w  w  . j  a  v a2s .  com*/
    float f = stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, block, meta);

    if (f > 1.0F) {
        int i = EnchantmentHelper.getEfficiencyModifier(robot);

        if (i > 0) {
            float f1 = i * i + 1;

            boolean canHarvest = ForgeHooks.canToolHarvestBlock(block, meta, usingItem);

            if (!canHarvest && f <= 1.0F) {
                f += f1 * 0.08F;
            } else {
                f += f1;
            }
        }
    }

    f = ForgeEventFactory.getBreakSpeed(
            BlockUtils.getFakePlayerWithTool((WorldServer) robot.worldObj, blockToBreak.x, blockToBreak.y,
                    blockToBreak.z, robot.getHeldItem()),
            block, meta, f, blockToBreak.x, blockToBreak.y, blockToBreak.z);
    return f < 0 ? 0 : f;
}

From source file:steamcraft.common.items.tools.ItemModTool.java

License:Minecraft Mod Public

@Override
public boolean canHarvestBlock(Block block, ItemStack stack) {
    return ForgeHooks.canToolHarvestBlock(block, 0/* TODO */, stack);
}