Guest User

Untitled

a guest
Sep 8th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. package rcpotatosoup.modsqaud.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import rcpotatosoup.modsqaud.init.siblocks;
  6. import net.minecraft.util.BlockPos;
  7. import net.minecraft.world.World;
  8. import net.minecraft.world.chunk.IChunkProvider;
  9. import net.minecraft.world.gen.feature.WorldGenMinable;
  10. import net.minecraft.world.gen.feature.WorldGenerator;
  11. import net.minecraftforge.fml.common.IWorldGenerator;
  12.  
  13. public class ModWorldGen implements IWorldGenerator {
  14.  
  15. private WorldGenerator gen_chaos_ore;
  16. private WorldGenerator gen_order_ore;
  17.  
  18. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  19. switch (world.provider.getDimensionId()) {
  20. case 0: //Overworld
  21. this.runGenerator(this.gen_chaos_ore, world, random, chunkX, chunkZ, 10, 0, 25);
  22. this.runGenerator(this.gen_order_ore, world, random, chunkX, chunkZ, 10, 0, 25);
  23. break;
  24. case -1: //Nether
  25.  
  26. break;
  27. case 1: //End
  28.  
  29. break;}
  30. }
  31.  
  32. public void TutorialWorldGen() {
  33. this.gen_chaos_ore = new WorldGenMinable(siblocks.chaos_ore.getDefaultState(), 4);
  34. this.gen_order_ore = new WorldGenMinable(siblocks.order_ore.getDefaultState(), 4);}
  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. }
Advertisement
Add Comment
Please, Sign In to add comment