Advertisement
HalestormXV

Untitled

Aug 26th, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.21 KB | None | 0 0
  1. package halestormxv.eAngelus.main.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import halestormxv.eAngelus.main.init.eAngelusBlocks;
  6. import halestormxv.eAngelus.main.world.Structures.generateKnightAlter;
  7. import halestormxv.eAngelus.main.world.Structures.generateChariotAlter;
  8. import net.minecraft.block.state.pattern.BlockMatcher;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.util.math.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraft.world.chunk.IChunkGenerator;
  13. import net.minecraft.world.chunk.IChunkProvider;
  14. import net.minecraft.world.gen.feature.WorldGenMinable;
  15. import net.minecraft.world.gen.feature.WorldGenerator;
  16. import net.minecraftforge.fml.common.IWorldGenerator;
  17.  
  18. public class E_AngWorldGen implements IWorldGenerator
  19. {
  20.     //World Generators
  21.     private WorldGenerator gen_AngelicOre;
  22.     private WorldGenerator gen_AzureiteOre;
  23.     private WorldGenerator gen_DemonicOre;
  24.     private WorldGenerator gen_MystalCite;
  25.     private WorldGenerator gen_SerpentineOre;
  26.     private WorldGenerator gen_TopazOre;
  27.     private WorldGenerator gen_KnightAlter;
  28.  
  29.     public E_AngWorldGen()
  30.     {
  31.         gen_AngelicOre = new WorldGenMinable(eAngelusBlocks.angelicOre.getDefaultState(), 4, BlockMatcher.forBlock(Blocks.STONE));
  32.         gen_AzureiteOre = new WorldGenMinable(eAngelusBlocks.azureite_Ore.getDefaultState(), 4, BlockMatcher.forBlock(Blocks.STONE));
  33.         gen_DemonicOre = new WorldGenMinable(eAngelusBlocks.demonicOre.getDefaultState(), 4, BlockMatcher.forBlock(Blocks.STONE));
  34.         gen_MystalCite = new WorldGenMinable(eAngelusBlocks.mystalCite.getDefaultState(), 5, BlockMatcher.forBlock(Blocks.STONE));
  35.         gen_SerpentineOre = new WorldGenMinable(eAngelusBlocks.serpentine_Ore.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.STONE));
  36.         gen_TopazOre = new WorldGenMinable(eAngelusBlocks.topazOre.getDefaultState(), 6, BlockMatcher.forBlock(Blocks.STONE));
  37.     }
  38.  
  39.     private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
  40.         if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
  41.             throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
  42.  
  43.         int heightDiff = maxHeight - minHeight + 1;
  44.         for (int i = 0; i < chancesToSpawn; i ++) {
  45.             int x = chunk_X * 16 + rand.nextInt(16);
  46.             int y = minHeight + rand.nextInt(heightDiff);
  47.             int z = chunk_Z * 16 + rand.nextInt(16);
  48.             generator.generate(world, rand, new BlockPos(x, y, z));
  49.         }
  50.     }
  51.  
  52.     private void generateChariotAlterSpawn(World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight)
  53.     {
  54.         if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
  55.             throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
  56.  
  57.         if (rand.nextInt(70) == 1)
  58.         {
  59.             for (int i = 0; i <= chancesToSpawn; i++)
  60.             {
  61.                 int randPosX = chunk_X * 16 + rand.nextInt(16);
  62.                 int randPosY = 60 + rand.nextInt(255 - 64);
  63.                 int randPosZ = chunk_Z * 16 + rand.nextInt(16);
  64.                 BlockPos position = new BlockPos(randPosX, randPosY, randPosZ);
  65.                 if (!(world.getBlockState(world.getTopSolidOrLiquidBlock(position)).getBlock().equals(Blocks.WATER)))
  66.                     new generateChariotAlter(world.getTopSolidOrLiquidBlock(position), world);
  67.             }
  68.         }
  69.     }
  70.  
  71.     @Override
  72.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  73.     {
  74.         switch (world.provider.getDimension())
  75.         {
  76.         case 0: //Overworld
  77.             //Chances to Spawn, Min Height, Max Height
  78.             this.runGenerator(this.gen_AngelicOre, world, random, chunkX, chunkZ, 8, 72, 128);
  79.             this.runGenerator(this.gen_AzureiteOre, world, random, chunkX, chunkZ, 12, 24, 128);
  80.             this.runGenerator(this.gen_DemonicOre, world, random, chunkX, chunkZ, 8, 8, 16);
  81.             this.runGenerator(this.gen_MystalCite, world, random, chunkX, chunkZ, 10, 12, 128);
  82.             this.runGenerator(this.gen_SerpentineOre, world, random, chunkX, chunkZ, 13, 12, 48);
  83.             this.runGenerator(this.gen_TopazOre, world, random, chunkX, chunkZ, 16, 12, 128);
  84.             this.generateChariotAlterSpawn(world, random, chunkX, chunkZ, 1, 72, 128);
  85.             break;
  86.         case -1: //Nether
  87.             break;
  88.            
  89.         case 1: //End
  90.             break;
  91.            
  92.         default:
  93.             break;
  94.         }
  95.  
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement