package JAKJ . RedstoneInMotion ;

public class TeleportativeSpectreRenderer extends TileEntityRenderer
{
	@Override
	public void Render ( net . minecraft . tileentity . TileEntity TileEntity , float PartialTick )
	{
		TeleportativeSpectreEntity Spectre = ( TeleportativeSpectreEntity ) TileEntity ;

		if ( Spectre . RenderCacheKey == null )
		{
			return ;
		}

		Integer DisplayList = CarriageRenderCache . Lookup ( Spectre . RenderCacheKey ) ;

		if ( DisplayList == null )
		{
			return ;
		}

		double Timestamp = Math . min ( Spectre . TicksExisted + PartialTick , Spectre . TeleportationDuration ) ;

		double Threshold = ( Timestamp / Spectre . TeleportationDuration ) * 0.95 + 0.025 ;

		double Value = Math . abs ( Math . sin ( Timestamp * ( ( 2 * Math . PI ) / 20 ) * 4 ) ) ;

		if ( Spectre . Source == true )
		{
			Render . Translate ( - Spectre . xCoord , - Spectre . yCoord , - Spectre . zCoord ) ;
		}
		else
		{
			Threshold = 1 - Threshold ;

			Render . Translate ( - Spectre . xCoord + Spectre . ShiftX , - Spectre . yCoord + Spectre . ShiftY , - Spectre . zCoord + Spectre . ShiftZ ) ;
		}

		if ( Value > Threshold )
		{
			RenderEngine . ResetBoundTexture ( ) ;

			Render . ExecuteDisplayList ( DisplayList ) ;

			RenderEngine . ResetBoundTexture ( ) ;
		}
	}
}
