use a better lookup than a hash.

with a perfect index function in val, there is no need to hash.
val is an incremented int, starting at 0, with every index up to the current max in use; there is no point in calculating a hash from the int then storing (with potential collisions) in a hashmap, when we can use the known int as a direct index to an array with 0 overhead, and 0 chance of collision.

Also, 
for(X x : hashMap.keySet())
hashmap.get(x) is quite poor and very slow code, and should be fixed, even if this PR is rejected.

much faster code (especially when hashing could be expensive) is:
for(Entry<X,Y> e: hashMap.EntrySet() )
e.getValue() 

In most java implementations hashMap does extra hashing of whatever key is passed to it, so Integer.HashValue() + another 20 or so extra HashMap.Hash() cpu operations is vastly more expensive than a simple member get.

This may resolve slow recipe lookups in various which are ore dictionary aware, and have to look up recipes every other tick. (ie, most crafting type blocks)