Advertisement
HalestormXV

Untitled

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