dumpchests now observes items with differing damage values
This commit is contained in:
parent
216bd58ccf
commit
9ca56ea596
15
items.py
15
items.py
@ -291,7 +291,7 @@ class Items (object):
|
||||
if line[0] == "#": continue;
|
||||
if line[0] == "~": continue; #groups
|
||||
stacksize = 64
|
||||
damagevalue = 0
|
||||
damagevalue = None
|
||||
maxdamage = 0
|
||||
|
||||
fields = line.split();
|
||||
@ -310,15 +310,24 @@ class Items (object):
|
||||
name = name.replace("_", " ");
|
||||
imagecoords = imagecoords.split(",");
|
||||
|
||||
self.itemtypes[id] = ItemType(id, name, imagefile, imagecoords, maxdamage, damagevalue, stacksize)
|
||||
self.itemtypes[(id, damagevalue)] = ItemType(id, name, imagefile, imagecoords, maxdamage, damagevalue, stacksize)
|
||||
except Exception, e:
|
||||
print "Error reading line:", e
|
||||
print "Line: ", line
|
||||
print
|
||||
|
||||
self.names = dict((item.name, item.id) for item in self.itemtypes.itervalues())
|
||||
|
||||
|
||||
def findItem(self, id=0, damage=None):
|
||||
item = self.itemtypes.get((id, damage))
|
||||
if item: return item
|
||||
|
||||
item = self.itemtypes.get((id, None))
|
||||
if item: return item
|
||||
|
||||
raise ItemNotFound, "Item {0}:{1} not found".format(id, damage)
|
||||
|
||||
class ItemNotFound(KeyError): pass
|
||||
|
||||
items = Items();
|
||||
|
||||
|
22
mce.py
22
mce.py
@ -690,13 +690,21 @@ class mce(object):
|
||||
chestCount += 1;
|
||||
|
||||
outFile.write(str(map(lambda x:tileEntity[x].value, "xyz")) + "\n");
|
||||
for Item in tileEntity["Items"]:
|
||||
try:
|
||||
itemname=items.itemtypes[Item["id"].value].name
|
||||
except KeyError:
|
||||
itemname="Unknown Item {0}".format(Item["id"].value)
|
||||
outFile.write("{0} {1}\n".format(Item["Count"].value,itemname));
|
||||
|
||||
itemsTag = tileEntity["Items"]
|
||||
if len(itemsTag):
|
||||
for itemTag in itemsTag:
|
||||
try:
|
||||
id = itemTag["id"].value
|
||||
damage = itemTag["Damage"].value
|
||||
item = items.findItem(id, damage)
|
||||
itemname=item.name
|
||||
except KeyError:
|
||||
itemname="Unknown Item {0}".format(itemTag)
|
||||
except Exception, e:
|
||||
itemname = repr(e)
|
||||
outFile.write("{0} {1}\n".format(itemTag["Count"].value,itemname));
|
||||
else:
|
||||
outFile.write("Empty Chest\n")
|
||||
|
||||
if i % 100 == 0:
|
||||
print "Chunk {0}...".format(i)
|
||||
|
Reference in New Issue
Block a user