Guest User

MyWorldGenMinable

a guest
Jan 14th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. package com.chef.mod.generate;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.init.Blocks;
  7. import net.minecraft.util.MathHelper;
  8. import net.minecraft.world.World;
  9. import net.minecraft.world.gen.feature.WorldGenerator;
  10.  
  11. public class MyWorldGenMinable extends WorldGenerator
  12. {
  13. private Block blockA;
  14. /** The number of blocks to generate. */
  15. private int numberOfBlocks;
  16. private Block blockB;
  17. private static final String __OBFID = "CL_00000426";
  18. private int mineableBlockMeta;
  19. int blockID;
  20.  
  21. public MyWorldGenMinable(Block block, int i, int blockID)
  22. {
  23. this(block, i, Blocks.stone, 0);
  24.  
  25. if (this.blockID < 0)
  26. {
  27. this.blockID = 0;
  28. }
  29. }
  30.  
  31. public MyWorldGenMinable(Block block, int i, Block generateIn, int blockID)
  32. {
  33. this.blockA = block;
  34. this.numberOfBlocks = i;
  35. this.blockB = generateIn;
  36. this.blockID = blockID;
  37. }
  38.  
  39. public MyWorldGenMinable(Block block, int meta, int number, Block target, int blockID)
  40. {
  41. this(block, number, target, 0);
  42. this.mineableBlockMeta = meta;
  43. }
  44.  
  45. public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_)
  46. {
  47. float f = p_76484_2_.nextFloat() * (float)Math.PI;
  48. double d0 = (double)((float)(p_76484_3_ + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
  49. double d1 = (double)((float)(p_76484_3_ + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
  50. double d2 = (double)((float)(p_76484_5_ + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
  51. double d3 = (double)((float)(p_76484_5_ + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
  52. double d4 = (double)(p_76484_4_ + p_76484_2_.nextInt(3) - 2);
  53. double d5 = (double)(p_76484_4_ + p_76484_2_.nextInt(3) - 2);
  54.  
  55. for (int l = 0; l <= this.numberOfBlocks; ++l)
  56. {
  57. double d6 = d0 + (d1 - d0) * (double)l / (double)this.numberOfBlocks;
  58. double d7 = d4 + (d5 - d4) * (double)l / (double)this.numberOfBlocks;
  59. double d8 = d2 + (d3 - d2) * (double)l / (double)this.numberOfBlocks;
  60. double d9 = p_76484_2_.nextDouble() * (double)this.numberOfBlocks / 16.0D;
  61. double d10 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
  62. double d11 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
  63. int i1 = MathHelper.floor_double(d6 - d10 / 2.0D);
  64. int j1 = MathHelper.floor_double(d7 - d11 / 2.0D);
  65. int k1 = MathHelper.floor_double(d8 - d10 / 2.0D);
  66. int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);
  67. int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);
  68. int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);
  69.  
  70. for (int k2 = i1; k2 <= l1; ++k2)
  71. {
  72. double d12 = ((double)k2 + 0.5D - d6) / (d10 / 2.0D);
  73.  
  74. if (d12 * d12 < 1.0D)
  75. {
  76. for (int l2 = j1; l2 <= i2; ++l2)
  77. {
  78. double d13 = ((double)l2 + 0.5D - d7) / (d11 / 2.0D);
  79.  
  80. if (d12 * d12 + d13 * d13 < 1.0D)
  81. {
  82. for (int i3 = k1; i3 <= j2; ++i3)
  83. {
  84. double d14 = ((double)i3 + 0.5D - d8) / (d10 / 2.0D);
  85.  
  86. if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && p_76484_1_.getBlock(k2, l2, i3).isReplaceableOreGen(p_76484_1_, k2, l2, i3, blockB))
  87. {
  88. p_76484_1_.setBlock(k2, l2, i3, this.blockA, mineableBlockMeta, 2);
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96.  
  97. return true;
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment