def print_player(data, sub_entry=False): indent = "" if sub_entry: indent = "\t" print("%sPosition:\t%i, %i, %i\t(dim: %i)" % (indent, data['Pos'][0], data['Pos'][1], data['Pos'][2], data['Dimension'])) try: print("%sSpawn:\t\t%i, %i, %i" % (indent, data['SpawnX'], data['SpawnY'], data['SpawnZ'])) except KeyError: pass print("%sHealth:\t%i\tLevel:\t\t%i\t\tGameType:\t%i" % (indent, data['Health'], data['XpLevel'], data['playerGameType'])) print("%sFood:\t%i\tTotal XP:\t%i" % (indent, data['foodLevel'], data['XpTotal'])) print("%sInventory: %d items" % (indent, len(data['Inventory']))) if not sub_entry: for item in data['Inventory']: print(" %-3d %s" % (item['Count'], items.id2item(item['id'])))
def print_player(data, sub_entry=False): indent = "" if sub_entry: indent = "\t" print "%sPosition:\t%i, %i, %i\t(dim: %i)" % (indent, data['Pos'][0], data['Pos'][1], data['Pos'][2], data['Dimension']) try: print "%sSpawn:\t\t%i, %i, %i" % (indent, data['SpawnX'], data['SpawnY'], data['SpawnZ']) except KeyError: pass print "%sHealth:\t%i\tLevel:\t\t%i\t\tGameType:\t%i" % (indent, data['Health'], data['XpLevel'], data['playerGameType']) print "%sFood:\t%i\tTotal XP:\t%i" % (indent, data['foodLevel'], data['XpTotal']) print "%sInventory: %d items" % (indent, len(data['Inventory'])) if not sub_entry: for item in data['Inventory']: print " %-3d %s" % (item['Count'], items.id2item(item['id']))
def chestFilter(poi): from overviewer_core import items if poi['id'] in ["Chest", "minecraft:chest"]: if 'Items' in poi: chest_text = "Chest with {} items".format(len(poi['Items'])) items_text = "Chest\nEmpty" chest_items = dict() for item in poi["Items"]: item_name = items.id2item(item["id"]) if item_name.startswith("minecraft:"): item_name = item_name[10:] if item_name in chest_items: chest_items[item_name] += item["Count"] else: chest_items[item_name] = item["Count"] if len(chest_items) > 0: items_text = "" for item_name in chest_items.keys(): items_text += "\n{} of {}".format(chest_items[item_name], item_name) return (chest_text, items_text)
""" Very basic player.dat inspection script """ import sys, os # incantation to be able to import overviewer_core if not hasattr(sys, "frozen"): sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0], '..'))) from overviewer_core.nbt import load from overviewer_core import items print "Inspecting %s" % sys.argv[1] data = load(sys.argv[1])[1] print "Position: %r" % data['Pos'] print "Health: %s" % data['Health'] print "Inventory: %d items" % len(data['Inventory']) for item in data['Inventory']: print " %-3d %s" % (item['Count'], items.id2item(item['id']))