Advertisement
Guest User

OreGeneration

a guest
Jan 14th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. package com.chef.mod.generate;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.chef.mod.Chef;
  6.  
  7. import net.minecraft.block.Block;
  8. import net.minecraft.init.Blocks;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.biome.BiomeGenBase;
  11. import net.minecraft.world.biome.BiomeGenBeach;
  12. import net.minecraft.world.biome.BiomeGenMesa;
  13. import net.minecraft.world.biome.BiomeGenOcean;
  14. import net.minecraft.world.biome.BiomeGenRiver;
  15. import net.minecraft.world.chunk.IChunkProvider;
  16. import net.minecraft.world.gen.feature.WorldGenMinable;
  17. import cpw.mods.fml.common.IWorldGenerator;
  18.  
  19. public class OreGeneration implements IWorldGenerator {
  20.  
  21. @Override
  22. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  23. switch(world.provider.dimensionId)
  24. {
  25. case 1:
  26. generateEnd(world, random, chunkX, chunkZ);
  27. break;
  28. case 0:
  29. generateOverworld(world, random, chunkX, chunkZ);
  30. break;
  31. case -1:
  32. generateNether(world, random, chunkX, chunkZ);
  33. break;
  34. }
  35. }
  36.  
  37. public void generateEnd(World world, Random rand, int x, int z) {
  38.  
  39. }
  40.  
  41. public void generateOverworld(World world, Random rand, int x, int z) {
  42. //world, rand, x, z, Minimal blocks to spawn, Maximal blocks to spawn, Chance to spawn, Minimal height to spawn, Maximal height to spawn, Block to spawn in
  43. generateOre(Chef.oreRockSaltOre, world, rand, x, z, 3, 7, 40, 80, 100, Blocks.stone);
  44. generateOreSand(Chef.oreSeaSaltOre, world, rand, x, z, 4, 8, 80, 50, 100, Blocks.sand);
  45. }
  46.  
  47. public void generateNether(World world, Random rand, int x, int z) {
  48.  
  49. }
  50.  
  51. public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
  52. int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
  53. int heightRange = maxY - minY;
  54. WorldGenMinable gen = new WorldGenMinable(block, vienSize, generateIn);
  55.  
  56. for (int i = 0; i < chance; i++) {
  57. int xRand = chunkX * 16 + random.nextInt(16);
  58. int yRand = random.nextInt(heightRange) + minY;
  59. int zRand = chunkZ * 16 + random.nextInt(16);
  60. gen.generate(world, random, xRand, yRand, zRand);
  61. }
  62. }
  63.  
  64. public void generateOreSand(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
  65. int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
  66. int heightRange = maxY - minY;
  67. WorldGenMinableSand gen = new WorldGenMinableSand(block, vienSize, generateIn);
  68. BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);
  69.  
  70. if(biome instanceof BiomeGenOcean || biome instanceof BiomeGenRiver || biome instanceof BiomeGenBeach) {
  71. for (int i = 0; i < chance; i++) {
  72. int xRand = chunkX * 16 + random.nextInt(16);
  73. int yRand = random.nextInt(heightRange) + minY;
  74. int zRand = chunkZ * 16 + random.nextInt(16);
  75. gen.generate(world, random, xRand, yRand, zRand);
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement