Advertisement
HalestormXV

Untitled

Apr 7th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. private void generateStructures(WorldGenerator generator, World world, Random random, int chunkX, int chunkZ, int chance, Block topBlock, Class<?>... classes)
  2. {
  3.         HighQualityRandom highQualityRandom = new HighQualityRandom();
  4.         ArrayList<Class<?>> classesList = new ArrayList<Class<?>>(Arrays.asList(classes));
  5.         int x = (chunkX * 16) + highQualityRandom.nextInt(15);
  6.         int z = (chunkZ * 16) + highQualityRandom.nextInt(15);
  7.         float y = 0;
  8.         for (int xSize = 0; xSize < 9; x++)
  9.         {
  10.             for (int zSize = 0; zSize < 7; z++)
  11.             {
  12.                 int oldY = Math.round(y);
  13.                 y += calculateGenerationHeight(world, x, z, topBlock);
  14.                 y /= 2;
  15.                 if (Math.round(y) != oldY){ return; }
  16.             }
  17.         }
  18.         int struc_y = (int)y - 1;
  19.         BlockPos pos = new BlockPos(x, struc_y, z);
  20.         Class<?> biome = world.provider.getBiomeForCoords(pos).getClass();
  21.         if (world.getWorldType() != WorldType.FLAT) {
  22.             if (classesList.contains(biome) || classesList.isEmpty()) {
  23.                 if (highQualityRandom.nextInt(chance) == 0)
  24.                 {
  25.  
  26.                     generator.generate(world, highQualityRandom, pos);
  27.                 }
  28.             }
  29.         }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement