package hmggirlfront.block;

import javax.annotation.Nullable;

import gvclib.entity.EntityBBase;
import gvclib.world.GVCExplosionBase;
import hmggirlfront.block.tile.TileEntity_Spawn_ONE;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class Block_Spawn_ONE extends BlockContainer
{

	protected static final AxisAlignedBB ATMine_AABB = new AxisAlignedBB(0.1D, 0.0D, 0.1D, 0.9D, 1.8D, 0.9D);
	
    public Block_Spawn_ONE()
    {
        super(Material.WOOD);
        //this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(DAMAGE, Integer.valueOf(0)));
        setHardness(1.5F);
        setResistance(10.0F);
       // setLightOpacity(1);
      //  setLightLevel(1.0F);
    }
    
    @Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return new TileEntity_Spawn_ONE();
	}

    
    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;
    }
    
    @Nullable
    public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
    {
    	return ATMine_AABB;
    }
    /**
     * Return an AABB (in world coords!) that should be highlighted when the player is targeting this Block
     */
    @SideOnly(Side.CLIENT)
    public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos)
    {
    	 return ATMine_AABB.offset(pos);
    }

    /**
     * Called When an Entity Collided with the Block
     */
    public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
    {
    	double x = pos.getX();
    	double y = pos.getY();
    	double z = pos.getZ();
    	//if (!worldIn.isRemote) 
    	if(entityIn instanceof EntityBBase){
    		EntityBBase bullet = (EntityBBase) entityIn;
    		if( bullet.getThrower() instanceof IMob) {
    			
    		}else {
    			//if(worldIn.getBlockState(pos).getBlock() == mod_GVCR2.gvcr2_blockspawner_ge_s)
    			{
        			//if (!worldIn.isRemote) 
        		    	{
        					GVCExplosionBase.ExplosionKai(entityIn, entityIn, x, y + 0.5, z, 0.0F, false,  false);
        					worldIn.setBlockToAir(pos);
        				}
        		 }
    		}
    	}
    }

}