Deadrik/TFCraft — pull request #576 by ProgrammerHero (2014-08-06 15:46:16+00:00)
Title:  [0.79] Removing unnecessary tick handlers

[updated from PR #573 to fix merge conflicts]

The player's tick handler covers more ground than it needs to. This will lead to some unneeded calculations every tick that can be eliminated. This may be a small optimization - its that little piece of me that craves high performance computing by removing wasted cpu cycles.

The changes:
The EntityLivingHandler was processing the EntityLivingUpdate for every loaded entity and each time it was asking "instanceof Player". Instead, I changed the handler to listen for PlayerTickEvent (and renamed the class accordingly) which is the player specific version of EntityLivingUpdate. This will cause the listener to fire twice per tick per player (pre and post - post is ignored) instead of once per loaded entity. A weird side-effect is we have to register this listener on two message buses.

I have played with this for some time, and it ticked properly in all my play-testing.

You can see the difference between the two events by looking at
EntityPlayer:274 - the player's tick event
EntityLivingBase:1774 - every other entity's tick event (also fired by the player on EntityPlayer:342)