Advertisement
Eragonn14900

Untitled

Dec 1st, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. package net.minecraft.world.gen.feature;
  2.  
  3. import com.google.common.base.Predicate;
  4. import java.util.Random;
  5. import net.minecraft.block.state.IBlockState;
  6. import net.minecraft.block.state.pattern.BlockMatcher;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.util.math.MathHelper;
  10. import net.minecraft.world.World;
  11.  
  12. public class WorldGenMinable extends WorldGenerator
  13. {
  14. private final IBlockState oreBlock;
  15. /** The number of blocks to generate. */
  16. private final int numberOfBlocks;
  17. private final Predicate<IBlockState> predicate;
  18.  
  19. public WorldGenMinable(IBlockState state, int blockCount)
  20. {
  21. this(state, blockCount, BlockMatcher.forBlock(Blocks.STONE));
  22. }
  23.  
  24. public WorldGenMinable(IBlockState state, int blockCount, Predicate<IBlockState> p_i45631_3_)
  25. {
  26. this.oreBlock = state;
  27. this.numberOfBlocks = blockCount;
  28. this.predicate = p_i45631_3_;
  29. }
  30.  
  31. public boolean generate(World worldIn, Random rand, BlockPos position)
  32. {
  33. float f = rand.nextFloat() * (float)Math.PI;
  34. double d0 = (double)((float)(position.getX() + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
  35. double d1 = (double)((float)(position.getX() + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
  36. double d2 = (double)((float)(position.getZ() + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
  37. double d3 = (double)((float)(position.getZ() + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
  38. double d4 = (double)(position.getY() + rand.nextInt(3) - 2);
  39. double d5 = (double)(position.getY() + rand.nextInt(3) - 2);
  40.  
  41. for (int i = 0; i < this.numberOfBlocks; ++i)
  42. {
  43. float f1 = (float)i / (float)this.numberOfBlocks;
  44. double d6 = d0 + (d1 - d0) * (double)f1;
  45. double d7 = d4 + (d5 - d4) * (double)f1;
  46. double d8 = d2 + (d3 - d2) * (double)f1;
  47. double d9 = rand.nextDouble() * (double)this.numberOfBlocks / 16.0D;
  48. double d10 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
  49. double d11 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
  50. int j = MathHelper.floor_double(d6 - d10 / 2.0D);
  51. int k = MathHelper.floor_double(d7 - d11 / 2.0D);
  52. int l = MathHelper.floor_double(d8 - d10 / 2.0D);
  53. int i1 = MathHelper.floor_double(d6 + d10 / 2.0D);
  54. int j1 = MathHelper.floor_double(d7 + d11 / 2.0D);
  55. int k1 = MathHelper.floor_double(d8 + d10 / 2.0D);
  56.  
  57. for (int l1 = j; l1 <= i1; ++l1)
  58. {
  59. double d12 = ((double)l1 + 0.5D - d6) / (d10 / 2.0D);
  60.  
  61. if (d12 * d12 < 1.0D)
  62. {
  63. for (int i2 = k; i2 <= j1; ++i2)
  64. {
  65. double d13 = ((double)i2 + 0.5D - d7) / (d11 / 2.0D);
  66.  
  67. if (d12 * d12 + d13 * d13 < 1.0D)
  68. {
  69. for (int j2 = l; j2 <= k1; ++j2)
  70. {
  71. double d14 = ((double)j2 + 0.5D - d8) / (d10 / 2.0D);
  72.  
  73. if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D)
  74. {
  75. BlockPos blockpos = new BlockPos(l1, i2, j2);
  76.  
  77. IBlockState state = worldIn.getBlockState(blockpos);
  78. if (state.getBlock().isReplaceableOreGen(state, worldIn, blockpos, this.predicate))
  79. {
  80. worldIn.setBlockState(blockpos, this.oreBlock, 2);
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89.  
  90. return true;
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement