Advertisement
djoveryde

App Eng Ore Gen

Jun 10th, 2015
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. package appeng.worldgen;
  2.  
  3. import appeng.api.AEApi;
  4. import appeng.api.IAppEngApi;
  5. import appeng.api.definitions.IBlockDefinition;
  6. import appeng.api.definitions.IBlocks;
  7. import appeng.api.definitions.IDefinitions;
  8. import appeng.api.features.IWorldGen.WorldGenType;
  9. import appeng.core.AEConfig;
  10. import appeng.core.features.registries.WorldGenRegistry;
  11. import com.google.common.base.Optional;
  12. import cpw.mods.fml.common.IWorldGenerator;
  13. import java.util.Random;
  14. import net.minecraft.block.Block;
  15. import net.minecraft.init.Blocks;
  16. import net.minecraft.world.World;
  17. import net.minecraft.world.WorldProvider;
  18. import net.minecraft.world.chunk.IChunkProvider;
  19. import net.minecraft.world.gen.feature.WorldGenMinable;
  20.  
  21. public final class QuartzWorldGen
  22. implements IWorldGenerator
  23. {
  24. private final WorldGenMinable oreNormal;
  25. private final WorldGenMinable oreCharged;
  26.  
  27. public QuartzWorldGen()
  28. {
  29. IBlocks blocks = AEApi.instance().definitions().blocks();
  30. IBlockDefinition oreDefinition = blocks.quartzOre();
  31. IBlockDefinition chargedDefinition = blocks.quartzOreCharged();
  32.  
  33. Block ore = (Block)oreDefinition.maybeBlock().orNull();
  34. Block charged = (Block)chargedDefinition.maybeBlock().orNull();
  35.  
  36. this.oreNormal = new WorldGenMinable(ore, 0, AEConfig.instance.quartzOresPerCluster, Blocks.field_150348_b);
  37. this.oreCharged = new WorldGenMinable(charged, 0, AEConfig.instance.quartzOresPerCluster, Blocks.field_150348_b);
  38. }
  39.  
  40. public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
  41. {
  42. int seaLevel = w.field_73011_w.func_76557_i() + 1;
  43. if (seaLevel < 20)
  44. {
  45. int x = (chunkX << 4) + 8;
  46. int z = (chunkZ << 4) + 8;
  47. seaLevel = w.func_72976_f(x, z);
  48. }
  49. if ((this.oreNormal == null) || (this.oreCharged == null)) {
  50. return;
  51. }
  52. double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64;
  53. int scale = (int)Math.round(r.nextGaussian() * Math.sqrt(oreDepthMultiplier) + oreDepthMultiplier);
  54. for (int x = 0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; x++)
  55. {
  56. boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance;
  57. WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal;
  58. if (WorldGenRegistry.INSTANCE.isWorldGenEnabled(isCharged ? IWorldGen.WorldGenType.ChargedCertusQuartz : IWorldGen.WorldGenType.CertusQuartz, w))
  59. {
  60. int cx = chunkX * 16 + r.nextInt(22);
  61. int cy = r.nextInt(40 * seaLevel / 64) + r.nextInt(22 * seaLevel / 64) + 12 * seaLevel / 64;
  62. int cz = chunkZ * 16 + r.nextInt(22);
  63. whichOre.func_76484_a(w, r, cx, cy, cz);
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement