Advertisement
HalestormXV

Untitled

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