Advanced level badges, like Herobrine, pull code from previously completed Herobrine badges, so if you're unable to run a badge in Herobrine, you should always go back and check your previously done Herobrine badges.
In your case, I think part of the problem is that on badge 3 you needed to right-click collapse the recipe blocks, as shown in the badge instructions. (I just fixed it for you) On badge 2771, you used the wrong kind of black js block.
Also, each time, you may need to go copy / paste the js code in the screencapped instructions into the black js block to make sure it's correct. Be careful that there's not a space before events.when
Your code should look exactly like what you see in the screencapped badge instructions. (The videos aren't always uptodate, so you should always check the screencapped instructions posted below the video.)
These are advanced level badges, so if you ever get too confused, I'd recommend going back to the Skills and Drills < Learning to Program badges. To get there, click skills and drills on the badge index page then click the 'Learning to Program' tab.