| 1 | package net.minecraft.world.gen.feature;
|
| 2 |
|
| 3 | import java.util.Random;
|
| 4 | import net.minecraft.block.Block;
|
| 5 | import net.minecraft.block.BlockDirt;
|
| 6 | import net.minecraft.block.BlockLeaves;
|
| 7 | import net.minecraft.block.BlockOldLeaf;
|
| 8 | import net.minecraft.block.BlockOldLog;
|
| 9 | import net.minecraft.block.BlockPlanks;
|
| 10 | import net.minecraft.block.material.Material;
|
| 11 | import net.minecraft.block.state.IBlockState;
|
| 12 | import net.minecraft.init.Blocks;
|
| 13 | import net.minecraft.util.BlockPos;
|
| 14 | import net.minecraft.util.MathHelper;
|
| 15 | import net.minecraft.world.World;
|
| 16 |
|
| 17 | public class WorldGenMegaPineTree extends WorldGenHugeTrees
|
| 18 | {
|
| 19 | private static final IBlockState field_181633_e = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
| 20 | private static final IBlockState field_181634_f = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
|
| 21 | private static final IBlockState field_181635_g = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL);
|
| 22 | private boolean useBaseHeight;
|
| 23 |
|
| 24 | public WorldGenMegaPineTree(boolean p_i45457_1_, boolean p_i45457_2_)
|
| 25 | {
|
| 26 | super(p_i45457_1_, 13, 15, field_181633_e, field_181634_f);
|
| 27 | this.useBaseHeight = p_i45457_2_;
|
| 28 | }
|
| 29 |
|
| 30 | public boolean generate(World worldIn, Random rand, BlockPos position)
|
| 31 | {
|
| 32 | int i = this.func_150533_a(rand);
|
| 33 |
|
| 34 | if (!this.func_175929_a(worldIn, rand, position, i))
|
| 35 | {
|
| 36 | return false;
|
| 37 | }
|
| 38 | else
|
| 39 | {
|
| 40 | this.func_150541_c(worldIn, position.getX(), position.getZ(), position.getY() + i, 0, rand);
|
| 41 |
|
| 42 | for (int j = 0; j < i; ++j)
|
| 43 | {
|
| 44 | Block block = worldIn.getBlockState(position.up(j)).getBlock();
|
| 45 |
|
| 46 | if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
| 47 | {
|
| 48 | this.setBlockAndNotifyAdequately(worldIn, position.up(j), this.woodMetadata);
|
| 49 | }
|
| 50 |
|
| 51 | if (j < i - 1)
|
| 52 | {
|
| 53 | block = worldIn.getBlockState(position.add(1, j, 0)).getBlock();
|
| 54 |
|
| 55 | if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
| 56 | {
|
| 57 | this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 0), this.woodMetadata);
|
| 58 | }
|
| 59 |
|
| 60 | block = worldIn.getBlockState(position.add(1, j, 1)).getBlock();
|
| 61 |
|
| 62 | if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
| 63 | {
|
| 64 | this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 1), this.woodMetadata);
|
| 65 | }
|
| 66 |
|
| 67 | block = worldIn.getBlockState(position.add(0, j, 1)).getBlock();
|
| 68 |
|
| 69 | if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
| 70 | {
|
| 71 | this.setBlockAndNotifyAdequately(worldIn, position.add(0, j, 1), this.woodMetadata);
|
| 72 | }
|
| 73 | }
|
| 74 | }
|
| 75 |
|
| 76 | return true;
|
| 77 | }
|
| 78 | }
|
| 79 |
|
| 80 | private void func_150541_c(World worldIn, int p_150541_2_, int p_150541_3_, int p_150541_4_, int p_150541_5_, Random p_150541_6_)
|
| 81 | {
|
| 82 | int i = p_150541_6_.nextInt(5) + (this.useBaseHeight ? this.baseHeight : 3);
|
| 83 | int j = 0;
|
| 84 |
|
| 85 | for (int k = p_150541_4_ - i; k <= p_150541_4_; ++k)
|
| 86 | {
|
| 87 | int l = p_150541_4_ - k;
|
| 88 | int i1 = p_150541_5_ + MathHelper.floor_float((float)l / (float)i * 3.5F);
|
| 89 | this.func_175925_a(worldIn, new BlockPos(p_150541_2_, k, p_150541_3_), i1 + (l > 0 && i1 == j && (k & 1) == 0 ? 1 : 0));
|
| 90 | j = i1;
|
| 91 | }
|
| 92 | }
|
| 93 |
|
| 94 | public void func_180711_a(World worldIn, Random p_180711_2_, BlockPos p_180711_3_)
|
| 95 | {
|
| 96 | this.func_175933_b(worldIn, p_180711_3_.west().north());
|
| 97 | this.func_175933_b(worldIn, p_180711_3_.east(2).north());
|
| 98 | this.func_175933_b(worldIn, p_180711_3_.west().south(2));
|
| 99 | this.func_175933_b(worldIn, p_180711_3_.east(2).south(2));
|
| 100 |
|
| 101 | for (int i = 0; i < 5; ++i)
|
| 102 | {
|
| 103 | int j = p_180711_2_.nextInt(64);
|
| 104 | int k = j % 8;
|
| 105 | int l = j / 8;
|
| 106 |
|
| 107 | if (k == 0 || k == 7 || l == 0 || l == 7)
|
| 108 | {
|
| 109 | this.func_175933_b(worldIn, p_180711_3_.add(-3 + k, 0, -3 + l));
|
| 110 | }
|
| 111 | }
|
| 112 | }
|
| 113 |
|
| 114 | private void func_175933_b(World worldIn, BlockPos p_175933_2_)
|
| 115 | {
|
| 116 | for (int i = -2; i <= 2; ++i)
|
| 117 | {
|
| 118 | for (int j = -2; j <= 2; ++j)
|
| 119 | {
|
| 120 | if (Math.abs(i) != 2 || Math.abs(j) != 2)
|
| 121 | {
|
| 122 | this.func_175934_c(worldIn, p_175933_2_.add(i, 0, j));
|
| 123 | }
|
| 124 | }
|
| 125 | }
|
| 126 | }
|
| 127 |
|
| 128 | private void func_175934_c(World worldIn, BlockPos p_175934_2_)
|
| 129 | {
|
| 130 | for (int i = 2; i >= -3; --i)
|
| 131 | {
|
| 132 | BlockPos blockpos = p_175934_2_.up(i);
|
| 133 | Block block = worldIn.getBlockState(blockpos).getBlock();
|
| 134 |
|
| 135 | if (block == Blocks.grass || block == Blocks.dirt)
|
| 136 | {
|
| 137 | this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181635_g);
|
| 138 | break;
|
| 139 | }
|
| 140 |
|
| 141 | if (block.getMaterial() != Material.air && i < 0)
|
| 142 | {
|
| 143 | break;
|
| 144 | }
|
| 145 | }
|
| 146 | }
|
| 147 | }
|
| 148 |
|