Client sided:
mouseFire(1); (you probably already knew that one)
Server sided:
%player.getDataBlock().onTrigger(%player, 0, 1);
If you really want to simulate it exactly, you can call the function again shortly after, but with the last argument as 0.