Last active
August 29, 2015 14:14
-
-
Save byteandahalf/09521352fc24e09c1f2b to your computer and use it in GitHub Desktop.
Adds a new item to MCPE iOS :D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <substrate.h> | |
#include <mach-o/dyld.h> | |
#include <string> | |
#include <stdbool.h> | |
#include <stddef.h> | |
#include <sstream> | |
#include <iomanip> | |
#include <vector> | |
#include <cstring> | |
#include <memory> | |
using namespace std; | |
class Item { | |
public: | |
void** vt; // 0 | |
int maxStack; // 4 | |
string atlas; // 8 | |
int frames; // 20 | |
bool toolbarAnimates; // 24 | |
int id; // 28 | |
int maxDamage; // 32 | |
char icon[32]; // 36 | |
int creativeTab; // 68 | |
bool equipped; // 72 | |
bool stackData; // 73 | |
Item* craftingRemainingItem; // 76 | |
string name; // 80 | |
}; // size 92 bytes | |
static void (*Item$setDescriptionId)(Item*, string const&); | |
static void (*Item$setIcon)(Item*, string const&, int); | |
static Item** Item$items; | |
void addNewItem(int id, string name, string icon, int iconindex) { | |
Item* myitem = (Item*) ::operator new(sizeof(Item)); | |
myitem->vt = Item$items[318]->vt; | |
myitem->id = id; | |
myitem->atlas = "items-opaque.png"; | |
myitem->maxStack = 64; | |
myitem->frames = 1; | |
myitem->toolbarAnimates = false; | |
myitem->maxDamage = 0; | |
myitem->creativeTab = 4; | |
myitem->stackData = false; | |
Item$setDescriptionId(myitem, name); | |
Item$setIcon(myitem, icon, iconindex); | |
Item$items[id] = myitem; | |
} | |
void initCustomItems() { | |
addNewItem(511, "hopper_item", "hopper", 0); | |
addNewItem(510, "fireworks", "fireworks", 0); | |
addNewItem(509, "rod", "fishing_rod_uncast", 0); | |
addNewItem(508, "cream", "magma_cream", 0); | |
addNewItem(507, "shiny_melon", "melon_speckled", 0); | |
} | |
MSHook(void, Item$initItems) { | |
_Item$initItems(); | |
initCustomItems(); | |
} | |
MSHook(string, I18n$get, string const& key) { | |
if(key == "item.hopper_item.name") return "Hopper"; | |
if(key == "item.fireworks.name") return "Fireworks"; | |
if(key == "item.rod.name") return "Fishing rod"; | |
if(key == "item.cream.name") return "Magma Cream"; | |
if(key == "item.shiny_melon.name") return "Sparkling Melon"; | |
return _I18n$get(key); | |
} | |
MSInitialize { | |
MSHookSymbol(Item$setIcon, "__ZN4Item7setIconERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEi"); | |
MSHookSymbol(Item$setDescriptionId, "__ZN4Item16setDescriptionIdERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE"); | |
#if __ARM_ARCH_7A__ | |
uintptr_t base = 0x2bcb14; | |
uintptr_t aslr_slide = _dyld_get_image_vmaddr_slide(0); | |
Item$items = (__typeof__(Item$items))(base + aslr_slide); | |
#elif __ARM_ARCH_7S__ | |
MSHookSymbol(Item$items, "__MergedGlobals11299"); | |
#elif __aarch64__ | |
MSHookSymbol(Item$items, "__ZN4Item5itemsE"); | |
#endif | |
MSHookFunction("__ZN4Item9initItemsEv", MSHake(Item$initItems)); | |
MSHookFunction("__ZN4I18n3getERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE", MSHake(I18n$get)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment