You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1184 lines
33KB

  1. #import <UIKit/UIKit.h>
  2. #import <CoreData/CoreData.h>
  3. #include <substrate.h>
  4. #define PLIST_PATH @"/var/mobile/Library/Preferences/BlockheadsInventory.plist"
  5. inline int GetPrefInt(NSString *key)
  6. {
  7. return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] intValue];
  8. }
  9. inline bool GetPrefBool(NSString *key)
  10. {
  11. return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] boolValue];
  12. }
  13. inline void SetPrefBool(NSString *key, bool value)
  14. {
  15. NSNumber *obj = [NSNumber numberWithBool:value];
  16. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:PLIST_PATH];
  17. [dict setObject:obj forKey:key];
  18. [dict writeToFile:PLIST_PATH atomically:YES];
  19. }
  20. inline void SetPrefInt(NSString *key, int value)
  21. {
  22. NSNumber *obj = [NSNumber numberWithInt:value];
  23. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:PLIST_PATH];
  24. [dict setObject:obj forKey:key];
  25. [dict writeToFile:PLIST_PATH atomically:YES];
  26. }
  27. //Inventory Hack Method Was Here
  28. NSArray *itemNames = @[@"hand",
  29. @"unknown",
  30. @"flint",
  31. @"sticks",
  32. @"unknown",
  33. @"flint axe",
  34. @"flint spear",
  35. @"flint pickaxe",
  36. @"double time",
  37. @"unknown",
  38. @"time crystal",
  39. @"baskets",
  40. @"embers",
  41. @"charcoal",
  42. @"campfires",
  43. @"flint spades",
  44. @"basic torches",
  45. @"unknown",
  46. @"blockheads",
  47. @"food",
  48. @"apples",
  49. @"mangos",
  50. @"maple seeds",
  51. @"prickly pears",
  52. @"flint machetes",
  53. @"unknown",
  54. @"pine cones ",
  55. @"clay",
  56. @"raw dodo meat",
  57. @"dodo feathers",
  58. @"copper ore",
  59. @"iron ore",
  60. @"stone axes",
  61. @"stone pickaxes",
  62. @"copper ingots",
  63. @"tin ore",
  64. @"tin ingots",
  65. @"bronze ingots",
  66. @"copper spears",
  67. @"tin spades",
  68. @"copper arrows",
  69. @"copper bow and arrows",
  70. @"bronze pickaxes",
  71. @"string",
  72. @"clay jugs",
  73. @"coconuts",
  74. @"oil lanterns ",
  75. @"oil",
  76. @"bronze machetes",
  77. @"bronze swords ",
  78. @"coal",
  79. @"wooden doors",
  80. @"ladders",
  81. @"flax seeds",
  82. @"flax",
  83. @"indian yellow",
  84. @"red ochre",
  85. @"windows",
  86. @"cooked dodo meat",
  87. @"oranges",
  88. @"sunflower seeds",
  89. @"corn",
  90. @"wooden beds",
  91. @"stone spades ",
  92. @"iron ingots",
  93. @"iron pickaxes",
  94. @"iron machetes ",
  95. @"iron swords ",
  96. @"trapdoors ",
  97. @"iron axes",
  98. @"carrots",
  99. @"gold ingots",
  100. @"gold nuggets",
  101. @"carrot on sticks",
  102. @"rubies",
  103. @"emeralds",
  104. @"cherries ",
  105. @"coffee cherries ",
  106. @"green coffee beans",
  107. @"cups",
  108. @"coffe",
  109. @"roasted coffee beans ",
  110. @"linen ",
  111. @"linen pants",
  112. @"linen shirts",
  113. @"sapphires ",
  114. @"amethysts",
  115. @"diamonds",
  116. @"gold spades",
  117. @"gold pickaxes",
  118. @"dodo eggs",
  119. @"steel ingots",
  120. @"steel pickaxes",
  121. @"amethysts pickaxe",
  122. @"sapphire pickaxes",
  123. @"emerald pickaxes",
  124. @"ruby pickaxes",
  125. @"diamond pickaxes",
  126. @"ultramarine blue",
  127. @"carbon black",
  128. @"marble white",
  129. @"tin bucket",
  130. @"paint",
  131. @"paint stripper",
  132. @"bucket of water",
  133. @"pigment",
  134. @"unknown - rainbow?",
  135. @"unknown",
  136. @"emerald green",
  137. @"tyrian purple",
  138. @"boat",
  139. @"chilli",
  140. @"unknown - rainbow pants",
  141. @"unknown - ranbow shirt",
  142. @"linen cap",
  143. @"unknown - rainbow cap",
  144. @"linen brimmed hat",
  145. @"unknown - rainbow hat",
  146. @"copper blue",
  147. @"leather",
  148. @"fur",
  149. @"leather jacket",
  150. @"unknown - rainbow jacket",
  151. @"leather boots",
  152. @"unknown - rainbow boots",
  153. @"fur coat",
  154. @"fur boots",
  155. @"unknown",
  156. @"unknown",
  157. @"leather pants",
  158. @"unknown",
  159. @"unknown - arrow (up)",
  160. @"camera",
  161. @"portal",
  162. @"amethyst portal",
  163. @"saphire portal",
  164. @"emerald portal",
  165. @"ruby portal",
  166. @"diamond portal",
  167. @"sunrise hat of fullness",
  168. @"sunset skirt of happiness",
  169. @"north pole hat of warmth",
  170. @"south pole boots of speed",
  171. @"kelp",
  172. @"amethyst chandelier",
  173. @"saphire chandelier",
  174. @"emerald chandelier",
  175. @"ruby chandelier",
  176. @"diamond chandelier",
  177. @"steel lanterns",
  178. @"raw fish",
  179. @"cooked fish",
  180. @"tin foil",
  181. @"tin foil hat",
  182. @"worm",
  183. @"fishing rod",
  184. @"shark jaw",
  185. @"fish bucket",
  186. @"shark bucket",
  187. @"lime",
  188. @"shelf",
  189. @"teleport here",
  190. @"sign",
  191. @"iron door",
  192. @"iron trapdoor",
  193. @"copper coin",
  194. @"Gold Coin",
  195. @"shop",
  196. @"soft bed",
  197. @"Golden Bed",
  198. @"unknown",
  199. @"unknown - rainbow bed",
  200. @"unknown - gold ^^",
  201. @"black window",
  202. @"magnet",
  203. @"copper boiler",
  204. @"electric motor",
  205. @"copper wore",
  206. @"steam engine",
  207. @"iron pot",
  208. @"fish curry",
  209. @"dodo stew",
  210. @"ice torch",
  211. @"silicon ingot",
  212. @"silicon crystal",
  213. @"silicon wafer",
  214. @"tin armor leggings",
  215. @"tin chest plate",
  216. @"tin helmet",
  217. @"tin boots",
  218. @"iron leggings",
  219. @"iron chest",
  220. @"iron helmet",
  221. @"iron boots",
  222. @"ice legs",
  223. @"ice chest",
  224. @"ice helmet",
  225. @"ice boots",
  226. @"rail",
  227. @"train station",
  228. @"pig iron",
  229. @"crushed limestone",
  230. @"train wheel",
  231. @"rail handcar",
  232. @"steam locomotive",
  233. @"freight car",
  234. @"display cabinet",
  235. @"passenger car",
  236. @"crowbar",
  237. @"Trade Portal",
  238. @"unknown",
  239. @"large s painting",
  240. @"larg l painting",
  241. @"larg p painting",
  242. @"med s painting",
  243. @"med l painting",
  244. @"med s painting",
  245. @"small s painting",
  246. @"small l painting",
  247. @"small p painting",
  248. @"easel",
  249. @"stone column",
  250. @"limestone column",
  251. @"marble column",
  252. @"sandstone column",
  253. @"red marble column",
  254. @"lapis lazuli column",
  255. @"basalt column",
  256. @"stone stairs",
  257. @"limestone stairs",
  258. @"marble stairs",
  259. @"sandstone stairs",
  260. @"red merble stairs",
  261. @"lapis lazuli stairs",
  262. @"basalt stairs",
  263. @"copper column",
  264. @"tin column",
  265. @"bronze column",
  266. @"iron column",
  267. @"steel column",
  268. @"gold column",
  269. @"wood column",
  270. @"brick column",
  271. @"ice column",
  272. @"copper stairs",
  273. @"tin stairs",
  274. @"bronze stairs",
  275. @"iron stairs",
  276. @"steel stairs",
  277. @"gold stairs",
  278. @"wood stairs",
  279. @"brick stairs",
  280. @"ice stairs",
  281. @"steel downlight",
  282. @"poison",
  283. @"unknown - arrow",
  284. @"gold bow & arrow",
  285. @"steel uplight",
  286. @"world credit",
  287. @"Platinum Coins",
  288. @"platinum nugget",
  289. @"platinum ingot",
  290. @"platinum stairs",
  291. @"platinum column",
  292. @"glass stairs",
  293. @"glass column",
  294. @"black glass stairs",
  295. @"black glass column",
  296. @"Fuel",
  297. @"refinery",
  298. @"epoxy",
  299. @"raw resin",
  300. @"carbon fibers",
  301. @"carbonf sheet",
  302. @"carbonf wing",
  303. @"jetpack chassis",
  304. @"jet engine",
  305. @"JETPACK",
  306. @"titanium ore",
  307. @"titanium ingot",
  308. @"titanium stairs",
  309. @"titanium column",
  310. @"carbonf stairs",
  311. @"carbonf column",
  312. @"titanium pickaxes",
  313. @"titanium sword",
  314. @"titanium leggings",
  315. @"titanium chest",
  316. @"titanium helmet",
  317. @"titanium boots",
  318. @"carbonf leggings",
  319. @"carbonf chest",
  320. @"carbonf helmet",
  321. @"carbonf boots",
  322. @"vine",
  323. @"tulip bulb",
  324. @"tulip seed",
  325. @"unknown - coins",
  326. @"random ore",
  327. @"electric sluice",
  328. @"ownership signs",
  329. @"Made by Gh0stByte"];
  330. UIViewController *mainViewController;
  331. UIButton *enableMenu;
  332. UIView *view2;
  333. UIView *selectionView;
  334. UIStepper* stepper;
  335. UIButton *button2;
  336. UIButton *button3;
  337. UIButton *button4;
  338. UISwitch *mySwitch;
  339. UITapGestureRecognizer *tapImageRecognizer;
  340. UIScrollView *scrollview;
  341. UILabel * label;
  342. UILabel *label2;
  343. bool ini = false;
  344. bool show = false;
  345. @interface EvolutionAppDelegate : NSObject <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UISearchDisplayDelegate>
  346. @end
  347. int sx = GetPrefInt(@"kX");
  348. int sy = GetPrefInt(@"kY");
  349. #define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/BlockheadsInventory.bundle"
  350. NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
  351. NSString *someImage = [bundle pathForResource:@"Background" ofType:@"png"];
  352. bool isServer = false;
  353. //Switches
  354. UISwitch *crystalSwitch;
  355. UISwitch *coinSwitch;
  356. UISwitch *speedSwitch;
  357. UISwitch *doubleSwitch;
  358. UISwitch *sleepSwitch;
  359. UISwitch *meditateSwitch;
  360. UISwitch *viewSwitch;
  361. UISwitch *solarSwitch;
  362. UISwitch *teleportSwitch;
  363. UISwitch *hdSwitch;
  364. UISwitch *levelSwitch;
  365. UISwitch *immortalSwitch;
  366. UISwitch *jetpackSwitch;
  367. UITableView *tableView;
  368. UISearchBar *searchBar;
  369. UISearchDisplayController *searchDC;
  370. NSString *version = @"1.6.2";
  371. NSString *currentVersion;
  372. NSString *features = [NSString stringWithContentsOfURL:
  373. [NSURL URLWithString:@"http://idroidcheats.net/iOS/blockheadsChangelog"]
  374. encoding:NSUTF8StringEncoding error:nil];
  375. %hook EvolutionAppDelegate
  376. -(void)applicationDidBecomeActive:(id)arg1
  377. {
  378. NSString *config = [NSString stringWithContentsOfURL:
  379. [NSURL URLWithString:@"http://idroidcheats.net/iOS/blockheads.txt"]
  380. encoding:NSUTF8StringEncoding error:nil];
  381. for (NSString *line in [config componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]])
  382. {
  383. if([line rangeOfString:@"currentVersion="].location != NSNotFound)
  384. {
  385. currentVersion = [line stringByReplacingOccurrencesOfString:@"currentVersion=" withString:@""];
  386. }
  387. }
  388. if(![currentVersion isEqualToString:version])
  389. {
  390. NSString *message2 = [NSString stringWithFormat:@"There is a new update available!\n\nChangelog:\n%@",features];
  391. UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Update Available" message:message2 delegate: self cancelButtonTitle:@"OK" otherButtonTitles:@"Update", nil]; [a show]; [a release];
  392. }
  393. %orig;
  394. if(!ini && GetPrefBool(@"kBOn"))
  395. {
  396. mainViewController = MSHookIvar<UIViewController *>(self, "_viewController");
  397. view2 = [[[UIView alloc] initWithFrame:CGRectMake(/*50, 50, 200, 150*/sx, sy, 0, 0)] autorelease];
  398. //[view2 setBackgroundColor:[UIColor blackColor]];
  399. //[view2 setBackgroundColor:[UIColor colorWithPatternImage:];
  400. [mainViewController.view addSubview:view2];
  401. view2.layer.cornerRadius = 5;
  402. view2.layer.masksToBounds = YES;
  403. [view2 setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[[NSBundle alloc] initWithPath:kBundlePath] pathForResource:@"Img" ofType:@"png"]]]];
  404. selectionView = [[[UIView alloc] initWithFrame:CGRectMake(/*50, 50, 200, 150*/sx, sy, 0, 0)] autorelease];
  405. [selectionView setBackgroundColor:[UIColor blackColor]];
  406. [mainViewController.view addSubview:selectionView];
  407. selectionView.layer.cornerRadius = 5;
  408. selectionView.layer.masksToBounds = YES;
  409. scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 2, 164, 191-32)];
  410. scrollview.showsVerticalScrollIndicator=YES;
  411. scrollview.scrollEnabled=YES;
  412. scrollview.userInteractionEnabled=YES;
  413. scrollview.backgroundColor = [UIColor clearColor];
  414. [scrollview setContentSize:CGSizeMake(scrollview.bounds.size.width,490)];
  415. [view2 addSubview:scrollview];
  416. tableView = [[[UITableView alloc] initWithFrame:CGRectMake(0, 0+30,250,360) style:UITableViewStyleGrouped] autorelease];
  417. tableView.dataSource = self;
  418. tableView.delegate = self;
  419. [selectionView addSubview:tableView];
  420. if(GetPrefBool(@"kSearch"))
  421. {
  422. searchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)] autorelease];
  423. searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
  424. searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
  425. searchBar.keyboardType = UIKeyboardTypeAlphabet;
  426. searchBar.delegate = self;
  427. tableView.tableHeaderView = searchBar;
  428. // Create the search display controller
  429. searchDC = [[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:mainViewController] autorelease];
  430. searchDC.searchResultsDataSource = self;
  431. searchDC.searchResultsDelegate = self;
  432. }
  433. tapImageRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissPopUp)];
  434. [mainViewController.view addGestureRecognizer:tapImageRecognizer];
  435. tapImageRecognizer.enabled = NO;
  436. mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 10, 0, 0)];
  437. [mySwitch addTarget:self action:@selector(changeState) forControlEvents:UIControlEventValueChanged];
  438. [scrollview addSubview:mySwitch];
  439. label = [[UILabel alloc] initWithFrame:CGRectMake(75, 15, 100, 20)];
  440. label.backgroundColor = [UIColor clearColor];
  441. label.textAlignment = UITextAlignmentCenter; // UITextAlignmentCenter, UITextAlignmentLeft
  442. label.textColor=[UIColor whiteColor];
  443. label.text = @"Inventory";
  444. [scrollview addSubview:label];
  445. crystalSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 90, 0, 0)];
  446. [crystalSwitch addTarget:self action:@selector(enableCrystal) forControlEvents:UIControlEventValueChanged];
  447. [scrollview addSubview:crystalSwitch];
  448. UILabel *crystallabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 95, 100, 20)];
  449. crystallabel.backgroundColor = [UIColor clearColor];
  450. crystallabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  451. crystallabel.textColor=[UIColor whiteColor];
  452. crystallabel.text = @"Crystals";
  453. [scrollview addSubview:crystallabel];
  454. coinSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 120, 0, 0)];
  455. [coinSwitch addTarget:self action:@selector(enableCoins) forControlEvents:UIControlEventValueChanged];
  456. [scrollview addSubview:coinSwitch];
  457. UILabel *coinlabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 125, 100, 20)];
  458. coinlabel.backgroundColor = [UIColor clearColor];
  459. coinlabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  460. coinlabel.textColor=[UIColor whiteColor];
  461. coinlabel.text = @"Coins";
  462. [scrollview addSubview:coinlabel];
  463. speedSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 150, 0, 0)];
  464. [speedSwitch addTarget:self action:@selector(enableSpeed) forControlEvents:UIControlEventValueChanged];
  465. [scrollview addSubview:speedSwitch];
  466. UILabel *speedlabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 155, 100, 20)];
  467. speedlabel.backgroundColor = [UIColor clearColor];
  468. speedlabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  469. speedlabel.textColor=[UIColor whiteColor];
  470. speedlabel.text = @"Speed";
  471. [scrollview addSubview:speedlabel];
  472. doubleSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 180, 0, 0)];
  473. [doubleSwitch addTarget:self action:@selector(enableDouble) forControlEvents:UIControlEventValueChanged];
  474. [scrollview addSubview:doubleSwitch];
  475. UILabel *doublelabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 185, 100, 20)];
  476. doublelabel.backgroundColor = [UIColor clearColor];
  477. doublelabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  478. doublelabel.textColor=[UIColor whiteColor];
  479. doublelabel.text = @"Double T";
  480. [scrollview addSubview:doublelabel];
  481. sleepSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 210, 0, 0)];
  482. [sleepSwitch addTarget:self action:@selector(enableSleep) forControlEvents:UIControlEventValueChanged];
  483. [scrollview addSubview:sleepSwitch];
  484. UILabel *sleeplabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 215, 100, 20)];
  485. sleeplabel.backgroundColor = [UIColor clearColor];
  486. sleeplabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  487. sleeplabel.textColor=[UIColor whiteColor];
  488. sleeplabel.text = @"CanSleep";
  489. [scrollview addSubview:sleeplabel];
  490. meditateSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 240, 0, 0)];
  491. [meditateSwitch addTarget:self action:@selector(enableMeditate) forControlEvents:UIControlEventValueChanged];
  492. [scrollview addSubview:meditateSwitch];
  493. UILabel *meditatelabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 245, 100, 20)];
  494. meditatelabel.backgroundColor = [UIColor clearColor];
  495. meditatelabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  496. meditatelabel.textColor=[UIColor whiteColor];
  497. meditatelabel.text = @"Meditate";
  498. [scrollview addSubview:meditatelabel];
  499. viewSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 270, 0, 0)];
  500. [viewSwitch addTarget:self action:@selector(enableView) forControlEvents:UIControlEventValueChanged];
  501. [scrollview addSubview:viewSwitch];
  502. UILabel *viewlabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 275, 100, 20)];
  503. viewlabel.backgroundColor = [UIColor clearColor];
  504. viewlabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  505. viewlabel.textColor=[UIColor whiteColor];
  506. viewlabel.text = @"ViewHak";
  507. [scrollview addSubview:viewlabel];
  508. solarSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 300, 0, 0)];
  509. [solarSwitch addTarget:self action:@selector(enableSolar) forControlEvents:UIControlEventValueChanged];
  510. [scrollview addSubview:solarSwitch];
  511. UILabel *solarlabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 305, 100, 20)];
  512. solarlabel.backgroundColor = [UIColor clearColor];
  513. solarlabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  514. solarlabel.textColor=[UIColor whiteColor];
  515. solarlabel.text = @"Solar Hak";
  516. [scrollview addSubview:solarlabel];
  517. teleportSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 330, 0, 0)];
  518. [teleportSwitch addTarget:self action:@selector(enableTeleport) forControlEvents:UIControlEventValueChanged];
  519. [scrollview addSubview:teleportSwitch];
  520. UILabel *teleportlabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 335, 100, 20)];
  521. teleportlabel.backgroundColor = [UIColor clearColor];
  522. teleportlabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  523. teleportlabel.textColor=[UIColor whiteColor];
  524. teleportlabel.text = @"Teleport";
  525. [scrollview addSubview:teleportlabel];
  526. hdSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 360, 0, 0)];
  527. [hdSwitch addTarget:self action:@selector(enableHD) forControlEvents:UIControlEventValueChanged];
  528. [scrollview addSubview:hdSwitch];
  529. UILabel *hdlabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 365, 100, 20)];
  530. hdlabel.backgroundColor = [UIColor clearColor];
  531. hdlabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  532. hdlabel.textColor=[UIColor whiteColor];
  533. hdlabel.text = @"Textures";
  534. [scrollview addSubview:hdlabel];
  535. levelSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 390, 0, 0)];
  536. [levelSwitch addTarget:self action:@selector(enableLevel) forControlEvents:UIControlEventValueChanged];
  537. [scrollview addSubview:levelSwitch];
  538. UILabel *levellabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 395, 100, 20)];
  539. levellabel.backgroundColor = [UIColor clearColor];
  540. levellabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  541. levellabel.textColor=[UIColor whiteColor];
  542. levellabel.text = @"LevelHak";
  543. [scrollview addSubview:levellabel];
  544. immortalSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 420, 0, 0)];
  545. [immortalSwitch addTarget:self action:@selector(enableImmortal) forControlEvents:UIControlEventValueChanged];
  546. [scrollview addSubview:immortalSwitch];
  547. UILabel *immortallabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 425, 100, 20)];
  548. immortallabel.backgroundColor = [UIColor clearColor];
  549. immortallabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  550. immortallabel.textColor=[UIColor whiteColor];
  551. immortallabel.text = @"Immortal";
  552. [scrollview addSubview:immortallabel];
  553. jetpackSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 450, 0, 0)];
  554. [jetpackSwitch addTarget:self action:@selector(enableJetpack) forControlEvents:UIControlEventValueChanged];
  555. [scrollview addSubview:jetpackSwitch];
  556. UILabel *jetpacklabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 455, 100, 20)];
  557. jetpacklabel.backgroundColor = [UIColor clearColor];
  558. jetpacklabel.textAlignment = UITextAlignmentLeft; // UITextAlignmentCenter, UITextAlignmentLeft
  559. jetpacklabel.textColor=[UIColor whiteColor];
  560. jetpacklabel.text = @"Jet Fuel";
  561. [scrollview addSubview:jetpacklabel];
  562. label2 = [[UILabel alloc] initWithFrame:CGRectMake(30, 110, 80, 20)];
  563. label2.backgroundColor = [UIColor clearColor];
  564. label2.textAlignment = UITextAlignmentCenter; // UITextAlignmentCenter, UITextAlignmentLeft
  565. label2.textColor=[UIColor whiteColor];
  566. NSString *nsd = [NSString stringWithFormat:@"id: %d", GetPrefInt(@"kItems")];
  567. label2.text = nsd;
  568. enableMenu = [UIButton buttonWithType:UIButtonTypeCustom];
  569. [enableMenu setFrame: CGRectMake(sx, sy, 40, 40)];
  570. [enableMenu addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchUpInside];
  571. [mainViewController.view addSubview:enableMenu];
  572. UIImage *newButtonImage = [UIImage imageWithContentsOfFile:[[[NSBundle alloc] initWithPath:kBundlePath] pathForResource:@"Button22" ofType:@"png"]];
  573. //Create image object from bundle. Name must include filetype; is case sensetive.
  574. [enableMenu setImage:newButtonImage forState:UIControlStateNormal];
  575. [enableMenu setTitle:@"M" forState:UIControlStateNormal];
  576. button2 = [UIButton buttonWithType:UIButtonTypeSystem];
  577. [button2 setFrame: CGRectMake(sx, sy+80, 50, 30)];
  578. [button2 addTarget:self action:@selector(changeDown) forControlEvents:UIControlEventTouchUpInside];
  579. //[view2 addSubview:button2];
  580. [button2 setTitle:@"-" forState:UIControlStateNormal];
  581. button3 = [UIButton buttonWithType:UIButtonTypeSystem];
  582. [button3 setFrame: CGRectMake(sx + 50, sy+80, 50, 30)];
  583. [button3 addTarget:self action:@selector(changeUp) forControlEvents:UIControlEventTouchUpInside];
  584. //[view2 addSubview:button3];
  585. [button3 setTitle:@"+" forState:UIControlStateNormal];
  586. button4 = [UIButton buttonWithType:UIButtonTypeSystem];
  587. [button4 setFrame: CGRectMake(10, 50, 100, 30)];
  588. [button4 addTarget:self action:@selector(showSelection) forControlEvents:UIControlEventTouchUpInside];
  589. [scrollview addSubview:button4];
  590. [button4 setTitle:@"Select Item" forState:UIControlStateNormal];
  591. UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, 100, 20)];
  592. label3.backgroundColor = [UIColor clearColor];
  593. label3.textAlignment = UITextAlignmentCenter; // UITextAlignmentCenter, UITextAlignmentLeft
  594. label3.textColor=[UIColor whiteColor];
  595. label3.text = @"Select Item";
  596. [selectionView addSubview:label3];
  597. ini = true;
  598. }
  599. if(GetPrefBool(@"kOn"))
  600. {
  601. [mySwitch setOn:YES animated:NO];
  602. }
  603. else{
  604. [mySwitch setOn:NO animated:NO];
  605. }
  606. if(GetPrefBool(@"kCrystalsBool"))
  607. {
  608. [crystalSwitch setOn:YES animated:NO];
  609. }
  610. else{
  611. [crystalSwitch setOn:NO animated:NO];
  612. }
  613. if(GetPrefBool(@"kCoins"))
  614. {
  615. [coinSwitch setOn:YES animated:NO];
  616. }
  617. else{
  618. [coinSwitch setOn:NO animated:NO];
  619. }
  620. if(GetPrefBool(@"kSpeed"))
  621. {
  622. [speedSwitch setOn:YES animated:NO];
  623. }
  624. else{
  625. [speedSwitch setOn:NO animated:NO];
  626. }
  627. if(GetPrefBool(@"kDoubleTime"))
  628. {
  629. [doubleSwitch setOn:YES animated:NO];
  630. }
  631. else{
  632. [doubleSwitch setOn:NO animated:NO];
  633. }
  634. if(GetPrefBool(@"kSleep"))
  635. {
  636. [sleepSwitch setOn:YES animated:NO];
  637. }
  638. else{
  639. [sleepSwitch setOn:NO animated:NO];
  640. }
  641. if(GetPrefBool(@"kMeditate"))
  642. {
  643. [meditateSwitch setOn:YES animated:NO];
  644. }
  645. else{
  646. [meditateSwitch setOn:NO animated:NO];
  647. }
  648. if(GetPrefBool(@"kView"))
  649. {
  650. [viewSwitch setOn:YES animated:NO];
  651. }
  652. else{
  653. [viewSwitch setOn:NO animated:NO];
  654. }
  655. if(GetPrefBool(@"kSolar"))
  656. {
  657. [solarSwitch setOn:YES animated:NO];
  658. }
  659. else{
  660. [solarSwitch setOn:NO animated:NO];
  661. }
  662. if(GetPrefBool(@"kTeleport"))
  663. {
  664. [teleportSwitch setOn:YES animated:NO];
  665. }
  666. else{
  667. [teleportSwitch setOn:NO animated:NO];
  668. }
  669. if(GetPrefBool(@"kHD"))
  670. {
  671. [hdSwitch setOn:YES animated:NO];
  672. }
  673. else{
  674. [hdSwitch setOn:NO animated:NO];
  675. }
  676. if(GetPrefBool(@"kCraftItems"))
  677. {
  678. [levelSwitch setOn:YES animated:NO];
  679. }
  680. else{
  681. [levelSwitch setOn:NO animated:NO];
  682. }
  683. if(GetPrefBool(@"kDie"))
  684. {
  685. [immortalSwitch setOn:YES animated:NO];
  686. }
  687. else{
  688. [immortalSwitch setOn:NO animated:NO];
  689. }
  690. if(GetPrefBool(@"kJetpack"))
  691. {
  692. [jetpackSwitch setOn:YES animated:NO];
  693. }
  694. else{
  695. [jetpackSwitch setOn:NO animated:NO];
  696. }
  697. if(isServer)
  698. {
  699. [mySwitch setOn:NO animated:YES];
  700. }
  701. }
  702. bool en = false;
  703. bool sh = false;
  704. %new
  705. -(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
  706. {
  707. [tableView reloadData];
  708. }
  709. %new
  710. -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  711. {
  712. //searchTextForSearch = searchText;
  713. for(int i=0; i<itemNames.count; i++)
  714. {
  715. //[[itemNames[i]lowercaseString] rangeOfString:[searchText lowercaseString]].location != NSNotFound
  716. //if([[searchText lowercaseString] isEqualToString:[itemNames[i]lowercaseString]])
  717. if([[itemNames[i]lowercaseString] rangeOfString:[searchText lowercaseString]].location != NSNotFound)
  718. {
  719. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
  720. [tableView scrollToRowAtIndexPath:indexPath
  721. atScrollPosition:UITableViewScrollPositionTop
  722. animated:YES];
  723. }
  724. }
  725. }
  726. %new
  727. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
  728. {
  729. [searchBar resignFirstResponder];
  730. }
  731. %new
  732. - (void) fetchObjects
  733. {
  734. }
  735. %new
  736. -(void)enableJetpack
  737. {
  738. if(GetPrefBool(@"kJetpack"))
  739. {
  740. SetPrefBool(@"kJetpack", false);
  741. }
  742. else{
  743. SetPrefBool(@"kJetpack", true);
  744. }
  745. }
  746. %new
  747. -(void)enableImmortal
  748. {
  749. if(GetPrefBool(@"kDie"))
  750. {
  751. SetPrefBool(@"kDie", false);
  752. }
  753. else{
  754. SetPrefBool(@"kDie", true);
  755. }
  756. }
  757. %new
  758. -(void)enableLevel
  759. {
  760. if(GetPrefBool(@"kCraftItems"))
  761. {
  762. SetPrefBool(@"kCraftItems", false);
  763. }
  764. else{
  765. SetPrefBool(@"kCraftItems", true);
  766. }
  767. }
  768. %new
  769. -(void)enableHD
  770. {
  771. if(GetPrefBool(@"kHD"))
  772. {
  773. SetPrefBool(@"kHD", false);
  774. }
  775. else{
  776. SetPrefBool(@"kHD", true);
  777. }
  778. }
  779. %new
  780. -(void)enableTeleport
  781. {
  782. if(GetPrefBool(@"kTeleport"))
  783. {
  784. SetPrefBool(@"kTeleport", false);
  785. }
  786. else{
  787. SetPrefBool(@"kTeleport", true);
  788. }
  789. }
  790. %new
  791. -(void)enableSolar
  792. {
  793. if(GetPrefBool(@"kSolar"))
  794. {
  795. SetPrefBool(@"kSolar", false);
  796. }
  797. else{
  798. SetPrefBool(@"kSolar", true);
  799. }
  800. }
  801. %new
  802. -(void)enableView
  803. {
  804. if(GetPrefBool(@"kView"))
  805. {
  806. SetPrefBool(@"kView", false);
  807. }
  808. else{
  809. SetPrefBool(@"kView", true);
  810. }
  811. }
  812. %new
  813. -(void)enableMeditate
  814. {
  815. if(GetPrefBool(@"kMeditate"))
  816. {
  817. SetPrefBool(@"kMeditate", false);
  818. }
  819. else{
  820. SetPrefBool(@"kMeditate", true);
  821. }
  822. }
  823. %new
  824. -(void)enableSleep
  825. {
  826. if(GetPrefBool(@"kSleep"))
  827. {
  828. SetPrefBool(@"kSleep", false);
  829. }
  830. else{
  831. SetPrefBool(@"kSleep", true);
  832. }
  833. }
  834. %new
  835. -(void)enableDouble
  836. {
  837. if(GetPrefBool(@"kDoubleTime"))
  838. {
  839. SetPrefBool(@"kDoubleTime", false);
  840. }
  841. else{
  842. SetPrefBool(@"kDoubleTime", true);
  843. }
  844. }
  845. %new
  846. -(void)enableSpeed
  847. {
  848. if(GetPrefBool(@"kSpeed"))
  849. {
  850. SetPrefBool(@"kSpeed", false);
  851. }
  852. else{
  853. SetPrefBool(@"kSpeed", true);
  854. }
  855. }
  856. %new
  857. -(void)enableCrystal
  858. {
  859. if(GetPrefBool(@"kCrystalsBool"))
  860. {
  861. SetPrefBool(@"kCrystalsBool", false);
  862. }
  863. else{
  864. SetPrefBool(@"kCrystalsBool", true);
  865. }
  866. }
  867. %new
  868. -(void)enableCoins
  869. {
  870. if(GetPrefBool(@"kCoins"))
  871. {
  872. SetPrefBool(@"kCoins", false);
  873. }
  874. else{
  875. SetPrefBool(@"kCoins", true);
  876. }
  877. }
  878. %new
  879. - (void)alertView: (UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex
  880. {
  881. if([alertView.title isEqualToString:@"Update Available"])
  882. {
  883. if([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"Update"])
  884. {
  885. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://ioscheaters.com/topic/8150-"]];
  886. }
  887. }
  888. }
  889. %new
  890. -(void)showSelection{
  891. if(!en)
  892. {
  893. selectionView.frame = CGRectMake(sx-3, sy+40, 250, 360);
  894. tapImageRecognizer.enabled = YES;
  895. [tapImageRecognizer setCancelsTouchesInView:NO];
  896. en = true;
  897. }
  898. }
  899. %new
  900. -(void)showMenu{
  901. if(!sh)
  902. {
  903. view2.frame = CGRectMake(sx-3, sy+40, 164, 191);
  904. tapImageRecognizer.enabled = YES;
  905. sh = true;
  906. }
  907. else
  908. {
  909. if(sh && en)
  910. {
  911. selectionView.frame = CGRectMake(sx, sy+30, 0, 0);
  912. view2.frame = CGRectMake(sx, sy+25, 0, 0);
  913. tapImageRecognizer.enabled = NO;
  914. sh = false;
  915. en = false;
  916. }
  917. if(sh)
  918. {
  919. view2.frame = CGRectMake(sx, sy+25, 0, 0);
  920. tapImageRecognizer.enabled = NO;
  921. sh = false;
  922. }
  923. }
  924. }
  925. %new
  926. -(void)dismissPopUp{
  927. if(en && sh)
  928. {
  929. //selectionView.frame = CGRectMake(0, 30, 0, 0);
  930. //tapImageRecognizer.enabled = NO;
  931. en = false;
  932. sh = false;
  933. }
  934. //if only the button is showing
  935. if(en)
  936. {
  937. view2.frame = CGRectMake(sx, sy+15, 0, 0);
  938. en = false;
  939. }
  940. if(sh)
  941. {
  942. selectionView.frame = CGRectMake(0, 30, 0, 0);
  943. //[searchBar resignFirstResponder];
  944. en = false;
  945. }
  946. }
  947. %new
  948. -(void)changeUp
  949. {
  950. NSNumber *obj = [NSNumber numberWithInt:GetPrefInt(@"kItems") + 1];
  951. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist"];
  952. [dict setObject:obj forKey:@"kItems"];
  953. [dict writeToFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist" atomically:YES];
  954. NSString *nsd = [NSString stringWithFormat:@"id: %d", GetPrefInt(@"kItems")];
  955. label2.text = nsd;
  956. }
  957. %new
  958. -(void)changeDown
  959. {
  960. NSNumber *obj = [NSNumber numberWithInt:GetPrefInt(@"kItems") - 1];
  961. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist"];
  962. [dict setObject:obj forKey:@"kItems"];
  963. [dict writeToFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist" atomically:YES];
  964. NSString *nsd = [NSString stringWithFormat:@"id: %d", GetPrefInt(@"kItems")];
  965. label2.text = nsd;
  966. }
  967. %new
  968. -(void)changeState
  969. {
  970. if(isServer)
  971. {
  972. UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Server" message:@"Hack not allowed for use on servers. Donate to get server version." delegate: nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [a show]; [a release];
  973. [mySwitch setOn:NO animated:YES];
  974. }
  975. else
  976. {
  977. if(GetPrefBool(@"kOn"))
  978. {
  979. NSNumber *obj = [NSNumber numberWithBool:NO];
  980. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist"];
  981. [dict setObject:obj forKey:@"kOn"];
  982. [dict writeToFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist" atomically:YES];
  983. }
  984. else
  985. {
  986. NSNumber *obj = [NSNumber numberWithBool:YES];
  987. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist"];
  988. [dict setObject:obj forKey:@"kOn"];
  989. [dict writeToFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist" atomically:YES];
  990. }
  991. }
  992. }
  993. int selectedIndex;
  994. %new
  995. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  996. // Return the number of sections.
  997. return 1;
  998. }
  999. %new
  1000. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  1001. // Return the number of rows in the section.
  1002. // If you're serving data from an array, return the length of the array:
  1003. return [itemNames count];
  1004. //return 10;
  1005. }
  1006. %new
  1007. -(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
  1008. {
  1009. // [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
  1010. //NSIndexPath *oldIndex = [tableView indexPathForSelectedRow];
  1011. //[tableView cellForRowAtIndexPath:oldIndex].accessoryType = UITableViewCellAccessoryNone;
  1012. //[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
  1013. return indexPath;
  1014. }
  1015. UITableViewCell *cell;
  1016. %new
  1017. // Customize the appearance of table view cells.
  1018. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  1019. static NSString *CellIdentifier = @"Cell";
  1020. cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  1021. if (cell == nil) {
  1022. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  1023. }
  1024. if(indexPath.row == selectedIndex)
  1025. {
  1026. cell.accessoryType = UITableViewCellAccessoryCheckmark;
  1027. }
  1028. else
  1029. {
  1030. cell.accessoryType = UITableViewCellAccessoryNone;
  1031. }
  1032. // Set the data for this cell:
  1033. cell.textLabel.text = [itemNames objectAtIndex:indexPath.row];
  1034. //cell.detailTextLabel.text = @"More text";
  1035. //cell.imageView.image = [UIImage imageNamed:@"flower.png"];
  1036. return cell;
  1037. }
  1038. %new
  1039. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  1040. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  1041. selectedIndex = indexPath.row;
  1042. [tableView reloadData];
  1043. int selectedRow = indexPath.row;
  1044. NSNumber *obj = [NSNumber numberWithInt:selectedRow+1];
  1045. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist"];
  1046. [dict setObject:obj forKey:@"kItems"];
  1047. [dict writeToFile:@"/var/mobile/Library/Preferences/BlockheadsInventory.plist" atomically:YES];
  1048. //tableView cellForRowAtIndexPath:indexPath.accessoryType = UITableViewCellAccessoryCheckmark;
  1049. // [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
  1050. }
  1051. %end
  1052. %hook HackExample
  1053. -(int)coins
  1054. {
  1055. if(GetPrefBool(@"kCoins"))
  1056. {
  1057. return 2147483647;
  1058. }
  1059. return %orig;
  1060. }
  1061. %end
  1062. //Hack Methods were all down here