package JAKJ . RedstoneInMotion ;

public class CarriageDriveItem extends BlockItem
{
	public CarriageDriveItem ( int Id )
	{
		super ( Id ) ;
	}

	public static boolean GetPrivateFlag ( net . minecraft . item . ItemStack Item )
	{
		return ( ( ( Item . itemDamage >>> 4 ) & 0x1 ) == 1 ) ;
	}

	public static int GetLabel ( net . minecraft . item . ItemStack Item )
	{
		return ( Item . itemDamage >>> 5 ) ;
	}

	public static boolean LabelWillResultInValidItemStack ( int Label )
	{
		return ( ( Label << 5 ) <= Short . MAX_VALUE ) ;
	}

	public static int AddDyeToLabel ( int Label , Vanilla . DyeTypes DyeType )
	{
		return ( Label | ( 1 << DyeType . ordinal ( ) ) ) ;
	}

	public static boolean LabelHasDye ( int Label , Vanilla . DyeTypes DyeType )
	{
		return ( ( ( Label >>> DyeType . ordinal ( ) ) & 0x1 ) == 1 ) ;
	}

	public static net . minecraft . item . ItemStack Stack ( int Type )
	{
		return ( Stack . New ( Blocks . CarriageDrive , Type ) ) ;
	}

	public static net . minecraft . item . ItemStack Stack ( int Type , boolean Private , int Label )
	{
		return ( Stack . New ( Blocks . CarriageDrive , ( Label << 5 ) | ( ( Private ? 1 : 0 ) << 4 ) | Type ) ) ;
	}

	@Override
	public String getItemDisplayName ( net . minecraft . item . ItemStack Item )
	{
		try
		{
			switch ( CarriageDrive . Types . values ( ) [ GetBlockType ( Item ) ] )
			{
				case Engine :

					return ( "Carriage Engine" ) ;

				case Motor :

					return ( "Carriage Motor" ) ;

				case Translocator :

					return ( "Carriage Translocator" ) ;

				case Controller :

					return ( "Carriage Controller" ) ;
			}
		}
		catch ( Throwable Throwable )
		{
			Throwable . printStackTrace ( ) ;
		}

		return ( "INVALID CARRIAGE DRIVE" ) ;
	}

	@Override
	public void AddTooltip ( net . minecraft . item . ItemStack Item , java . util . List TooltipLines )
	{
		int Type = GetBlockType ( Item ) ;

		try
		{
			switch ( CarriageDrive . Types . values ( ) [ Type ] )
			{
				case Engine :

					TooltipLines . add ( "Moves with the carriage" ) ;

					break ;

				case Motor :

					TooltipLines . add ( "Moves the carriage while staying put" ) ;

					break ;

				case Translocator :

					TooltipLines . add ( "Teleports the carriage to a remote position" ) ;

					break ;

				case Controller :

					TooltipLines . add ( "Moves according to ComputerCraft control" ) ;

					break ;
			}
		}
		catch ( Throwable Throwable )
		{
			Throwable . printStackTrace ( ) ;

			return ;
		}

		if ( Type == CarriageDrive . Types . Translocator . ordinal ( ) )
		{
			boolean Private = GetPrivateFlag ( Item ) ;

			int Label = GetLabel ( Item ) ;

			if ( Private )
			{
				TooltipLines . add ( "Label (private):" ) ;
			}
			else
			{
				TooltipLines . add ( "Label:" ) ;
			}

			if ( Label == 0 )
			{
				TooltipLines . add ( "<blank>" ) ;

				return ;
			}

			for ( Vanilla . DyeTypes DyeType : Vanilla . DyeTypes . values ( ) )
			{
				if ( LabelHasDye ( Label , DyeType ) )
				{
					TooltipLines . add ( " - " + DyeType . name ( ) ) ;
				}
			}
		}
	}
}
