Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.TheRPGAdventurer.server.world;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.init.Biomes;
- import net.minecraft.init.Blocks;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- import net.minecraft.world.biome.BiomeHills;
- import net.minecraft.world.chunk.IChunkGenerator;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.structure.template.Template;
- import net.minecraftforge.fml.common.IWorldGenerator;
- public class ROTDWorldGenerator implements IWorldGenerator{
- //@formatter:off
- StructureDragonNests dragonNest = new StructureDragonNests();
- //@formatter:on
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
- switch(world.provider.getDimension()) {
- case -1: //Nether
- break;
- case 0: //OverWorld (Earth)
- this.generateNests(world, random, chunkX, chunkZ, null, random);
- break;
- case 1: //End
- break;
- }
- }
- public void generateNests(World world, Random random, int chunkX, int chunkZ, BlockPos position, Random rand) {
- int x = chunkX * 16 + random.nextInt(16);
- int z = chunkZ * 16 + random.nextInt(16);
- int xy = x >> 4;
- int zy = z >> 4;
- int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15));
- int y = height - 1;
- if(world.getBiomeForCoordsBody(new BlockPos (x,y,z)).getBiomeClass().equals(Biomes.EXTREME_HILLS)) {
- if((random.nextInt(50) + 1) <= 1) {
- boolean place = true;
- for(int j = 0; j < 6; j++) {
- for(int k = 0; k < 9; k++) {
- for(int i = 0; i < 11; i++) {
- if(world.getBlockState(new BlockPos(i + x, j + y + 1, k + z)).getBlock() == Blocks.AIR) {
- place = false;
- }
- }
- }
- }
- if(place) {
- dragonNest.generate(world, random, new BlockPos(x,y,z));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment