Advertisement
HalestormXV

Untitled

Aug 21st, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.70 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. {
  18.  
  19.     private WorldGenerator gen_AngelicOre;
  20.     private WorldGenerator gen_AzureiteOre;
  21.     private WorldGenerator gen_DemonicOre;
  22.     private WorldGenerator gen_MystalCite;
  23.     private WorldGenerator gen_SerpentineOre;
  24.     private WorldGenerator gen_TopazOre;
  25.  
  26.  
  27.     public E_AngWorldGen()
  28.     {
  29.         this.gen_AngelicOre = new WorldGenMinable(eAngelusBlocks.angelicOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.STONE));
  30.         this.gen_AzureiteOre = new WorldGenMinable(eAngelusBlocks.azureite_Ore.getDefaultState(), 4, BlockMatcher.forBlock(Blocks.STONE));
  31.         this.gen_DemonicOre = new WorldGenMinable(eAngelusBlocks.demonicOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.STONE));
  32.         this.gen_MystalCite = new WorldGenMinable(eAngelusBlocks.mystalCite.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.STONE));
  33.         this.gen_SerpentineOre = new WorldGenMinable(eAngelusBlocks.serpentine_Ore.getDefaultState(), 3, BlockMatcher.forBlock(Blocks.STONE));
  34.         this.gen_TopazOre = new WorldGenMinable(eAngelusBlocks.topazOre.getDefaultState(), 6, BlockMatcher.forBlock(Blocks.STONE));
  35.     }
  36.  
  37.  
  38.     @Override
  39.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  40.     {
  41.         switch (world.provider.getDimension())
  42.         {
  43.         case 0: //Overworld
  44.             //Chances to Spawn, Min Height, Max Height
  45.             this.runGenerator(this.gen_AngelicOre, world, random, chunkX, chunkZ, 6, 72, 232);
  46.             this.runGenerator(this.gen_AzureiteOre, world, random, chunkX, chunkZ, 12, 24, 128);
  47.             this.runGenerator(this.gen_DemonicOre, world, random, chunkX, chunkZ, 6, 8, 16);
  48.             this.runGenerator(this.gen_MystalCite, world, random, chunkX, chunkZ, 8, 12, 36);
  49.             this.runGenerator(this.gen_SerpentineOre, world, random, chunkX, chunkZ, 13, 12, 48);
  50.             this.runGenerator(this.gen_TopazOre, world, random, chunkX, chunkZ, 16, 12, 128);
  51.             break;
  52.            
  53.         case -1: //Nether
  54.             break;
  55.            
  56.         case 1: //End
  57.             break;
  58.            
  59.         default:
  60.             this.runGenerator(this.gen_AngelicOre, world, random, chunkX, chunkZ, 6, 72, 232);
  61.             this.runGenerator(this.gen_AzureiteOre, world, random, chunkX, chunkZ, 12, 24, 128);
  62.             this.runGenerator(this.gen_DemonicOre, world, random, chunkX, chunkZ, 6, 8, 16);
  63.             this.runGenerator(this.gen_MystalCite, world, random, chunkX, chunkZ, 8, 12, 36);
  64.             this.runGenerator(this.gen_SerpentineOre, world, random, chunkX, chunkZ, 13, 12, 48);
  65.             this.runGenerator(this.gen_TopazOre, world, random, chunkX, chunkZ, 16, 12, 128);
  66.             break;
  67.         }
  68.  
  69.     }
  70.  
  71.     private void runGenerator(WorldGenerator generator, World world, Random random, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight)
  72.     {
  73.         if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
  74.             throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
  75.  
  76.         int heightDiff = maxHeight - minHeight + 1;
  77.         for (int i = 0; i < chancesToSpawn; i++)
  78.         {
  79.             int x = chunk_X * 16 + random.nextInt(16);
  80.             int y = minHeight + random.nextInt(heightDiff);
  81.             int z = chunk_Z * 16 + random.nextInt(16);
  82.             generator.generate(world, random, new BlockPos(x, y, z));
  83.         }
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement