Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created December 31, 2012 02:25
Show Gist options
  • Save zhuowei/4416929 to your computer and use it in GitHub Desktop.
Save zhuowei/4416929 to your computer and use it in GitHub Desktop.
Pulls movs r1, # statements from objdump output of Tile::initTiles to find out block ID locations in Minecraft PE
#!/usr/bin/python
#Feed the decompiled Tile::initTiles method from objdump into standard input
from sys import stdin
lastMov = "";
def decodeAndPrint(movstr):
endpart = movstr[movstr.find("#") + 1:len(movstr) - 1]
if endpart.find(";") > -1:
endpart = endpart[0:endpart.find(";") - 1]
print(movstr[0:movstr.find(":")].lstrip() + "," + "{0:X}".format(int(endpart)))
def isAConstructor(mystr):
if mystr.find("bl") < 0 or mystr.find("::") < 0 or mystr.find("Tile") < 0:
return False;
funcname = mystr[mystr.find("<") + 1: mystr.find(">")]
firstPart = funcname[0: funcname.find("::")]
secondPart = funcname[funcname.find("::") + 2: funcname.find("(")]
if firstPart == secondPart:
return True
return False
for line in stdin:
if isAConstructor(line):
decodeAndPrint(lastMov)
elif line.find("mov") > -1 and line.find("r1, #") > -1:
lastMov = line
@shoghicp
Copy link

Added this to https://gist.github.com/shoghicp/4678643/6c872c58936995f72267f85279609fa009fe9fe9#file-extractor-php-L232

Thanks!

PS: A way to get the name would be pretty good ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment