Example usage for net.minecraftforge.common ForgeHooks isToolEffective

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

Introduction

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

Prototype

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

Source Link

Usage

From source file:blusunrize.immersiveengineering.common.items.ItemDrill.java

@Override
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos,
        EntityLivingBase living) {//from   w  w w  . j av a  2s. co  m
    if ((double) state.getBlockHardness(world, pos) != 0.0D) {
        int dmg = ForgeHooks.isToolEffective(world, pos, stack) ? 1 : 3;
        ItemStack head = getHead(stack);
        if (!head.isEmpty()) {
            if (living instanceof EntityPlayer) {
                if (((EntityPlayer) living).capabilities.isCreativeMode)
                    return true;
                ((IDrillHead) head.getItem()).afterBlockbreak(stack, head, (EntityPlayer) living);
            }
            if (!getUpgrades(stack).getBoolean("oiled") || Utils.RAND.nextInt(4) == 0)
                ((IDrillHead) head.getItem()).damageHead(head, dmg);
            this.setHead(stack, head);
            IFluidHandler handler = FluidUtil.getFluidHandler(stack);
            handler.drain(1, true);

            Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry
                    .getStoredShaderAndCase(stack);
            if (shader != null)
                shader.getMiddle().getEffectFunction().execute(world, shader.getLeft(), stack,
                        shader.getRight().getShaderType(),
                        new Vec3d(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5), null, .375f);
        }
    }

    return true;
}

From source file:com.kegare.caveworld.util.CaveUtils.java

License:Minecraft Mod Public

public static boolean isItemPickaxe(ItemStack itemstack) {
    if (itemstack != null && itemstack.stackSize > 0) {
        Item item = itemstack.getItem();

        if (item != null && item.isItemTool(itemstack)) {
            if (item instanceof ItemPickaxe) {
                return true;
            } else if (item.getToolClasses(itemstack).contains("pickaxe")) {
                return true;
            } else if (ForgeHooks.isToolEffective(itemstack, Blocks.stone, 0)) {
                return true;
            }//  ww  w.  j  av a2  s  .  com
        }
    }

    return false;
}

From source file:com.shinoow.abyssalcraft.common.items.ItemEthaxiumPickaxe.java

License:Apache License

@Override
public float getDigSpeed(ItemStack stack, Block block, int meta) {
    if (effectiveBlocks.contains(block))
        return efficiencyOnProperMaterial * 10;
    if (ForgeHooks.isToolEffective(stack, block, meta))
        return efficiencyOnProperMaterial;
    return super.getDigSpeed(stack, block, meta);
}

From source file:electricMagicTools.tombenpotter.electricmagictools.common.items.tools.ItemRockbreakerDrill.java

License:Open Source License

@SuppressWarnings("rawtypes")
@Override//from w  w  w . ja  va 2  s  . c  om
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z,
        EntityLivingBase entityLiving) {
    if (Config.toolsInBore == false) {
        cost = 350;
    } else {
        cost = 1;
    }
    if (entityLiving.isSneaking()) {
        if (ElectricItem.manager.canUse(stack, cost)) {
            ElectricItem.manager.use(stack, cost, entityLiving);
        }
        return true;
    }
    int md = world.getBlockMetadata(x, y, z);
    if (ForgeHooks.isToolEffective(stack, block, md) || isEffectiveAgainst(block)) {
        for (int aa = -1; aa <= 1; aa++) {
            for (int bb = -1; bb <= 1; bb++) {
                int xx = 0;
                int yy = 0;
                int zz = 0;
                if (side <= 1) {
                    xx = aa;
                    zz = bb;
                } else if (side <= 3) {
                    xx = aa;
                    yy = bb;
                } else {
                    zz = aa;
                    yy = bb;
                }
                Block bl = world.getBlock(x + xx, y + yy, z + zz);
                md = world.getBlockMetadata(x + xx, y + yy, z + zz);
                if (!ForgeHooks.isToolEffective(stack, bl, md) && !isEffectiveAgainst(bl)) {
                    continue;
                }
                if (ElectricItem.manager.canUse(stack, cost)) {
                    ElectricItem.manager.use(stack, cost, entityLiving);
                }
                int fortune = EnchantmentHelper.getFortuneModifier(entityLiving);
                world.setBlockToAir(x + xx, y + yy, z + zz);
                ArrayList ret = bl.getDrops(world, x + xx, y + yy, z + zz, md, fortune);
                boolean creative = false;
                if ((entityLiving instanceof EntityPlayer)
                        && ((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
                    creative = true;
                }
                if (ret.size() <= 0 || creative || ((Entity) (entityLiving)).worldObj.isRemote) {
                    continue;
                }
                ItemStack is;
                for (Iterator i$ = ret.iterator(); i$.hasNext(); world
                        .spawnEntityInWorld(new EntityFollowingItem(world, (double) x + (double) xx + 0.5D,
                                (double) y + (double) yy + 0.5D, (double) z + (double) zz + 0.5D, is,
                                entityLiving, 3))) {
                    is = (ItemStack) i$.next();
                }
            }
        }
    }
    return true;
}

From source file:forestry.apiculture.items.ItemScoop.java

License:Open Source License

@Override
public float getStrVsBlock(ItemStack itemstack, Block block, int md) {
    if (ForgeHooks.isToolEffective(itemstack, block, md))
        return efficiencyOnProperMaterial;

    return getStrVsBlock(itemstack, block);
}

From source file:forestry.arboriculture.items.ItemGrafter.java

License:Open Source License

@Override
public float getDigSpeed(ItemStack itemstack, Block block, int md) {
    if (ForgeHooks.isToolEffective(itemstack, block, md)) {
        return efficiencyOnProperMaterial;
    }/* w  w  w  .  j a  v  a 2s  .  c  om*/

    return func_150893_a(itemstack, block);
}

From source file:forestry.core.items.ItemForestryTool.java

License:Open Source License

@Override
public float getDigSpeed(ItemStack itemstack, Block block, int md) {
    if (ForgeHooks.isToolEffective(itemstack, block, md)) {
        return efficiencyOnProperMaterial;
    }/*w w w.j a va 2s  .co  m*/
    return func_150893_a(itemstack, block);
}

From source file:forestry.core.items.ItemScoop.java

License:Open Source License

@Override
public float getDigSpeed(ItemStack itemstack, Block block, int md) {
    if (ForgeHooks.isToolEffective(itemstack, block, md))
        return efficiencyOnProperMaterial;

    return func_150893_a(itemstack, block);
}

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

License:Minecraft Mod Public

@Override
public float getDigSpeed(ItemStack stack, Block block, int metadata) {
    if (this.isSteampowered() && !stack.getTagCompound().getBoolean("hasCanister"))
        return 0.1F;

    if (ForgeHooks.isToolEffective(stack, block, metadata) || this.canHarvestBlock(block, stack)) {
        return this.efficiencyOnProperMaterial;
    }//from w  ww . j a v a 2  s . co  m

    return super.getDigSpeed(stack, block, metadata);
}

From source file:tombenpotter.emt.common.items.tools.drills.ItemRockbreakerDrill.java

License:Open Source License

@SuppressWarnings("rawtypes")
@Override//from   ww w.j av  a 2  s .c o  m
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z,
        EntityLivingBase entityLiving) {
    if (ConfigHandler.toolsInBore == false) {
        cost = 350;
    } else {
        cost = 1;
    }
    if (entityLiving.isSneaking()) {
        if (ElectricItem.manager.canUse(stack, cost)) {
            ElectricItem.manager.use(stack, cost, entityLiving);
        }
        return true;
    }
    int md = world.getBlockMetadata(x, y, z);
    if (ForgeHooks.isToolEffective(stack, block, md) || isEffectiveAgainst(block)) {
        for (int aa = -1; aa <= 1; aa++) {
            for (int bb = -1; bb <= 1; bb++) {
                int xx = 0;
                int yy = 0;
                int zz = 0;
                if (side <= 1) {
                    xx = aa;
                    zz = bb;
                } else if (side <= 3) {
                    xx = aa;
                    yy = bb;
                } else {
                    zz = aa;
                    yy = bb;
                }
                Block bl = world.getBlock(x + xx, y + yy, z + zz);
                md = world.getBlockMetadata(x + xx, y + yy, z + zz);
                if (!ForgeHooks.isToolEffective(stack, bl, md) && !isEffectiveAgainst(bl)) {
                    continue;
                }
                if (ElectricItem.manager.canUse(stack, cost)) {
                    ElectricItem.manager.use(stack, cost, entityLiving);
                }
                int fortune = EnchantmentHelper.getFortuneModifier(entityLiving);
                world.setBlockToAir(x + xx, y + yy, z + zz);
                ArrayList ret = bl.getDrops(world, x + xx, y + yy, z + zz, md, fortune);
                boolean creative = false;
                if ((entityLiving instanceof EntityPlayer)
                        && ((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
                    creative = true;
                }
                if (ret.size() <= 0 || creative || ((Entity) (entityLiving)).worldObj.isRemote) {
                    continue;
                }
                ItemStack is;
                for (Iterator i$ = ret.iterator(); i$.hasNext(); world
                        .spawnEntityInWorld(new EntityFollowingItem(world, (double) x + (double) xx + 0.5D,
                                (double) y + (double) yy + 0.5D, (double) z + (double) zz + 0.5D, is,
                                entityLiving, 3))) {
                    is = (ItemStack) i$.next();
                }
            }
        }
    }
    return true;
}