Created
January 13, 2015 18:22
-
-
Save martok/6469ed0abc336a4757ce to your computer and use it in GitHub Desktop.
MCEdit Block/Height filter
This file contains 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
from pymclevel import items | |
def itembyname(name): | |
if name in items.items.items: | |
return items.items.itewms[name]["id"] | |
return 0 | |
def namebyitem(id): | |
item = items.items.findItemID(id) | |
if type(item["name"]) == str or type(item["name"]) == unicode: | |
return item["name"] | |
else: | |
return item["name"][0] | |
def perform(level, box, options): | |
total = {-1 : 0} | |
for name in ["gold_ore", "iron_ore", "coal_ore", "lapis_ore", "diamond_ore", "redstone_ore", "emerald_ore", "clay", "gravel", "dirt", "sand"]: | |
iid = itembyname("minecraft:" + name) | |
total[ iid ] = 0 | |
file = open("counter_output.txt", "w"); | |
line = ["Y"] | |
for iid in total: | |
if iid==-1: | |
line.append("total") | |
else: | |
line.append(namebyitem(iid)) | |
file.write(";".join(line) + "\n"); | |
for y in xrange(0,128): | |
print "Layer " + str(y) | |
for iid in total: | |
total[iid] = 0 | |
for x in xrange(box.minx, box.maxx): | |
for z in xrange(box.minz, box.maxz): | |
block = level.blockAt(x,y,z) | |
if block != 0: | |
total[-1] += 1 | |
if block in total: | |
total[block] += 1 | |
line = [str(y)] | |
for iid in total: | |
line.append(str(total[iid])) | |
file.write(";".join(line) + "\n") | |
file.flush() | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment