copied from FTBmad