Add a script to extract item data from Bukkit

This commit is contained in:
Trever Fischer
2012-11-09 10:38:57 -05:00
parent e3296b029a
commit be8bb0dc2a
2 changed files with 1844 additions and 0 deletions

30
genitems.py Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python
# Prints out python code from a working Material.java from bukkit.
# https://github.com/Bukkit/Bukkit/raw/master/src/main/java/org/bukkit/Material.java
import re
f = open('Material.java')
dataMatch = re.compile("([A-Z][A-Z0-9_]+)\((.*)\),")
print "ITEMS = ["
for line in f.readlines():
line = line.strip()
matches = dataMatch.search(line)
if matches:
name = matches.group(1)
params = matches.group(2).split(',')
id = int(params.pop(0))
try:
stack = int(params.pop(0))
except:
stack = 64
try:
durability = int(params.pop(0))
except:
durability = 0
print " {"
print " 'name': '%s',"%(name)
print " 'id': %d,"%(id)
print " 'stack': %d,"%(stack)
print " 'durability': %d,"%(durability)
print " },"
print "]"

1814
minecraft/items.py Normal file

File diff suppressed because it is too large Load Diff