thaumcraft.common.lib.utils.BlockUtils Java Examples

The following examples show how to use thaumcraft.common.lib.utils.BlockUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemStreamChainsaw.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
    Block bi = world.getBlock(x, y, z);
    if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) {
        if (!world.isRemote) {
            if (BlockUtils.breakFurthestBlock(world, x, y, z, bi, player)) {
                world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F);
                ElectricItem.manager.use(itemstack, cost, player);
                this.alternateServer = (!this.alternateServer);
            }
        } else {
            player.swingItem();
            ElectricItem.manager.use(itemstack, cost, player);
            this.alternateClient = (!this.alternateClient);
        }
    }
    return super.onItemUse(itemstack, player, world, x, y, z, par7, par8, par9, par10);
}
 
Example #2
Source File: ItemStreamChainsaw.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) {
    World world = player.worldObj;
    Block bi = world.getBlock(x, y, z);
    if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) {
        if (!world.isRemote) {
            BlockUtils.breakFurthestBlock(world, x, y, z, bi, player);
            PacketHandler.INSTANCE.sendToAllAround(new PacketFXBlockBubble(x, y, z, new Color(0.33F, 0.33F, 1.0F).getRGB()), new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D));

            world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F);
        }
        ElectricItem.manager.use(itemstack, cost, player);
        return true;
    }
    return super.onBlockStartBreak(itemstack, x, y, z, player);
}
 
Example #3
Source File: ItemRockbreakerDrill.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) {
    MovingObjectPosition movingobjectposition = BlockUtils.getTargetBlock(((Entity) (player)).worldObj, player, true);
    if (movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
        side = movingobjectposition.sideHit;
    }
    return super.onBlockStartBreak(itemstack, X, Y, Z, player);
}
 
Example #4
Source File: ItemMorphShovel.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    MovingObjectPosition movingobjectposition = BlockUtils.getTargetBlock(player.worldObj, player, true);
    if(movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
        this.side = movingobjectposition.sideHit;
    }

    return super.onBlockStartBreak(stack, x, y, z, player);
}
 
Example #5
Source File: ItemMorphShovel.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) {
    if(EnchantmentHelper.getEnchantmentLevel(DarkEnchantments.impact.effectId, stack) <= 0)
        return super.onBlockDestroyed(stack, world, block, x, y, z, player);
    if(!player.worldObj.isRemote) {
        int meta = world.getBlockMetadata(x, y, z);
        if(ForgeHooks.isToolEffective(stack, block, meta)) {
            for(int aa = -1; aa <= 1; ++aa) {
                for(int bb = -1; bb <= 1; ++bb) {
                    int xx = 0;
                    int yy = 0;
                    int zz = 0;
                    if(this.side <= 1) {
                        xx = aa;
                        zz = bb;
                    } else if(this.side <= 3) {
                        xx = aa;
                        yy = bb;
                    } else {
                        zz = aa;
                        yy = bb;
                    }

                    if(!(player instanceof EntityPlayer) || world.canMineBlock((EntityPlayer)player, x + xx, y + yy, z + zz)) {
                        Block bl = world.getBlock(x + xx, y + yy, z + zz);
                        meta = world.getBlockMetadata(x + xx, y + yy, z + zz);
                        if(bl.getBlockHardness(world, x + xx, y + yy, z + zz) >= 0.0F && ForgeHooks.isToolEffective(stack, bl, meta)) {
                            stack.damageItem(1, player);
                            BlockUtils.harvestBlock(world, (EntityPlayer)player, x + xx, y + yy, z + zz, true, 2);
                        }
                    }
                }
            }
        }
        else
            return super.onBlockDestroyed(stack, world, block, x, y, z, player);
    }

    return super.onBlockDestroyed(stack, world, block, x, y, z, player);
}
 
Example #6
Source File: ItemMorphPickaxe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    MovingObjectPosition movingobjectposition = BlockUtils.getTargetBlock(player.worldObj, player, true);
    if(movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
        this.side = movingobjectposition.sideHit;
    }

    return super.onBlockStartBreak(stack, x, y, z, player);
}
 
Example #7
Source File: ItemMorphPickaxe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) {
    if(EnchantmentHelper.getEnchantmentLevel(DarkEnchantments.impact.effectId, stack) <= 0)
        return super.onBlockDestroyed(stack, world, block, x, y, z, player);
    if(!player.worldObj.isRemote) {
        int meta = world.getBlockMetadata(x, y, z);
        if(ForgeHooks.isToolEffective(stack, block, meta)) {
            for(int aa = -1; aa <= 1; ++aa) {
                for(int bb = -1; bb <= 1; ++bb) {
                    int xx = 0;
                    int yy = 0;
                    int zz = 0;
                    if(this.side <= 1) {
                        xx = aa;
                        zz = bb;
                    } else if(this.side <= 3) {
                        xx = aa;
                        yy = bb;
                    } else {
                        zz = aa;
                        yy = bb;
                    }

                    if(!(player instanceof EntityPlayer) || world.canMineBlock((EntityPlayer)player, x + xx, y + yy, z + zz)) {
                        Block bl = world.getBlock(x + xx, y + yy, z + zz);
                        meta = world.getBlockMetadata(x + xx, y + yy, z + zz);
                        if(bl.getBlockHardness(world, x + xx, y + yy, z + zz) >= 0.0F && ForgeHooks.isToolEffective(stack, bl, meta)) {
                            stack.damageItem(1, player);
                            BlockUtils.harvestBlock(world, (EntityPlayer)player, x + xx, y + yy, z + zz, true, 2);
                        }
                    }
                }
            }
        }
        else
            return super.onBlockDestroyed(stack, world, block, x, y, z, player);
    }

    return super.onBlockDestroyed(stack, world, block, x, y, z, player);
}