Tuesday, August 25, 2015

Custom MCPE version name

This time, I will show you how to change the minecraft version name to anything you want.


Custom blocks, custom block shapes & custom crafting recipes

In this tutorial I will show you how to add new blocks to the game.
  1. Adding a new Block
  2. Shaping the Block
  3. Adding a recipe for the Block

1.Adding a new block:

2. Shaping the block

Code reference: Tile::setShape. It takes 6 input parameters: minX, minY, minZ, maxX, maxY, maxZ
Usage: tileInstancePointer->setShape(...)
The minX, minY, minZ parameters are the offset of starting points of the drawn block, and the maxX, maxY and maxZ are the ends.

Some sample shapes:
  • Cube: Tile::setShape(0.25, 0.25, 0.25, 0.75, 0.75, 0.75);
  • Pillar: Tile::setShape(0.25, 0, 0.25, 0.75, 1, 0.75);
  • Enchanting Table: Tile::setShape(0, 0, 0, 1, 0.75, 1);
 

 3. Custom block recipes

Mod project setup on an android device

Let's Start... AND DISASSEMBLE!

First step: what are native mods?

Native mods for BlockLauncher are apps which require a permission from BlockLauncher, so it knows that there are new mods installed on your device. I'll show you how to disassemble the libminecraftpe.so and tell you how it works.

How does this work?

BlockLauncher can load mods to Minecraft PE by replacing Minecraft PE functions with it's own. All objects in Android get an unique address in memory. BlockLauncher replaces the original function with it's own which calls custom functions and then (optionally) the original one. Native mods (addons) for BlockLauncher can do the same thing.

How do i know what functions does Minecraft PE have?

The answer is: disassembly!

Minecraft PE is an android native app - that means it has java code and c/c++ code. In android, jni code (c/c++) is generated into a .so (shared object) file. In an apk file this .so is located in /libs/armeabi-v7a/[name].so. Minecraft PE has it's library named libminecraftpe.so.
To disassemble it you'll need the following:
- A computer with a good cpu (the better the cpu is, the faster the .so is being disassembled),
- IDA (Integrated Disassembly Application),
- An apk of minecraft pe,
- File Explorer (e.g. Windows Explorer).

Last Steps

  1. Change the minecraftpe.apk name to minecraftpe.zip
  2. Open the archive
  3. Navigate to /libs/armeabi-v7a
  4. Copy libminecraftpe.so
  5. Paste it anywhere out of the archive
  6. Open IDA and open the libminecraftpe.so
  7. Change processor type to ARM LITTLE-ENDIAN
  8. Click ok and ok once again in the new window
  9. You'll get an error: Couldn't find signature... it's normal, just click ok
  10. Wait until the file is disassembled
  11. Click ALT+T to open the search window
  12. You can explore all the functions right now

Friday, August 14, 2015

Introduction & Setup

What are native mods?

Native mods (also called addons though they're apps that are addons to blocklauncher) are programs written in C++ and Java for Android. The core mod's code must be written in C++.

How does an addon work?

Addons are programs which are interpreted by Block Launcher, a mod loader for mcpe for android. Block Launcher basically launches mcpe inside it's view, and can override mcpe's methods (via replacing addresses in RAM). E.g. if one mcpe's function is called whenever a block is being rendered and an addon overrides the method, BlockLauncher simply "redirects" the original method to the addon function, which calls it's own methods and (optionally) the original one. An addon must contain the mcpe's library in it's /jni folder in order to override mcpe's code.

Why native mods are better than modpe scripts (which are really easier to be made)?

ModPE has only about 60 functions whereas native mods have access to all mcpe's functions (about 12000).

Looks neat and easy? so no it's the right time to show you the low point of native mods

Now, although there are over 12,000 functions that are in MCPE, not all of them can be modded. There are a few factors that prevent some functions from being modded:

  • Some functions have names that are too short: Substrate actually has, for whatever reason, trouble hooking functions that have short names, though not many have this issue. This can sometimes be worked around by direct vtable replacement.

  • Some functions are weak: Now what exactly this means I don't know, but if a function seen has the word WEAK next to its name, it cannot be normally hooked, though there is a way around this.

  • Some functions have stripped symbols: Some functions that the game uses have stripped symbols. This means that the modders can't identify the function, because its name will simple read sub_xxxxxx. These functions can still be hooked, but it takes a bit of work to identify them.

  • Some functions are inlined: This is the worst whammy of all. Mojang compiles the game with certain flags that will cause alot of functions to be inlined, which means that the function will be deleted completely, and all of its code is added in place of each of its calls. This is a limitation that is impossible to reverse and hard to workaround.

Before you start...

It's the right time for a setup:
I'd prefer to use a PC for modding, but if you want, you can use an android device.

For PCs you will need:
- IDA Evaluation Version (link here)
- Apache Ant, Android Studio or Eclipse (I'd prefer to use Android Studio)
- The android SDK and NDK
- An emulator (or a device for testing)
- MCPE's apk
- Patience

For Android devices:
- AIDE (link here)
- A disassembly of libminecraftpe.so prepared on your pc
- MCPE's apk
- Patience