Advertisement
modblockminer

OreGen.java

May 31st, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. package com.stevemod.main.worldgen;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.stevemod.main.blocks.blockRuby;
  6.  
  7. import init.ModBlocks;
  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 OreGen implements IWorldGenerator {
  17.  
  18. //World Generators
  19. private WorldGenerator ruby_overworld;
  20. private WorldGenerator ruby_nether;
  21. private WorldGenerator ruby_end;
  22.  
  23. public OreGen() {
  24. ruby_overworld = new WorldGenMinable(ModBlocks.rubyblock.getDefaultState(), 8);
  25. }
  26.  
  27. private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
  28. if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
  29. throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
  30.  
  31. int heightDiff = maxHeight - minHeight + 1;
  32. for (int i = 0; i < chancesToSpawn; i ++) {
  33. int x = chunk_X * 16 + rand.nextInt(16);
  34. int y = minHeight + rand.nextInt(heightDiff);
  35. int z = chunk_Z * 16 + rand.nextInt(16);
  36. generator.generate(world, rand, new BlockPos(x, y, z));
  37. }
  38. }
  39.  
  40. @Override
  41. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
  42. IChunkProvider chunkProvider) {
  43.  
  44. switch(world.provider.getDimension()) {
  45. case 0:
  46. this.runGenerator(ruby_overworld, world, random, chunkX, chunkZ, 100, 60, 110);
  47. }
  48.  
  49.  
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement