package othlon.cherrypig.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import othlon.cherrypig.CherryPig;

import java.util.List;

/**
 * Created by Jen on 30/05/14.
 */
public class CPCherrySapling extends BlockSapling {

    private IIcon texture;

    public CPCherrySapling() {
        float f = 0.4F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
        this.setHardness(0.0F);
        this.setStepSound(Block.soundTypeGrass);
        this.setCreativeTab(CherryPig.tabCherryPig);

    }

    @Override
    public void registerBlockIcons(IIconRegister iconRegister) {


        texture = iconRegister.registerIcon("cherrypig:cherrypig_sapling");
    }

    public boolean isValidPosition(World world, int x, int y, int z, int metadata) {

        Block block = world.getBlock(x, y - 1, z);

        return block == Blocks.grass || block == Blocks.dirt || block == Blocks.farmland || block.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this);

    }

    @Override
    public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) {
        //noinspection unchecked
        p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0));
    }

    @Override
    public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side) {
        return isValidPosition(world, x, y, z, -1);
    }


}

@@ -211,24 +211,74 @@
 ativeTabs;%0D%0A
+import net.minecraft.entity.player.EntityPlayer;%0D%0A
 import net.m
@@ -535,31 +535,108 @@
 g;%0D%0A
-%0D%0Aimport java.util.List
+import othlon.cherrypig.worldgen.CPCherryTreeGen;%0D%0A%0D%0Aimport java.util.List;%0D%0Aimport java.util.Random
 ;%0D%0A%0D
@@ -1041,32 +1041,407 @@
 g);%0D%0A%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A    public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) %7B%0D%0A        return p_149727_1_.isRemote %7C%7C new CPCherryTreeGen().generate(p_149727_1_, p_149727_1_.rand, p_149727_2_, p_149727_3_, p_149727_4_);%0D%0A    %7D%0D%0A%0D%0A
     @Override%0D%0A 
@@ -2284,13 +2284,169 @@
    %7D%0D%0A%0D%0A
+    @Override%0D%0A    public void func_149878_d(World world, int x, int y, int z, Random rand) %7B%0D%0A//        super.func_149878_d(world, x, y, z, rand);%0D%0A%0D%0A    %7D
 %0D%0A%7D%0D%0A

Debug code on sapling until bonemeal