-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.xm
383 lines (338 loc) · 9.97 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
//####################################################
//# MCPE Mod 0.10.0 (For Minecraft PE 0.10.0 IOS) #
//# #
//# Created by HenryQuan #
//# 11/11/2014 #
//####################################################
// # # # # ###### # # # # ###
// # # # # # # # # # # ######
// # # # # ###### ########### ##### ######## # #
// # # # ####### # # # # ## # # # # #
// ### ## ###### ########### # # # # # #
//############## # # # # # # # # # ########## ##########
// # # # # # # # # # # # # # # # # # #
// # # # # # # # ### # # # # # # #
// # # # ####### # # # # # # #
// # # # # # # # # # # #
// # #### # ## ### # # # # ##
#import <Foundation/Foundation.h>
#import <substrate.h>
#define PLIST_PATH @"/var/mobile/Library/Preferences/HenryQuan.MCPEMod.plist"
#define KEEP_ALL_STAFFS "__ZN6Player3dieEP6Entity"
#define SNEAKING "__ZN11LocalPlayer10isSneakingEv"
#define NO_FALL_DAMAGE "__ZN11LocalPlayer15causeFallDamageEf"
#define CAN_HURT_PLAYER "__ZN6Player4hurtEP6Entityi"
#define PLAYER_WALKING_SPEED "__ZN6Player23getWalkingSpeedModifierEv"
#define IS_IN_WALL "__ZN6Player8isInWallEv"
#define ARMOR_VALUE "__ZN6Player13getArmorValueEv"
#define INSTANT_DESTROY_PICKAXE "__ZN11PickaxeItem15getDestroySpeedEP12ItemInstanceP4Tile"
#define INSTANT_DESTROY_ITEM "__ZN4Item15getDestroySpeedEP12ItemInstanceP4Tile"
#define INSTANT_DESTROY_AXE "__ZN11HatchetItem15getDestroySpeedEP12ItemInstanceP4Tile"
#define INSTANT_DESTROY_DIGGER "__ZN10DiggerItem15getDestroySpeedEP12ItemInstanceP4Tile"
#define INSTANT_KILL "__ZN3Mob25getDamageAfterArmorAbsorbEi"
#define INFINITY_OXYGEN "__ZNK6Entity13isUnderLiquidEPK8Material"
#define IS_IN_WATER "__ZNK6Entity9isInWaterEv"
#define IS_IN_LAVA "__ZN6Entity8isInLavaEv"
#define STUCK_IN_WEB "__ZN6Entity14makeStuckInWebEv"
#define BIGGER_INVENTORY "__ZNK9Inventory16getContainerSizeEv"
// Crushes when launching the app (version 0.10.0)
// #define MAX_STACK_SIZE "__ZN4Item15setMaxStackSizeEi"
#define MOB_GET_TARGET "__ZN3Mob9getTargetEv"
#define MOB_FIND_TARGET "__ZN7Monster16findAttackTargetEv"
#define NO_EXPLOSION "__ZN5Level7explodeEP6Entityffffb"
#define DIRT_TO_STH "__ZN4Tile11getResourceEiP6Random"
#define GET_DROP_COUNT "__ZN9Inventory3addEP12ItemInstance"
// Prevent repetitive code
inline bool GetBool(NSString *key)
{
return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] boolValue];
}
// Prevent repetitive code (same as above)
inline int GetInt(NSString *key)
{
return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] intValue];
}
void keepAllStaffs()
{
// Should not remove all the items
}
float noFallDamage()
{
return 0.f;
}
BOOL isSneaking()
{
return true;
}
BOOL isNotSneaking()
{
return false;
}
float sneakingSpeed()
{
return 0.55f;
}
float normalSpeed()
{
return 1.f;
}
float sprintSpeed()
{
return 2.5f;
}
void canNotHurtPlayer()
{
}
BOOL isNotInWall()
{
return false;
}
int GetArmorValue()
{
int result;
int armor = GetInt(@"customArmor");
// Use array here instead of 7 ifs
if (armor == 1)
{
result = 0;
}
if (armor == 2)
{
result = 7;
}
if (armor == 3)
{
result = 12;
}
if (armor == 4)
{
result = 15;
}
if (armor == 5)
{
result = 11;
}
if (armor == 6)
{
result = 20;
}
if (armor == 7)
{
result = 999;
}
return result;
}
float instantDestroy()
{
// only use once so ...
return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:@"customDigSpeed"] floatValue];
}
int instantKill()
{
// 50 is a big enough value to kill most of the mobs (enderman's HP is about 45 but below 50)
return 50;
}
BOOL isNotUnderWater()
{
return false;
}
BOOL isNotInWaterAndLava()
{
return false;
}
BOOL isInWater()
{
return true;
}
BOOL dontStuckInWeb()
{
return false;
}
int biggerInventory()
{
return 88;
}
/*
We don't need to use it now
int MaxStack()
{
return 999;
}
*/
int mobNoTarget()
{
return 0;
}
int mobCanNotFindTarget()
{
return 0;
}
BOOL noExplosion()
{
return false;
}
int customDrop()
{
return GetInt(@"customDrop");
}
int customCount()
{
return GetInt(@"customDropNum");
}
typedef struct
{
void vtable();
int itemId;
} Item;
typedef struct
{
int count;
int damage;
Item item;
} * ItemInstance;
int (*old__ZN9Inventory3addEP12ItemInstance)(void self(), ItemInstance itemi);
int $__ZN9Inventory3addEP12ItemInstance(void self(), ItemInstance itemi)
{
itemi->count = GetInt(@"customDropNum");
return old__ZN9Inventory3addEP12ItemInstance(self, itemi);
}
%ctor
{
// The main control of the MOD
if (GetBool(@"main"))
{
// All the sub-switches
if (GetBool(@"keep"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, KEEP_ALL_STAFFS)), (void *)keepAllStaffs, NULL);
}
if (GetBool(@"noFallDamage"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, NO_FALL_DAMAGE)), (void *)noFallDamage, NULL);
}
if (GetBool(@"inWall"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, IS_IN_WALL)), (void *)isNotInWall, NULL);
}
if (GetBool(@"armor"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, ARMOR_VALUE)), (void *)GetArmorValue, NULL);
}
if (GetBool(@"instantBreak"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, INSTANT_DESTROY_PICKAXE)), (void *)instantDestroy, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, INSTANT_DESTROY_AXE)), (void *)instantDestroy, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, INSTANT_DESTROY_DIGGER)), (void *)instantDestroy, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, INSTANT_DESTROY_ITEM)), (void *)instantDestroy, NULL);
}
if (GetBool(@"instantKill"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, INSTANT_KILL)), (void *)instantKill, NULL);
}
if (GetBool(@"infinityOxygen"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, INFINITY_OXYGEN)), (void *)isNotUnderWater, NULL);
}
if (GetBool(@"walkingInWaterAndLava"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, IS_IN_WATER)), (void *)isNotInWaterAndLava, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, IS_IN_LAVA)), (void *)isNotInWaterAndLava, NULL);
}
if (GetBool(@"noGravity"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, IS_IN_WATER)), (void *)isInWater, NULL);
}
if (GetBool(@"stuckInWeb"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, STUCK_IN_WEB)), (void *)dontStuckInWeb, NULL);
}
// Crushes >_<
// if (GetBool(@"maxStack"))
// {
// MSHookFunction(((void*)MSFindSymbol(NULL, MAX_STACK_SIZE)),(void*)MaxStack,NULL);
// }
if (GetBool(@"biggerInventory"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, BIGGER_INVENTORY)), (void *)biggerInventory, NULL);
}
if (GetBool(@"mobsDontAttack"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, MOB_GET_TARGET)), (void *)mobNoTarget, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, MOB_FIND_TARGET)), (void *)mobCanNotFindTarget, NULL);
}
if (GetBool(@"noExplosion"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, NO_EXPLOSION)), (void *)noExplosion, NULL);
}
if (GetBool(@"dirtToAnything"))
{
MSHookFunction(((void *)MSFindSymbol(NULL, DIRT_TO_STH)), (void *)customDrop, NULL);
}
if (GetBool(@"getDropNumber"))
{
MSHookFunction(((int *)MSFindSymbol(NULL, GET_DROP_COUNT)), (int *)$__ZN9Inventory3addEP12ItemInstance, (int **)&old__ZN9Inventory3addEP12ItemInstance);
}
}
}
@interface minecraftpeViewController : UIViewController
@end
%hook minecraftpeViewController
UIButton *Sneaking;
- (void)viewDidLoad
{
%orig();
// The main control of the MOD
if (GetBool(@"main"))
{
if (GetBool(@"sneaking"))
{
Sneaking = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Sneaking.frame = CGRectMake(0, 90, 40, 25);
[Sneaking setTitle:@"N" forState:UIControlStateNormal];
[Sneaking setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
Sneaking.backgroundColor = [UIColor blackColor];
[Sneaking addTarget:self action:@selector(switchMode) forControlEvents:UIControlEventTouchUpInside];
[[self view] addSubview:Sneaking];
// is better to put a label above the button, it looks nice.
UILabel *walking = [[UILabel alloc] initWithFrame:CGRectMake(0, 70, 55, 25)];
walking.text = @"walk";
[[self view] addSubview:walking];
}
}
}
%new - (void)switchMode
{
if ([Sneaking.currentTitle isEqualToString:@"N"])
{
[Sneaking setTitle:@"S" forState:UIControlStateNormal];
MSHookFunction(((void *)MSFindSymbol(NULL, SNEAKING)), (void *)isSneaking, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, CAN_HURT_PLAYER)), (void *)canNotHurtPlayer, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, NO_FALL_DAMAGE)), (void *)noFallDamage, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, PLAYER_WALKING_SPEED)), (void *)sneakingSpeed, NULL);
}
else if ([Sneaking.currentTitle isEqualToString:@"S"])
{
[Sneaking setTitle:@"V" forState:UIControlStateNormal];
MSHookFunction(((void *)MSFindSymbol(NULL, SNEAKING)), (void *)isNotSneaking, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, CAN_HURT_PLAYER)), (void *)canNotHurtPlayer, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, NO_FALL_DAMAGE)), (void *)noFallDamage, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, PLAYER_WALKING_SPEED)), (void *)sprintSpeed, NULL);
}
else if ([Sneaking.currentTitle isEqualToString:@"V"])
{
[Sneaking setTitle:@"N" forState:UIControlStateNormal];
MSHookFunction(((void *)MSFindSymbol(NULL, SNEAKING)), (void *)isNotSneaking, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, CAN_HURT_PLAYER)), (void *)canNotHurtPlayer, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, NO_FALL_DAMAGE)), (void *)noFallDamage, NULL);
MSHookFunction(((void *)MSFindSymbol(NULL, PLAYER_WALKING_SPEED)), (void *)normalSpeed, NULL);
}
}
%end
// 12/11/2014 9:50pm ^_^
// 19/11/2014 16:16pm >_<
/*
02/10/2020 7:46pm
It has been 6 years, time really flies.
I am back again but this time, I am more powerful than ever before!
HenryQuan
*/