Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package carpet;
- import net.minecraft.init.Biomes;
- import net.minecraft.init.Bootstrap;
- import net.minecraft.world.WorldType;
- import net.minecraft.world.biome.Biome;
- import net.minecraft.world.gen.ChunkGeneratorSettings;
- import net.minecraft.world.gen.layer.GenLayer;
- import net.minecraft.world.gen.layer.IntCache;
- public class Main {
- private static final long SEED = 2791111690993685248L;
- private static final int STRIDE = 15 * 16;
- private static GenLayer biomeGen;
- private static int DESERT, DESERT_HILLS, DESERT_M;
- public static void main(String[] args) {
- Bootstrap.register();
- DESERT = Biome.getIdForBiome(Biomes.DESERT);
- DESERT_HILLS = Biome.getIdForBiome(Biomes.DESERT_HILLS);
- DESERT_M = Biome.getIdForBiome(Biomes.MUTATED_DESERT);
- biomeGen = GenLayer.initializeAllBiomeGenerators(SEED, WorldType.DEFAULT, new ChunkGeneratorSettings.Factory().build())[1];
- int minDistance = Integer.MAX_VALUE;
- int x = 0, z = 0;
- if (!checkArea(0, 0)) {
- for (int radius = STRIDE; radius * radius <= minDistance; radius += STRIDE) {
- for (int dx = radius; dx > -radius; dx -= STRIDE) {
- int dz = Math.abs(dx) - STRIDE;
- if (checkArea(dx, dz)) {
- int distance = dx * dx + dz * dz;
- if (distance < minDistance) {
- minDistance = distance;
- x = dx;
- z = dz;
- }
- }
- }
- for (int dx = -radius; dx < radius; dx += STRIDE) {
- int dz = STRIDE - Math.abs(dx);
- if (checkArea(dx, dz)) {
- int distance = dx * dx + dz * dz;
- if (distance < minDistance) {
- minDistance = distance;
- x = dx;
- z = dz;
- }
- }
- }
- }
- }
- System.out.println(x + ", " + z);
- }
- private static boolean checkArea(int x, int z) {
- System.out.println("Searching " + x + ", " + z);
- if (!isDesert(biomeGen.getInts(x, z, 1, 1)[0]))
- return false;
- final int SIZE = 29 * 16;
- int[] biomes = biomeGen.getInts(x - 14 * 16, z - 14 * 16, SIZE, SIZE);
- boolean[][] desertChunks = new boolean[29][29];
- for (int chunkX = 0; chunkX < 29; chunkX++) {
- innerChunkLoop:
- for (int chunkZ = 0; chunkZ < 29; chunkZ++) {
- for (int dx = 0; dx < 16; dx++) {
- for (int dz = 0; dz < 16; dz++) {
- if (!isDesert(biomes[chunkX * 16 + dx + SIZE * (chunkZ * 16 + dz)]))
- continue innerChunkLoop;
- }
- }
- desertChunks[chunkX][chunkZ] = true;
- }
- }
- for (int chunkX = 0; chunkX < 15; chunkX++) {
- innerOuter:
- for (int chunkZ = 0; chunkZ < 15; chunkZ++) {
- for (int dx = 0; dx < 15; dx++) {
- for (int dz = 0; dz < 15; dz++) {
- if (!desertChunks[chunkX + dx][chunkZ + dz])
- continue innerOuter;
- }
- }
- return true;
- }
- }
- IntCache.resetIntCache();
- return false;
- }
- private static boolean isDesert(int biome) {
- return biome == DESERT || biome == DESERT_HILLS || biome == DESERT_M;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement