package hmggirlfront.block;

import hmggirlfront.mod_GirlFront;
import hmggirlfront.items.ItemDollCore;
import hmggirlfront.items.ItemDollGunBase;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockM_Dismantling extends Block
{

    public BlockM_Dismantling()
    {
    	super(Material.IRON);
        this.setHardness(5F);
        this.setResistance(10.0F);
        this.setSoundType(SoundType.METAL);
    }

    /**
     * Called when the block is right clicked by a player.
     */
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
    	ItemStack itemstack = playerIn.getHeldItem(hand);
    	if(!itemstack.isEmpty() && itemstack.getItem() instanceof ItemDollCore) {
    		ItemDollCore core = (ItemDollCore) itemstack.getItem();
    		if(!worldIn.isRemote) {
    			if(core.main != null && core.main instanceof ItemDollGunBase) {
        			ItemDollGunBase gun = (ItemDollGunBase) core.main;
        			if(gun.doll_d_hp > 0)spawnAsEntity(worldIn, pos, new ItemStack(mod_GirlFront.idoll_hp, gun.doll_d_hp));
        			if(gun.doll_d_bullet > 0)spawnAsEntity(worldIn, pos, new ItemStack(mod_GirlFront.idoll_bullet, gun.doll_d_bullet));
        			if(gun.doll_d_food > 0)spawnAsEntity(worldIn, pos, new ItemStack(mod_GirlFront.idoll_food, gun.doll_d_food));
        			if(gun.doll_d_parts > 0)spawnAsEntity(worldIn, pos, new ItemStack(mod_GirlFront.idoll_parts, gun.doll_d_parts));
        			if(gun.doll_d_core > 0)spawnAsEntity(worldIn, pos, new ItemStack(mod_GirlFront.idoll_core, gun.doll_d_core));
        			if (!playerIn.capabilities.isCreativeMode)
    		        {
    		        	itemstack.shrink(1);
    		        }
        		}
    		}
    	}
        
        return true;
    }
    
    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT;
    }
    
    public boolean isFullCube(IBlockState state)
    {
        return false;
    }

    /**
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
     */
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }
    
    /**
     * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
     */
    public EnumBlockRenderType getRenderType(IBlockState state)
    {
        return EnumBlockRenderType.MODEL;
    }
    
    

	

}