Created
July 1, 2015 14:09
-
-
Save m0r13/6b25673ca85790d4dcf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.System; | |
import java.util.Random; | |
class SlimeTest { | |
public static boolean isSlimeChunk(long seed, long x, long z) { | |
Random random = new Random(seed + | |
(long) (x * x * 0x4c1906) + | |
(long) (x * 0x5ac0db) + | |
(long) (z * z) * 0x4307a7L + | |
(long) (z * 0x5f24f) ^ 0x3ad8025f); | |
return random.nextInt(10) == 0; | |
} | |
public static void main(String[] args) { | |
long seed = 42; | |
for (int x = -10; x <= 10; x++) { | |
for (int z = -10; z <= 10; z++) { | |
if (isSlimeChunk(seed, x, z)) { | |
// System.out.println(x + "," + z + " is a slime chunk!"); | |
System.out.println("mc::ChunkPos(" + x + ", " + z + "),"); | |
} | |
} | |
} | |
System.out.println(); | |
seed = 73; | |
int needed = 20; | |
int max = 100000; | |
Random random = new Random(System.currentTimeMillis()); | |
int found = 0; | |
while (found < needed) { | |
long chunkx = random.nextInt(2*max) - max; | |
long chunkz = random.nextInt(2*max) - max; | |
if (isSlimeChunk(seed, chunkx, chunkz)) { | |
System.out.println("mc::ChunkPos(" + chunkx + ", " + chunkz + "),"); | |
found++; | |
} | |
} | |
System.out.println(); | |
found = 0; | |
while (found < needed) { | |
long chunkx = random.nextInt(2*max) - max; | |
long chunkz = random.nextInt(2*max) - max; | |
if (!isSlimeChunk(seed, chunkx, chunkz)) { | |
System.out.println("mc::ChunkPos(" + chunkx + ", " + chunkz + "),"); | |
found++; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment