Advertisement
Dylann6466

Ore Generation

Jul 7th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. package com.dylann6466.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.dylann6466.Main.MainRegistry;
  6.  
  7. import net.minecraft.block.Block;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.util.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraft.world.chunk.IChunkProvider;
  13. import net.minecraft.world.gen.feature.WorldGenMinable;
  14. import net.minecraftforge.fml.common.IWorldGenerator;
  15.  
  16. public class WorldOreGen implements IWorldGenerator {
  17.  
  18. @Override
  19. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
  20. {
  21. switch(world.provider.getDimensionId())
  22. {
  23. case -1:
  24. GenerateNether(world, chunkX * 16, chunkZ * 16, random);
  25. break;
  26. case 0:
  27. GenerateOverworld(world, chunkX * 16, chunkZ * 16, random);
  28. break;
  29. case 1:
  30. GenerateEnd(world, chunkX * 16, chunkZ * 16, random);
  31. break;
  32. }
  33. }
  34.  
  35. private void addOre(Block block, Block blockSpawn, Random random, World world, int posX, int posZ, int minY, int maxY, int minVein, int maxVein, int SpawnChance)
  36. {
  37. for(int i = 0; i < SpawnChance; i++)
  38. {
  39. int defaultChunkSize = 16;
  40.  
  41. int Xpos = posX + random.nextInt(defaultChunkSize);
  42. int Ypos = minY + random.nextInt(maxY - minY);
  43. int Zpos = posZ + random.nextInt(defaultChunkSize);
  44.  
  45. IBlockState state = block.getDefaultState();
  46. BlockPos blockPos = new BlockPos(Xpos, Ypos, Zpos);
  47.  
  48. new WorldGenMinable(state, maxVein).generate(world, random, blockPos);
  49. System.out.println("Ore Generated: " + blockPos);
  50. }
  51. }
  52.  
  53. private void GenerateEnd(World world, int i, int j, Random random)
  54. {
  55.  
  56. }
  57.  
  58. private void GenerateOverworld(World world, int i, int j, Random random)
  59. {
  60. addOre(MainRegistry.copperOre, Blocks.stone, random, world, i, j, 15, 100, 4, 8, 40);
  61. }
  62.  
  63. private void GenerateNether(World world, int i, int j, Random random)
  64. {
  65.  
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement