@Override
  public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    PropertyDoom doom = PropertyDoom.get(player);

    if (!super.onLeftClickEntity(stack, player, entity)
        && entity instanceof EntityLivingBase
        && itemRand.nextInt(4) == 0
        && canUseAbility(doom, TragicConfig.doomAbilityCost[34])
        && getStackCooldown(stack) == 0
        && TragicConfig.doomAbility[34]) {
      ((EntityLivingBase) entity)
          .addPotionEffect(new PotionEffect(Potion.wither.id, 60, itemRand.nextInt(4)));
      if (!player.capabilities.isCreativeMode) doom.increaseDoom(-TragicConfig.doomAbilityCost[34]);
      setStackCooldown(stack, 5);
    }
    return super.onLeftClickEntity(stack, player, entity);
  }
  @Override
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    PropertyDoom doom = PropertyDoom.get(par3EntityPlayer);

    Vec3 vec = WorldHelper.getVecFromEntity(par3EntityPlayer);
    if (vec == null) return par1ItemStack;

    if (doom != null && !par2World.isRemote && getStackCooldown(par1ItemStack) == 0) {
      double d4 = vec.xCoord - par3EntityPlayer.posX;
      double d5 = vec.yCoord - (par3EntityPlayer.posY + par3EntityPlayer.height / 2.0F);
      double d6 = vec.zCoord - par3EntityPlayer.posZ;

      if (!par3EntityPlayer.isSneaking()) {
        if (canUseAbility(doom, TragicConfig.doomAbilityCost[35]) && TragicConfig.doomAbility[35]) {
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[35]);
          setStackCooldown(par1ItemStack, 5);

          EntityWitherSkull skull = new EntityWitherSkull(par2World, par3EntityPlayer, d4, d5, d6);
          skull.posY += par3EntityPlayer.getEyeHeight();
          par2World.spawnEntityInWorld(skull);
          return par1ItemStack;
        }
      } else {
        if (canUseAbility(doom, TragicConfig.doomAbilityCost[36]) && TragicConfig.doomAbility[36]) {
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[36]);
          setStackCooldown(par1ItemStack, 5);

          EntityWitherSkull skull = new EntityWitherSkull(par2World, par3EntityPlayer, d4, d5, d6);
          skull.posY += par3EntityPlayer.getEyeHeight();
          skull.setInvulnerable(true);
          par2World.spawnEntityInWorld(skull);
          return par1ItemStack;
        }
      }
    }

    return par1ItemStack;
  }
  @Override
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    PropertyDoom doom = PropertyDoom.get(par3EntityPlayer);

    if (!par3EntityPlayer.isSneaking()
        || !TragicWeapon.canUseAbility(doom, TragicConfig.doomAbilityCost[5])) {
      ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
      MinecraftForge.EVENT_BUS.post(event);
      if (event.isCanceled()) return event.result;

      if (par3EntityPlayer.capabilities.isCreativeMode
          || par3EntityPlayer.inventory.hasItem(Items.arrow)) {
        par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
      }
    } else {
      if (TragicWeapon.getStackCooldown(par1ItemStack) == 0 && TragicConfig.doomAbility[8]) {
        float f = 1.0F;
        float f1 =
            par3EntityPlayer.prevRotationPitch
                + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f;
        float f2 =
            par3EntityPlayer.prevRotationYaw
                + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f;
        double d0 =
            par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * f;
        double d1 =
            par3EntityPlayer.prevPosY
                + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * f
                + (par3EntityPlayer.worldObj.isRemote
                    ? par3EntityPlayer.getEyeHeight() - par3EntityPlayer.getDefaultEyeHeight()
                    : par3EntityPlayer
                        .getEyeHeight()); // isRemote check to revert changes to ray trace position
        // due to adding the eye height clientside and player
        // yOffset differences
        double d2 =
            par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * f;
        Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
        float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 50.0D;

        if (par3EntityPlayer instanceof EntityPlayerMP) {
          d3 =
              ((EntityPlayerMP) par3EntityPlayer).theItemInWorldManager.getBlockReachDistance()
                  + 46.0;
        }

        Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
        MovingObjectPosition mop =
            par3EntityPlayer.worldObj.func_147447_a(vec3, vec31, true, false, true);

        if (mop == null) {
          if (!par2World.isRemote)
            par3EntityPlayer.addChatMessage(new ChatComponentText("Out of range to teleport to!"));
          return par1ItemStack;
        }

        if (mop.typeOfHit == MovingObjectType.BLOCK
            && par3EntityPlayer instanceof EntityPlayerMP
            && ((EntityPlayerMP) par3EntityPlayer)
                .playerNetServerHandler
                .func_147362_b()
                .isChannelOpen()) {
          if (par3EntityPlayer.isRiding()) par3EntityPlayer.mountEntity((Entity) null);

          double d4 = WorldHelper.getXPositionFromSide(mop.sideHit, mop.hitVec.xCoord);
          double d5 = WorldHelper.getYPositionFromSide(mop.sideHit, mop.hitVec.yCoord);
          double d6 = WorldHelper.getZPositionFromSide(mop.sideHit, mop.hitVec.zCoord);

          par3EntityPlayer.setPositionAndUpdate(d4, d5, d6);
          par3EntityPlayer.fallDistance = 0.0F;
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[8]);
          TragicWeapon.setStackCooldown(par1ItemStack, 5);
        }
      }
    }
    return par1ItemStack;
  }