12-08-2013, 07:41 AM
1, Revise the algorithm. It shouldn't be such a hog
2, Bail out quickly. If you want to navigate to a player 100 blocks away, give it up altogether. Take into account that in vanilla most mobs only track within 16 blocks away.
3, Don't call that algorithm that often. Only recalculate path when needed - once every N ticks, or if the surroundings change and the mob cannot continue along the calculated path
4, Use as few dynamic allocations as possible. Use stack-allocated values or a cache for storing lots of values of the same simple type (for example coords)
2, Bail out quickly. If you want to navigate to a player 100 blocks away, give it up altogether. Take into account that in vanilla most mobs only track within 16 blocks away.
3, Don't call that algorithm that often. Only recalculate path when needed - once every N ticks, or if the surroundings change and the mob cannot continue along the calculated path
4, Use as few dynamic allocations as possible. Use stack-allocated values or a cache for storing lots of values of the same simple type (for example coords)