Guest User

dragon nest

a guest
Jul 2nd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. package com.TheRPGAdventurer.server.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.material.Material;
  7. import net.minecraft.init.Biomes;
  8. import net.minecraft.init.Blocks;
  9. import net.minecraft.util.math.BlockPos;
  10. import net.minecraft.world.World;
  11. import net.minecraft.world.biome.BiomeHills;
  12. import net.minecraft.world.chunk.IChunkGenerator;
  13. import net.minecraft.world.chunk.IChunkProvider;
  14. import net.minecraft.world.gen.structure.template.Template;
  15. import net.minecraftforge.fml.common.IWorldGenerator;
  16.  
  17.  
  18. public class ROTDWorldGenerator implements IWorldGenerator{
  19. //@formatter:off
  20.  
  21. StructureDragonNests dragonNest = new StructureDragonNests();
  22.  
  23. //@formatter:on
  24.  
  25. @Override
  26. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
  27. switch(world.provider.getDimension()) {
  28. case -1: //Nether
  29. break;
  30. case 0: //OverWorld (Earth)
  31. this.generateNests(world, random, chunkX, chunkZ, null, random);
  32. break;
  33. case 1: //End
  34. break;
  35. }
  36. }
  37. public void generateNests(World world, Random random, int chunkX, int chunkZ, BlockPos position, Random rand) {
  38. int x = chunkX * 16 + random.nextInt(16);
  39. int z = chunkZ * 16 + random.nextInt(16);
  40. int xy = x >> 4;
  41. int zy = z >> 4;
  42. int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15));
  43. int y = height - 1;
  44.  
  45. if(world.getBiomeForCoordsBody(new BlockPos (x,y,z)).getBiomeClass().equals(Biomes.EXTREME_HILLS)) {
  46. if((random.nextInt(50) + 1) <= 1) {
  47. boolean place = true;
  48.  
  49. for(int j = 0; j < 6; j++) {
  50. for(int k = 0; k < 9; k++) {
  51. for(int i = 0; i < 11; i++) {
  52. if(world.getBlockState(new BlockPos(i + x, j + y + 1, k + z)).getBlock() == Blocks.AIR) {
  53. place = false;
  54. }
  55. }
  56. }
  57. }
  58.  
  59. if(place) {
  60. dragonNest.generate(world, random, new BlockPos(x,y,z));
  61. }
  62. }
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment