package JAKJ . RedstoneInMotion ;

public class CarriageDrive extends Block
{
	public static int Id ;

	public CarriageDrive ( )
	{
		super ( Id , blockIron , "pickaxe" ) ;
	}

	@Override
	public Class < ? extends BlockItem > BlockItemClass ( )
	{
		return ( CarriageDriveItem . class ) ;
	}

	public enum Types
	{
		Engine ( "Carriage Engine" , CarriageEngineEntity . class , "Moves with the carriage" ) ,
		Motor ( "Carriage Motor" , CarriageMotorEntity . class , "Moves the carriage while staying put" ) ,
		Controller ( "Carriage Controller" , null , "Moves according to ComputerCraft control" ) ;

		public final String Name ;

		public Class < ? extends TileEntity > Class ;

		public final String Tooltip ;

		public final IconHolder NormalIcon ;
		public final IconHolder ContinuousIcon ;
		public final IconHolder NormalActiveIcon ;
		public final IconHolder ContinuousActiveIcon ;

		private Types ( String Name , Class < ? extends TileEntity > Class , String Tooltip )
		{
			this . Name = Name ;

			this . Class = Class ;

			this . Tooltip = Tooltip ;

			NormalIcon = new IconHolder ( "Carriage" + name ( ) ) ;
			ContinuousIcon = new IconHolder ( "Carriage" + name ( ) + "_Continuous" ) ;
			NormalActiveIcon = new IconHolder ( "Carriage" + name ( ) + "_Active" ) ;
			ContinuousActiveIcon = new IconHolder ( "Carriage" + name ( ) + "_Continuous_Active" ) ;
		}
	}

	@Override
	public int SubTypeCount ( )
	{
		return ( Types . values ( ) . length ) ;
	}

	@Override
	public void RegisterShowcaseStacks ( )
	{
		for ( Types Type : Types . values ( ) )
		{
			if ( Type . Class == null )
			{
				continue ;
			}

			RegisterShowcaseStack ( new Stack ( this , Type ) ) ;
		}
	}

	@Override
	public Class < ? extends TileEntity > TileEntityClass ( int Index )
	{
		return ( Types . values ( ) [ Index ] . Class ) ;
	}

	@Override
	public void RegisterIcons ( IconRegister Register )
	{
		for ( Types Type : Types . values ( ) )
		{
			Register . Register ( Type . NormalIcon ) ;
			Register . Register ( Type . ContinuousIcon ) ;
			Register . Register ( Type . NormalActiveIcon ) ;
			Register . Register ( Type . ContinuousActiveIcon ) ;
		}
	}

	@Override
	public IconHolder GetIcon ( int Side , int Meta )
	{
		return ( Types . values ( ) [ Meta ] . NormalIcon ) ;
	}

	@Override
	public void onNeighborBlockChange ( net . minecraft . world . World World , int X , int Y , int Z , int Id )
	{
		CarriageDriveEntity Drive = ( CarriageDriveEntity ) World . getBlockTileEntity ( X , Y , Z ) ;

		if ( Drive == null )
		{
			return ;
		}

		Drive . HandleNeighbourBlockChange ( ) ;
	}

	@Override
	public boolean onBlockActivated ( net . minecraft . world . World World , int X , int Y , int Z , net . minecraft . entity . player . EntityPlayer Player , int Side , float HitX , float HitY , float HitZ )
	{
		if ( World . isRemote )
		{
			return ( false ) ;
		}

		if ( ! IsScrewdriverEquivalent ( Player . inventory . getCurrentItem ( ) ) )
		{
			return ( false ) ;
		}

		CarriageDriveEntity Drive = ( CarriageDriveEntity ) World . getBlockTileEntity ( X , Y , Z ) ;

		if ( Drive == null )
		{
			return ( false ) ;
		}

		Drive . ToggleContinuity ( ) ;

		return ( true ) ;
	}
}
