| 1 | package net.minecraft.world.gen.feature;
|
| 2 |
|
| 3 | import java.util.Random;
|
| 4 | import net.minecraft.block.Block;
|
| 5 | import net.minecraft.block.material.Material;
|
| 6 | import net.minecraft.block.state.IBlockState;
|
| 7 | import net.minecraft.init.Blocks;
|
| 8 | import net.minecraft.util.BlockPos;
|
| 9 | import net.minecraft.world.World;
|
| 10 |
|
| 11 | public abstract class WorldGenHugeTrees extends WorldGenAbstractTree
|
| 12 | {
|
| 13 | /** The base height of the tree */
|
| 14 | protected final int baseHeight;
|
| 15 |
|
| 16 | /** Sets the metadata for the wood blocks used */
|
| 17 | protected final IBlockState woodMetadata;
|
| 18 |
|
| 19 | /** Sets the metadata for the leaves used in huge trees */
|
| 20 | protected final IBlockState leavesMetadata;
|
| 21 | protected int extraRandomHeight;
|
| 22 |
|
| 23 | public WorldGenHugeTrees(boolean p_i46447_1_, int p_i46447_2_, int p_i46447_3_, IBlockState p_i46447_4_, IBlockState p_i46447_5_)
|
| 24 | {
|
| 25 | super(p_i46447_1_);
|
| 26 | this.baseHeight = p_i46447_2_;
|
| 27 | this.extraRandomHeight = p_i46447_3_;
|
| 28 | this.woodMetadata = p_i46447_4_;
|
| 29 | this.leavesMetadata = p_i46447_5_;
|
| 30 | }
|
| 31 |
|
| 32 | protected int func_150533_a(Random p_150533_1_)
|
| 33 | {
|
| 34 | int i = p_150533_1_.nextInt(3) + this.baseHeight;
|
| 35 |
|
| 36 | if (this.extraRandomHeight > 1)
|
| 37 | {
|
| 38 | i += p_150533_1_.nextInt(this.extraRandomHeight);
|
| 39 | }
|
| 40 |
|
| 41 | return i;
|
| 42 | }
|
| 43 |
|
| 44 | private boolean func_175926_c(World worldIn, BlockPos p_175926_2_, int p_175926_3_)
|
| 45 | {
|
| 46 | boolean flag = true;
|
| 47 |
|
| 48 | if (p_175926_2_.getY() >= 1 && p_175926_2_.getY() + p_175926_3_ + 1 <= 256)
|
| 49 | {
|
| 50 | for (int i = 0; i <= 1 + p_175926_3_; ++i)
|
| 51 | {
|
| 52 | int j = 2;
|
| 53 |
|
| 54 | if (i == 0)
|
| 55 | {
|
| 56 | j = 1;
|
| 57 | }
|
| 58 | else if (i >= 1 + p_175926_3_ - 2)
|
| 59 | {
|
| 60 | j = 2;
|
| 61 | }
|
| 62 |
|
| 63 | for (int k = -j; k <= j && flag; ++k)
|
| 64 | {
|
| 65 | for (int l = -j; l <= j && flag; ++l)
|
| 66 | {
|
| 67 | if (p_175926_2_.getY() + i < 0 || p_175926_2_.getY() + i >= 256 || !this.func_150523_a(worldIn.getBlockState(p_175926_2_.add(k, i, l)).getBlock()))
|
| 68 | {
|
| 69 | flag = false;
|
| 70 | }
|
| 71 | }
|
| 72 | }
|
| 73 | }
|
| 74 |
|
| 75 | return flag;
|
| 76 | }
|
| 77 | else
|
| 78 | {
|
| 79 | return false;
|
| 80 | }
|
| 81 | }
|
| 82 |
|
| 83 | private boolean func_175927_a(BlockPos p_175927_1_, World worldIn)
|
| 84 | {
|
| 85 | BlockPos blockpos = p_175927_1_.down();
|
| 86 | Block block = worldIn.getBlockState(blockpos).getBlock();
|
| 87 |
|
| 88 | if ((block == Blocks.grass || block == Blocks.dirt) && p_175927_1_.getY() >= 2)
|
| 89 | {
|
| 90 | this.func_175921_a(worldIn, blockpos);
|
| 91 | this.func_175921_a(worldIn, blockpos.east());
|
| 92 | this.func_175921_a(worldIn, blockpos.south());
|
| 93 | this.func_175921_a(worldIn, blockpos.south().east());
|
| 94 | return true;
|
| 95 | }
|
| 96 | else
|
| 97 | {
|
| 98 | return false;
|
| 99 | }
|
| 100 | }
|
| 101 |
|
| 102 | protected boolean func_175929_a(World worldIn, Random p_175929_2_, BlockPos p_175929_3_, int p_175929_4_)
|
| 103 | {
|
| 104 | return this.func_175926_c(worldIn, p_175929_3_, p_175929_4_) && this.func_175927_a(p_175929_3_, worldIn);
|
| 105 | }
|
| 106 |
|
| 107 | protected void func_175925_a(World worldIn, BlockPos p_175925_2_, int p_175925_3_)
|
| 108 | {
|
| 109 | int i = p_175925_3_ * p_175925_3_;
|
| 110 |
|
| 111 | for (int j = -p_175925_3_; j <= p_175925_3_ + 1; ++j)
|
| 112 | {
|
| 113 | for (int k = -p_175925_3_; k <= p_175925_3_ + 1; ++k)
|
| 114 | {
|
| 115 | int l = j - 1;
|
| 116 | int i1 = k - 1;
|
| 117 |
|
| 118 | if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
|
| 119 | {
|
| 120 | BlockPos blockpos = p_175925_2_.add(j, 0, k);
|
| 121 | Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();
|
| 122 |
|
| 123 | if (material == Material.air || material == Material.leaves)
|
| 124 | {
|
| 125 | this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
|
| 126 | }
|
| 127 | }
|
| 128 | }
|
| 129 | }
|
| 130 | }
|
| 131 |
|
| 132 | protected void func_175928_b(World worldIn, BlockPos p_175928_2_, int p_175928_3_)
|
| 133 | {
|
| 134 | int i = p_175928_3_ * p_175928_3_;
|
| 135 |
|
| 136 | for (int j = -p_175928_3_; j <= p_175928_3_; ++j)
|
| 137 | {
|
| 138 | for (int k = -p_175928_3_; k <= p_175928_3_; ++k)
|
| 139 | {
|
| 140 | if (j * j + k * k <= i)
|
| 141 | {
|
| 142 | BlockPos blockpos = p_175928_2_.add(j, 0, k);
|
| 143 | Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();
|
| 144 |
|
| 145 | if (material == Material.air || material == Material.leaves)
|
| 146 | {
|
| 147 | this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
|
| 148 | }
|
| 149 | }
|
| 150 | }
|
| 151 | }
|
| 152 | }
|
| 153 | }
|
| 154 |
|