Advertisement
manusoftar

Minecraft mineshaft algorithm

Jul 29th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public static boolean hasMineshaftStartingPoint(long mapSeed, int chunkX, int chunkZ){
  2.    
  3.     Random rand = new Random();
  4.    
  5.     // *** MapGenBase->generate() / MapGenStructure->getNeareastInstance()
  6.     rand.setSeed(mapSeed);
  7.     long seedMod1 = rand.nextLong();
  8.     long seedMod2 = rand.nextLong();
  9.    
  10.     long seedMod3 = (long)chunkX * seedMod1;
  11.     long seedMod4 = (long)chunkZ * seedMod2;
  12.    
  13.     rand.setSeed(seedMod3 ^ seedMod4 ^ mapSeed);
  14.    
  15.     rand.nextInt();
  16.    
  17.     // *** MapGenMineshaft->canSpawnStructureAtCoords
  18.     if(rand.nextDouble() < 0.01D && rand.nextInt(80) < Math.max(Math.abs(chunkX), Math.abs(chunkZ))){
  19.         return true;
  20.     }
  21.    
  22.     return false;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement