package JAKJ . RedstoneInMotion ;

public class Carriage extends Block
{
	public static int Id ;

	public Carriage ( )
	{
		super ( Id , wood , "axe" ) ;
	}

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

	public enum Types
	{
		Frame ( "Frame Carriage" , FrameCarriageEntity . class , "Carries blocks directly touching it" ) ,
		Platform ( "Platform Carriage" , PlatformCarriageEntity . class , "Carries entire body of blocks it's connected to" ) ,
		Structure ( "Structure Carriage" , StructureCarriageEntity . class , "Carries entire cuboid of world" ) ,
		Support ( "Support Carriage" , SupportCarriageEntity . class , "Carries straight line of blocks" ) ,
		Template ( "Template Carriage" , TemplateCarriageEntity . class , "Carries blocks in the exact pattern prepared" ) ;

		public final String Name ;

		public final Class < ? extends TileEntity > Class ;

		public final String Tooltip ;

		public final IconHolder OpenIcon ;
		public final IconHolder ClosedIcon ;

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

			this . Class = Class ;

			this . Tooltip = Tooltip ;

			OpenIcon = new IconHolder ( name ( ) + "Carriage_Open" ) ;
			ClosedIcon = new IconHolder ( name ( ) + "Carriage_Closed" ) ;
		}
	}

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

	@Override
	public void RegisterShowcaseStacks ( )
	{
		for ( Types Type : Types . values ( ) )
		{
			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 . ClosedIcon ) ;
			Register . Register ( Type . OpenIcon ) ;
		}
	}

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

	@Override
	public boolean isOpaqueCube ( )
	{
		return ( false ) ;
	}

	@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 ) ;
		}

		CarriageEntity Carriage = ( CarriageEntity ) World . getBlockTileEntity ( X , Y , Z ) ;

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

		if ( Player . isSneaking ( ) && ( ! ( Carriage instanceof StructureCarriageEntity ) ) )
		{
			Side = Directions . values ( ) [ Side ] . Opposite ( ) . ordinal ( ) ;
		}

		Carriage . ToggleSide ( Side ) ;

		return ( true ) ;
	}
}
