ported by fayz_golden for clockwork