Search in sources :

Example 1 with BlockHugeMushroom

use of net.minecraft.block.BlockHugeMushroom in project CumServerPro by MCUmbrella.

the class WorldGenBigMushroom method generate.

public boolean generate(World worldIn, Random rand, BlockPos position) {
    Block block = this.mushroomType;
    if (block == null) {
        block = rand.nextBoolean() ? Blocks.BROWN_MUSHROOM_BLOCK : Blocks.RED_MUSHROOM_BLOCK;
    }
    int i = rand.nextInt(3) + 4;
    if (rand.nextInt(12) == 0) {
        i *= 2;
    }
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 < 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 3;
            if (j <= position.getY() + 3) {
                k = 0;
            }
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        IBlockState state = worldIn.getBlockState(blockpos$mutableblockpos.setPos(l, j, i1));
                        if (!state.getBlock().isAir(state, worldIn, blockpos$mutableblockpos) && !state.getBlock().isLeaves(state, worldIn, blockpos$mutableblockpos)) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            Block block1 = worldIn.getBlockState(position.down()).getBlock();
            if (block1 != Blocks.DIRT && block1 != Blocks.GRASS && block1 != Blocks.MYCELIUM) {
                return false;
            } else {
                int k2 = position.getY() + i;
                if (block == Blocks.RED_MUSHROOM_BLOCK) {
                    k2 = position.getY() + i - 3;
                }
                for (int l2 = k2; l2 <= position.getY() + i; ++l2) {
                    int j3 = 1;
                    if (l2 < position.getY() + i) {
                        ++j3;
                    }
                    if (block == Blocks.BROWN_MUSHROOM_BLOCK) {
                        j3 = 3;
                    }
                    int k3 = position.getX() - j3;
                    int l3 = position.getX() + j3;
                    int j1 = position.getZ() - j3;
                    int k1 = position.getZ() + j3;
                    for (int l1 = k3; l1 <= l3; ++l1) {
                        for (int i2 = j1; i2 <= k1; ++i2) {
                            int j2 = 5;
                            if (l1 == k3) {
                                --j2;
                            } else if (l1 == l3) {
                                ++j2;
                            }
                            if (i2 == j1) {
                                j2 -= 3;
                            } else if (i2 == k1) {
                                j2 += 3;
                            }
                            BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
                            if (block == Blocks.BROWN_MUSHROOM_BLOCK || l2 < position.getY() + i) {
                                if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1)) {
                                    continue;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                            }
                            if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i) {
                                blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
                            }
                            if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE) {
                                BlockPos blockpos = new BlockPos(l1, l2, i2);
                                IBlockState state = worldIn.getBlockState(blockpos);
                                if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, block.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
                                }
                            }
                        }
                    }
                }
                for (int i3 = 0; i3 < i; ++i3) {
                    IBlockState iblockstate = worldIn.getBlockState(position.up(i3));
                    if (iblockstate.getBlock().canBeReplacedByLeaves(iblockstate, worldIn, position.up(i3))) {
                        this.setBlockAndNotifyAdequately(worldIn, position.up(i3), block.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
                    }
                }
                return true;
            }
        }
    } else {
        return false;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockHugeMushroom(net.minecraft.block.BlockHugeMushroom) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with BlockHugeMushroom

use of net.minecraft.block.BlockHugeMushroom in project Minecraft-SlientClient-Hack by YouNeverKnow00.

the class WorldGenBigMushroom method generate.

public boolean generate(World worldIn, Random rand, BlockPos position) {
    Block block = this.mushroomType;
    if (block == null) {
        block = rand.nextBoolean() ? Blocks.BROWN_MUSHROOM_BLOCK : Blocks.RED_MUSHROOM_BLOCK;
    }
    int i = rand.nextInt(3) + 4;
    if (rand.nextInt(12) == 0) {
        i *= 2;
    }
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 < 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 3;
            if (j <= position.getY() + 3) {
                k = 0;
            }
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        Material material = worldIn.getBlockState(blockpos$mutableblockpos.setPos(l, j, i1)).getMaterial();
                        if (material != Material.AIR && material != Material.LEAVES) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            Block block1 = worldIn.getBlockState(position.down()).getBlock();
            if (block1 != Blocks.DIRT && block1 != Blocks.GRASS && block1 != Blocks.MYCELIUM) {
                return false;
            } else {
                int k2 = position.getY() + i;
                if (block == Blocks.RED_MUSHROOM_BLOCK) {
                    k2 = position.getY() + i - 3;
                }
                for (int l2 = k2; l2 <= position.getY() + i; ++l2) {
                    int j3 = 1;
                    if (l2 < position.getY() + i) {
                        ++j3;
                    }
                    if (block == Blocks.BROWN_MUSHROOM_BLOCK) {
                        j3 = 3;
                    }
                    int k3 = position.getX() - j3;
                    int l3 = position.getX() + j3;
                    int j1 = position.getZ() - j3;
                    int k1 = position.getZ() + j3;
                    for (int l1 = k3; l1 <= l3; ++l1) {
                        for (int i2 = j1; i2 <= k1; ++i2) {
                            int j2 = 5;
                            if (l1 == k3) {
                                --j2;
                            } else if (l1 == l3) {
                                ++j2;
                            }
                            if (i2 == j1) {
                                j2 -= 3;
                            } else if (i2 == k1) {
                                j2 += 3;
                            }
                            BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
                            if (block == Blocks.BROWN_MUSHROOM_BLOCK || l2 < position.getY() + i) {
                                if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1)) {
                                    continue;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                            }
                            if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i) {
                                blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
                            }
                            if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE) {
                                BlockPos blockpos = new BlockPos(l1, l2, i2);
                                if (!worldIn.getBlockState(blockpos).isFullBlock()) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, block.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
                                }
                            }
                        }
                    }
                }
                for (int i3 = 0; i3 < i; ++i3) {
                    IBlockState iblockstate = worldIn.getBlockState(position.up(i3));
                    if (!iblockstate.isFullBlock()) {
                        this.setBlockAndNotifyAdequately(worldIn, position.up(i3), block.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
                    }
                }
                return true;
            }
        }
    } else {
        return false;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockHugeMushroom(net.minecraft.block.BlockHugeMushroom) BlockPos(net.minecraft.util.math.BlockPos) Material(net.minecraft.block.material.Material)

Example 3 with BlockHugeMushroom

use of net.minecraft.block.BlockHugeMushroom in project WizClient-1.8.9-Version by WizClient.

the class WorldGenBigMushroom method generate.

public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (this.mushroomType == null) {
        this.mushroomType = rand.nextBoolean() ? Blocks.brown_mushroom_block : Blocks.red_mushroom_block;
    }
    int i = rand.nextInt(3) + 4;
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 < 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 3;
            if (j <= position.getY() + 3) {
                k = 0;
            }
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        Block block = worldIn.getBlockState(blockpos$mutableblockpos.set(l, j, i1)).getBlock();
                        if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            Block block1 = worldIn.getBlockState(position.down()).getBlock();
            if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium) {
                return false;
            } else {
                int k2 = position.getY() + i;
                if (this.mushroomType == Blocks.red_mushroom_block) {
                    k2 = position.getY() + i - 3;
                }
                for (int l2 = k2; l2 <= position.getY() + i; ++l2) {
                    int j3 = 1;
                    if (l2 < position.getY() + i) {
                        ++j3;
                    }
                    if (this.mushroomType == Blocks.brown_mushroom_block) {
                        j3 = 3;
                    }
                    int k3 = position.getX() - j3;
                    int l3 = position.getX() + j3;
                    int j1 = position.getZ() - j3;
                    int k1 = position.getZ() + j3;
                    for (int l1 = k3; l1 <= l3; ++l1) {
                        for (int i2 = j1; i2 <= k1; ++i2) {
                            int j2 = 5;
                            if (l1 == k3) {
                                --j2;
                            } else if (l1 == l3) {
                                ++j2;
                            }
                            if (i2 == j1) {
                                j2 -= 3;
                            } else if (i2 == k1) {
                                j2 += 3;
                            }
                            BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
                            if (this.mushroomType == Blocks.brown_mushroom_block || l2 < position.getY() + i) {
                                if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1)) {
                                    continue;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                            }
                            if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i) {
                                blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
                            }
                            if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE) {
                                BlockPos blockpos = new BlockPos(l1, l2, i2);
                                if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock()) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.mushroomType.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
                                }
                            }
                        }
                    }
                }
                for (int i3 = 0; i3 < i; ++i3) {
                    Block block2 = worldIn.getBlockState(position.up(i3)).getBlock();
                    if (!block2.isFullBlock()) {
                        this.setBlockAndNotifyAdequately(worldIn, position.up(i3), this.mushroomType.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
                    }
                }
                return true;
            }
        }
    } else {
        return false;
    }
}
Also used : Block(net.minecraft.block.Block) BlockHugeMushroom(net.minecraft.block.BlockHugeMushroom) BlockPos(net.minecraft.util.BlockPos)

Example 4 with BlockHugeMushroom

use of net.minecraft.block.BlockHugeMushroom in project kull by Sxmurai.

the class WorldGenBigMushroom method generate.

public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (this.mushroomType == null) {
        this.mushroomType = rand.nextBoolean() ? Blocks.brown_mushroom_block : Blocks.red_mushroom_block;
    }
    int i = rand.nextInt(3) + 4;
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 < 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 3;
            if (j <= position.getY() + 3) {
                k = 0;
            }
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        Block block = worldIn.getBlockState(blockpos$mutableblockpos.func_181079_c(l, j, i1)).getBlock();
                        if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            Block block1 = worldIn.getBlockState(position.down()).getBlock();
            if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium) {
                return false;
            } else {
                int k2 = position.getY() + i;
                if (this.mushroomType == Blocks.red_mushroom_block) {
                    k2 = position.getY() + i - 3;
                }
                for (int l2 = k2; l2 <= position.getY() + i; ++l2) {
                    int j3 = 1;
                    if (l2 < position.getY() + i) {
                        ++j3;
                    }
                    if (this.mushroomType == Blocks.brown_mushroom_block) {
                        j3 = 3;
                    }
                    int k3 = position.getX() - j3;
                    int l3 = position.getX() + j3;
                    int j1 = position.getZ() - j3;
                    int k1 = position.getZ() + j3;
                    for (int l1 = k3; l1 <= l3; ++l1) {
                        for (int i2 = j1; i2 <= k1; ++i2) {
                            int j2 = 5;
                            if (l1 == k3) {
                                --j2;
                            } else if (l1 == l3) {
                                ++j2;
                            }
                            if (i2 == j1) {
                                j2 -= 3;
                            } else if (i2 == k1) {
                                j2 += 3;
                            }
                            BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
                            if (this.mushroomType == Blocks.brown_mushroom_block || l2 < position.getY() + i) {
                                if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1)) {
                                    continue;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                            }
                            if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i) {
                                blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
                            }
                            if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE) {
                                BlockPos blockpos = new BlockPos(l1, l2, i2);
                                if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock()) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.mushroomType.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
                                }
                            }
                        }
                    }
                }
                for (int i3 = 0; i3 < i; ++i3) {
                    Block block2 = worldIn.getBlockState(position.up(i3)).getBlock();
                    if (!block2.isFullBlock()) {
                        this.setBlockAndNotifyAdequately(worldIn, position.up(i3), this.mushroomType.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
                    }
                }
                return true;
            }
        }
    } else {
        return false;
    }
}
Also used : Block(net.minecraft.block.Block) BlockHugeMushroom(net.minecraft.block.BlockHugeMushroom) BlockPos(net.minecraft.util.BlockPos)

Example 5 with BlockHugeMushroom

use of net.minecraft.block.BlockHugeMushroom in project UtilityClient2 by Utility-Client.

the class WorldGenBigMushroom method generate.

public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (this.mushroomType == null) {
        this.mushroomType = rand.nextBoolean() ? Blocks.brown_mushroom_block : Blocks.red_mushroom_block;
    }
    int i = rand.nextInt(3) + 4;
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 < 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 3;
            if (j <= position.getY() + 3) {
                k = 0;
            }
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        Block block = worldIn.getBlockState(blockpos$mutableblockpos.func_181079_c(l, j, i1)).getBlock();
                        if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            Block block1 = worldIn.getBlockState(position.down()).getBlock();
            if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium) {
                return false;
            } else {
                int k2 = position.getY() + i;
                if (this.mushroomType == Blocks.red_mushroom_block) {
                    k2 = position.getY() + i - 3;
                }
                for (int l2 = k2; l2 <= position.getY() + i; ++l2) {
                    int j3 = 1;
                    if (l2 < position.getY() + i) {
                        ++j3;
                    }
                    if (this.mushroomType == Blocks.brown_mushroom_block) {
                        j3 = 3;
                    }
                    int k3 = position.getX() - j3;
                    int l3 = position.getX() + j3;
                    int j1 = position.getZ() - j3;
                    int k1 = position.getZ() + j3;
                    for (int l1 = k3; l1 <= l3; ++l1) {
                        for (int i2 = j1; i2 <= k1; ++i2) {
                            int j2 = 5;
                            if (l1 == k3) {
                                --j2;
                            } else if (l1 == l3) {
                                ++j2;
                            }
                            if (i2 == j1) {
                                j2 -= 3;
                            } else if (i2 == k1) {
                                j2 += 3;
                            }
                            BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
                            if (this.mushroomType == Blocks.brown_mushroom_block || l2 < position.getY() + i) {
                                if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1)) {
                                    continue;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == j1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() - (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
                                }
                                if (l1 == position.getX() - (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == k3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
                                }
                                if (l1 == position.getX() + (j3 - 1) && i2 == k1) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                                if (l1 == l3 && i2 == position.getZ() + (j3 - 1)) {
                                    blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
                                }
                            }
                            if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i) {
                                blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
                            }
                            if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE) {
                                BlockPos blockpos = new BlockPos(l1, l2, i2);
                                if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock()) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.mushroomType.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
                                }
                            }
                        }
                    }
                }
                for (int i3 = 0; i3 < i; ++i3) {
                    Block block2 = worldIn.getBlockState(position.up(i3)).getBlock();
                    if (!block2.isFullBlock()) {
                        this.setBlockAndNotifyAdequately(worldIn, position.up(i3), this.mushroomType.getDefaultState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
                    }
                }
                return true;
            }
        }
    } else {
        return false;
    }
}
Also used : Block(net.minecraft.block.Block) BlockHugeMushroom(net.minecraft.block.BlockHugeMushroom) BlockPos(net.minecraft.util.BlockPos)

Aggregations

Block (net.minecraft.block.Block)6 BlockHugeMushroom (net.minecraft.block.BlockHugeMushroom)6 BlockPos (net.minecraft.util.BlockPos)3 IBlockState (net.minecraft.block.state.IBlockState)2 BlockPos (net.minecraft.util.math.BlockPos)2 BlockBasePlanks (gregapi.block.metatype.BlockBasePlanks)1 BlockBaseBale (gregapi.block.misc.BlockBaseBale)1 BlockBaseBeam (gregapi.block.tree.BlockBaseBeam)1 BlockBaseLog (gregapi.block.tree.BlockBaseLog)1 BlockBaseSapling (gregapi.block.tree.BlockBaseSapling)1 IItemNoGTOverride (gregapi.item.IItemNoGTOverride)1 MultiItemRandom (gregapi.item.multiitem.MultiItemRandom)1 OreDictItemData (gregapi.oredict.OreDictItemData)1 OreDictMaterialStack (gregapi.oredict.OreDictMaterialStack)1 BlockRailBase (net.minecraft.block.BlockRailBase)1 Material (net.minecraft.block.material.Material)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1