Java Code Examples for net.minecraft.block.material.Material.leaves()

The following are Jave code examples for showing how to use leaves() of the net.minecraft.block.material.Material class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: WorldGenHugeTrees.java   View Source Code Vote up 6 votes
protected void func_175925_a(World worldIn, BlockPos p_175925_2_, int p_175925_3_)
{
    int i = p_175925_3_ * p_175925_3_;

    for (int j = -p_175925_3_; j <= p_175925_3_ + 1; ++j)
    {
        for (int k = -p_175925_3_; k <= p_175925_3_ + 1; ++k)
        {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
            {
                BlockPos blockpos = p_175925_2_.add(j, 0, k);
                Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();

                if (material == Material.air || material == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 2
Project: BaseClient   File: BlockLog.java   View Source Code Vote up 6 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 4;
    int j = i + 1;

    if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j)))
    {
        for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)))
        {
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(BlockLeaves.CHECK_DECAY)).booleanValue())
            {
                worldIn.setBlockState(blockpos, iblockstate.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
            }
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: WorldGenHugeTrees.java   View Source Code Vote up 6 votes
protected void func_175928_b(World worldIn, BlockPos p_175928_2_, int p_175928_3_)
{
    int i = p_175928_3_ * p_175928_3_;

    for (int j = -p_175928_3_; j <= p_175928_3_; ++j)
    {
        for (int k = -p_175928_3_; k <= p_175928_3_; ++k)
        {
            if (j * j + k * k <= i)
            {
                BlockPos blockpos = p_175928_2_.add(j, 0, k);
                Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();

                if (material == Material.air || material == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 4
Project: BaseClient   File: EntityOcelot.java   View Source Code Vote up 6 votes
/**
 * Checks that the entity is not colliding with any blocks / liquids
 */
public boolean isNotColliding()
{
    if (this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox()))
    {
        BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);

        if (blockpos.getY() < this.worldObj.func_181545_F())
        {
            return false;
        }

        Block block = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block == Blocks.grass || block.getMaterial() == Material.leaves)
        {
            return true;
        }
    }

    return false;
}
 
Example 5
Project: DecompiledMinecraft   File: EntityOcelot.java   View Source Code Vote up 6 votes
/**
 * Checks that the entity is not colliding with any blocks / liquids
 */
public boolean isNotColliding()
{
    if (this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox()))
    {
        BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);

        if (blockpos.getY() < this.worldObj.func_181545_F())
        {
            return false;
        }

        Block block = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block == Blocks.grass || block.getMaterial() == Material.leaves)
        {
            return true;
        }
    }

    return false;
}
 
Example 6
Project: DecompiledMinecraft   File: World.java   View Source Code Vote up 6 votes
/**
 * Finds the highest block on the x and z coordinate that is solid or liquid, and returns its y coord.
 */
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos)
{
    Chunk chunk = this.getChunkFromBlockCoords(pos);
    BlockPos blockpos;
    BlockPos blockpos1;

    for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
    {
        blockpos1 = blockpos.down();
        Material material = chunk.getBlock(blockpos1).getMaterial();

        if (material.blocksMovement() && material != Material.leaves)
        {
            break;
        }
    }

    return blockpos;
}
 
Example 7
Project: BaseClient   File: WorldGenBigTree.java   View Source Code Vote up 6 votes
void func_181631_a(BlockPos p_181631_1_, float p_181631_2_, IBlockState p_181631_3_)
{
    int i = (int)((double)p_181631_2_ + 0.618D);

    for (int j = -i; j <= i; ++j)
    {
        for (int k = -i; k <= i; ++k)
        {
            if (Math.pow((double)Math.abs(j) + 0.5D, 2.0D) + Math.pow((double)Math.abs(k) + 0.5D, 2.0D) <= (double)(p_181631_2_ * p_181631_2_))
            {
                BlockPos blockpos = p_181631_1_.add(j, 0, k);
                Material material = this.world.getBlockState(blockpos).getBlock().getMaterial();

                if (material == Material.air || material == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(this.world, blockpos, p_181631_3_);
                }
            }
        }
    }
}
 
Example 8
Project: BaseClient   File: World.java   View Source Code Vote up 6 votes
/**
 * Finds the highest block on the x and z coordinate that is solid or liquid, and returns its y coord.
 */
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos)
{
    Chunk chunk = this.getChunkFromBlockCoords(pos);
    BlockPos blockpos;
    BlockPos blockpos1;

    for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
    {
        blockpos1 = blockpos.down();
        Material material = chunk.getBlock(blockpos1).getMaterial();

        if (material.blocksMovement() && material != Material.leaves)
        {
            break;
        }
    }

    return blockpos;
}
 
Example 9
Project: DecompiledMinecraft   File: BlockLog.java   View Source Code Vote up 6 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 4;
    int j = i + 1;

    if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j)))
    {
        for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)))
        {
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(BlockLeaves.CHECK_DECAY)).booleanValue())
            {
                worldIn.setBlockState(blockpos, iblockstate.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
            }
        }
    }
}
 
Example 10
Project: BaseClient   File: EntityOcelot.java   View Source Code Vote up 6 votes
/**
 * Checks that the entity is not colliding with any blocks / liquids
 */
public boolean isNotColliding()
{
    if (this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox()))
    {
        BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);

        if (blockpos.getY() < this.worldObj.func_181545_F())
        {
            return false;
        }

        Block block = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block == Blocks.grass || block.getMaterial() == Material.leaves)
        {
            return true;
        }
    }

    return false;
}
 
Example 11
Project: BaseClient   File: WorldGenSavannaTree.java   View Source Code Vote up 5 votes
private void func_175924_b(World worldIn, BlockPos p_175924_2_)
{
    Material material = worldIn.getBlockState(p_175924_2_).getBlock().getMaterial();

    if (material == Material.air || material == Material.leaves)
    {
        this.setBlockAndNotifyAdequately(worldIn, p_175924_2_, field_181644_b);
    }
}
 
Example 12
Project: BaseClient   File: ItemShears.java   View Source Code Vote up 5 votes
/**
 * Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
 */
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
{
    if (blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool)
    {
        return super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn);
    }
    else
    {
        stack.damageItem(1, playerIn);
        return true;
    }
}
 
Example 13
Project: BaseClient   File: ItemSword.java   View Source Code Vote up 5 votes
public float getStrVsBlock(ItemStack stack, Block block)
{
    if (block == Blocks.web)
    {
        return 15.0F;
    }
    else
    {
        Material material = block.getMaterial();
        return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
    }
}
 
Example 14
Project: DecompiledMinecraft   File: ItemShears.java   View Source Code Vote up 5 votes
/**
 * Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
 */
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
{
    if (blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool)
    {
        return super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn);
    }
    else
    {
        stack.damageItem(1, playerIn);
        return true;
    }
}
 
Example 15
Project: DecompiledMinecraft   File: WorldGenMegaPineTree.java   View Source Code Vote up 4 votes
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    int i = this.func_150533_a(rand);

    if (!this.func_175929_a(worldIn, rand, position, i))
    {
        return false;
    }
    else
    {
        this.func_150541_c(worldIn, position.getX(), position.getZ(), position.getY() + i, 0, rand);

        for (int j = 0; j < i; ++j)
        {
            Block block = worldIn.getBlockState(position.up(j)).getBlock();

            if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
            {
                this.setBlockAndNotifyAdequately(worldIn, position.up(j), this.woodMetadata);
            }

            if (j < i - 1)
            {
                block = worldIn.getBlockState(position.add(1, j, 0)).getBlock();

                if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 0), this.woodMetadata);
                }

                block = worldIn.getBlockState(position.add(1, j, 1)).getBlock();

                if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 1), this.woodMetadata);
                }

                block = worldIn.getBlockState(position.add(0, j, 1)).getBlock();

                if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(0, j, 1), this.woodMetadata);
                }
            }
        }

        return true;
    }
}
 
Example 16
Project: DecompiledMinecraft   File: WorldGenAbstractTree.java   View Source Code Vote up 4 votes
protected boolean func_150523_a(Block p_150523_1_)
{
    Material material = p_150523_1_.getMaterial();
    return material == Material.air || material == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log2 || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine;
}
 
Example 17
Project: DecompiledMinecraft   File: WorldGenShrub.java   View Source Code Vote up 4 votes
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Block block;

    while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
    {
        position = position.down();
    }

    Block block1 = worldIn.getBlockState(position).getBlock();

    if (block1 == Blocks.dirt || block1 == Blocks.grass)
    {
        position = position.up();
        this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);

        for (int i = position.getY(); i <= position.getY() + 2; ++i)
        {
            int j = i - position.getY();
            int k = 2 - j;

            for (int l = position.getX() - k; l <= position.getX() + k; ++l)
            {
                int i1 = l - position.getX();

                for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
                {
                    int k1 = j1 - position.getZ();

                    if (Math.abs(i1) != k || Math.abs(k1) != k || rand.nextInt(2) != 0)
                    {
                        BlockPos blockpos = new BlockPos(l, i, j1);

                        if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock())
                        {
                            this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                        }
                    }
                }
            }
        }
    }

    return true;
}
 
Example 18
Project: DecompiledMinecraft   File: ItemShears.java   View Source Code Vote up 4 votes
public float getStrVsBlock(ItemStack stack, Block block)
{
    return block != Blocks.web && block.getMaterial() != Material.leaves ? (block == Blocks.wool ? 5.0F : super.getStrVsBlock(stack, block)) : 15.0F;
}
 
Example 19
Project: BaseClient   File: ItemShears.java   View Source Code Vote up 4 votes
public float getStrVsBlock(ItemStack stack, Block block)
{
    return block != Blocks.web && block.getMaterial() != Material.leaves ? (block == Blocks.wool ? 5.0F : super.getStrVsBlock(stack, block)) : 15.0F;
}
 
Example 20
Project: DecompiledMinecraft   File: BlockSnow.java   View Source Code Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    IBlockState iblockstate = worldIn.getBlockState(pos.down());
    Block block = iblockstate.getBlock();
    return block != Blocks.ice && block != Blocks.packed_ice ? (block.getMaterial() == Material.leaves ? true : (block == this && ((Integer)iblockstate.getValue(LAYERS)).intValue() >= 7 ? true : block.isOpaqueCube() && block.blockMaterial.blocksMovement())) : false;
}