Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void generateStructures(WorldGenerator generator, World world, Random random, int chunkX, int chunkZ, int chance, Block topBlock, Class<?>... classes) {
- HighQualityRandom highQualityRandom = new HighQualityRandom();
- ArrayList<Class<?>> classesList = new ArrayList<Class<?>>(Arrays.asList(classes));
- int struc_x = (chunkX * 16) + highQualityRandom.nextInt(15);
- int struc_z = (chunkZ * 16) + highQualityRandom.nextInt(15);
- float y = 0;
- for (int x = 0; x < struc_x; x++)
- {
- for (int z = 0; z < struc_z; z++)
- {
- int oldY = Math.round(y);
- y += calculateGenerationHeight(world, x, z, topBlock);
- y /= 2;
- if (Math.round(y) != oldY){ return; }
- }
- }
- int struc_y = (int)y;
- BlockPos pos = new BlockPos(struc_x, struc_y, struc_z);
- Class<?> biome = world.provider.getBiomeForCoords(pos).getClass();
- if (world.getWorldType() != WorldType.FLAT) {
- if (classesList.contains(biome) || classesList.isEmpty()) {
- if (highQualityRandom.nextInt(chance) == 0)
- {
- generator.generate(world, highQualityRandom, pos);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement