Map Seed

Discussion in 'Plugin Development' started by CorrieKay, Dec 22, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    CorrieKay

    Does anyone know what method NMS code uses to set the map seed string to a long and pass into the WorldCreator? Ive got a map that has a string for a seed, but i need it to be converted into a long to work with the world creator. I figured it may be just hashing the string, but i dont wanna be wrong. (nor do i know how i would check)
     
  2. Offline

    fireblast709

    CorrieKay
    Code:java
    1. String s = this.propertyManager.getString("level-seed", "");
    2. long k = (new Random()).nextLong();
    3. if (s.length() > 0) {
    4. try {
    5. long l = Long.parseLong(s);
    6.  
    7. if (l != 0L) {
    8. k = l;
    9. }
    10. } catch (NumberFormatException numberformatexception) {
    11. k = (long) s.hashCode();
    12. }
    13. }
    k would be the seed. It would default to a random long, take the String as seed if the seed can be converted to a long. If not, it would get, indeed, the hash.
     
  3. Offline

    CorrieKay

    Yeah i found that after i had posted this. Question though, when i didnt define a seed in my world creator, it would always generate the map fractally, is this because every reboot it would choose a different seed?
     
  4. Offline

    fireblast709

    Umm... no? wouldn't a world save the seed?
     
  5. Offline

    CorrieKay

    I mean with my multiworld system. Based on what ive seen, whenever i try to load additional worlds, if i dont save the seed to file, and specify the seed, it fragments the world.
     
  6. Offline

    fireblast709

    Mmh weird
     
  7. Offline

    CorrieKay

    I think the reason is that the seed for the main world is saved to the preferences file, while any additional worlds loaded (not typical with minecraft) are given a random seed if you dont provide one.
     
Thread Status:
Not open for further replies.

Share This Page