Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
- switch (world.provider.getDimension()) {
- case -1:
- break;
- case 0:
- generateStructures(new WorldGenStructure("cultist_hut"), world, random, chunkX, chunkZ, 10, Blocks.GRASS, getBiomeList().toArray(new Class[getBiomeList().size()]));
- generateRuneAltar(new WorldGenStructure("air_temple"), world, random, chunkX, chunkZ, 120, 98, 176);
- generateRuneAltar(new WorldGenStructure("earth_temple"), world, random, chunkX, chunkZ, 180, 84, 152);
- generateTrees(LUPRESIUM_TREE, world, random, chunkX, chunkZ, 10, lupresiumDirt, BiomeLupresiumForest.class);
- generateTrees(MYSTIC_TREE, world, random, chunkX, chunkZ, 10, mysticDirt, BiomeMysticLands.class);
- break;
- case 1:
- break;
- case 2:
- break;
- }
- }
- 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);
- }
- }
- }
- }
- private static int calculateGenerationHeight(World world, int x, int z, Block topBlock) {
- int y = world.getHeight();
- boolean foundGround = false;
- while (!foundGround && y-- >= 0) {
- Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
- foundGround = block == topBlock;
- }
- return y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement