Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.15 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 net.minecraft.block.state.pattern.BlockMatcher;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.chunk.IChunkGenerator;
  11. import net.minecraft.world.chunk.IChunkProvider;
  12. import net.minecraft.world.gen.feature.WorldGenMinable;
  13. import net.minecraft.world.gen.feature.WorldGenerator;
  14. import net.minecraftforge.fml.common.IWorldGenerator;
  15.  
  16. public class E_AngWorldGen implements IWorldGenerator {
  17.     //World Generators
  18.     private WorldGenerator gen_AngelicOre;
  19.     private WorldGenerator gen_AzureiteOre;
  20.     private WorldGenerator gen_DemonicOre;
  21.     private WorldGenerator gen_MystalCite;
  22.     private WorldGenerator gen_SerpentineOre;
  23.     private WorldGenerator gen_TopazOre;
  24.  
  25.     public E_AngWorldGen()
  26.     {
  27.         gen_AngelicOre = new WorldGenMinable(eAngelusBlocks.angelicOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.STONE));
  28.         gen_AzureiteOre = new WorldGenMinable(eAngelusBlocks.azureite_Ore.getDefaultState(), 4, BlockMatcher.forBlock(Blocks.STONE));
  29.         gen_DemonicOre = new WorldGenMinable(eAngelusBlocks.demonicOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.STONE));
  30.         gen_MystalCite = new WorldGenMinable(eAngelusBlocks.mystalCite.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.STONE));
  31.         gen_SerpentineOre = new WorldGenMinable(eAngelusBlocks.serpentine_Ore.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.STONE));
  32.         gen_TopazOre = new WorldGenMinable(eAngelusBlocks.topazOre.getDefaultState(), 6, BlockMatcher.forBlock(Blocks.STONE));
  33.     }
  34.  
  35.     private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
  36.         if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
  37.             throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
  38.  
  39.         int heightDiff = maxHeight - minHeight + 1;
  40.         for (int i = 0; i < chancesToSpawn; i ++) {
  41.             int x = chunk_X * 16 + rand.nextInt(16);
  42.             int y = minHeight + rand.nextInt(heightDiff);
  43.             int z = chunk_Z * 16 + rand.nextInt(16);
  44.             generator.generate(world, rand, new BlockPos(x, y, z));
  45.         }
  46.     }
  47.  
  48.     @Override
  49.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  50.     {
  51.         switch (world.provider.getDimension())
  52.         {
  53.         case 0: //Overworld
  54.             //Chances to Spawn, Min Height, Max Height
  55.             this.runGenerator(this.gen_AngelicOre, world, random, chunkX, chunkZ, 6, 72, 128);
  56.             this.runGenerator(this.gen_AzureiteOre, world, random, chunkX, chunkZ, 12, 24, 128);
  57.             this.runGenerator(this.gen_DemonicOre, world, random, chunkX, chunkZ, 6, 8, 16);
  58.             this.runGenerator(this.gen_MystalCite, world, random, chunkX, chunkZ, 8, 12, 128);
  59.             this.runGenerator(this.gen_SerpentineOre, world, random, chunkX, chunkZ, 13, 12, 48);
  60.             this.runGenerator(this.gen_TopazOre, world, random, chunkX, chunkZ, 16, 12, 128);
  61.             break;
  62.            
  63.         case -1: //Nether
  64.             break;
  65.            
  66.         case 1: //End
  67.             break;
  68.            
  69.         default:
  70.             break;
  71.         }
  72.  
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement