What is the hash method for minecraft?



  • I heard that if you input a non-number into the seed box (or a number larger than 2⁶⁴), it will use a hash method to turn this into a number (less than or equal to 2⁶⁴). My question:
    What is the hash method Minecraft uses? (I use the Bedrock Edition)



  • According to https://minecraft.fandom.com/wiki/Seed_(level_generation)#General , the hash function used is the Java String.hashCode(), which is computed as:

    s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
    

    (where s[i] is the i-th character of the string, n is the length of the string, and ^ indicates exponentiation)

    Which is clearly a Java method. However, considering that seeds are somewhat compatible across editions, this algorithm could be true for both Java and Bedrock.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2