Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package personthecat.seededchunkmatcher;
- import java.util.Arrays;
- import java.util.Random;
- public class Main
- {
- static Random rand = new Random(12345);
- public static void main(String[] args)
- {
- int[][] coordinates = new int[][]
- {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}};
- boolean[][] matches = new boolean[10][10];
- int ID = getNumberForName("iron_ore");
- System.out.println("Name ID: " + ID);
- for (int x = 0; x < coordinates.length; x++)
- {
- for (int y = 0; y < coordinates[0].length; y++)
- {
- int concatenatedValues = concatenateNumbers(ID, x, y);
- matches[x][y] = (((double) rand.nextInt(concatenatedValues) / (double) concatenatedValues) > 0.75);
- }
- }
- for (int x = 0; x < matches.length; x++)
- {
- System.out.println(Arrays.toString(matches[x]));
- }
- }
- /*
- * Could concatenate these numbers to produce a more unique
- * value of every string. It's easier for me to work with
- * smaller numbers, however.
- */
- private static int getNumberForName(String name)
- {
- int number = 0;
- for (Character c : name.toCharArray())
- {
- number += Character.getNumericValue(c);
- }
- return number;
- }
- private static int concatenateNumbers(int... numbers)
- {
- StringBuilder sb = new StringBuilder(numbers.length);
- for (int number : numbers)
- {
- sb.append(Math.abs(number));
- }
- return Integer.valueOf(sb.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment