package common.block;

import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemShears;
import common.item.ItemStack;
import common.material.Material;
import common.model.Model;
import common.model.ModelProvider;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.world.State;
import common.world.World;

public class BlockDeadBush extends BlockBush
{
	public BlockDeadBush()
    {
        super(Material.vine);
        float f = 0.4F;
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
    }

//    /**
//     * Get the MapColor for this Block and the given BlockState
//     */
//    public MapColor getMapColor(IBlockState state)
//    {
//        return MapColor.woodColor;
//    }

    /**
     * is the block grass, dirt or farmland
     */
    protected boolean canPlaceBlockOn(Block ground)
    {
        return ground == Blocks.sand || ground == Blocks.hardened_clay || ground == Blocks.stained_hardened_clay || ground == Blocks.dirt;
    }

    /**
     * Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
     */
    public boolean isReplaceable(World worldIn, BlockPos pos)
    {
        return true;
    }

    /**
     * Get the Item that this Block should drop when harvested.
     */
    public Item getItemDropped(State state, Random rand, int fortune)
    {
        return rand.chance(5) ? Items.stick : null;
    }

    public void harvestBlock(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te)
    {
        if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears)
        {
//            player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
            spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0));
        }
        else
        {
            super.harvestBlock(worldIn, player, pos, state, te);
        }
    }

    public Model getModel(ModelProvider provider, String name, State state) {
    	return provider.getModel("deadbush").cross();
    }
}
