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;
|
||||||
if line[0] == "~": continue; #groups
|
if line[0] == "~": continue; #groups
|
||||||
stacksize = 64
|
stacksize = 64
|
||||||
damagevalue = 0
|
damagevalue = None
|
||||||
maxdamage = 0
|
maxdamage = 0
|
||||||
|
|
||||||
fields = line.split();
|
fields = line.split();
|
||||||
@ -310,15 +310,24 @@ class Items (object):
|
|||||||
name = name.replace("_", " ");
|
name = name.replace("_", " ");
|
||||||
imagecoords = imagecoords.split(",");
|
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:
|
except Exception, e:
|
||||||
print "Error reading line:", e
|
print "Error reading line:", e
|
||||||
print "Line: ", line
|
print "Line: ", line
|
||||||
print
|
print
|
||||||
|
|
||||||
self.names = dict((item.name, item.id) for item in self.itemtypes.itervalues())
|
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();
|
items = Items();
|
||||||
|
|
||||||
|
22
mce.py
22
mce.py
@ -690,13 +690,21 @@ class mce(object):
|
|||||||
chestCount += 1;
|
chestCount += 1;
|
||||||
|
|
||||||
outFile.write(str(map(lambda x:tileEntity[x].value, "xyz")) + "\n");
|
outFile.write(str(map(lambda x:tileEntity[x].value, "xyz")) + "\n");
|
||||||
for Item in tileEntity["Items"]:
|
itemsTag = tileEntity["Items"]
|
||||||
try:
|
if len(itemsTag):
|
||||||
itemname=items.itemtypes[Item["id"].value].name
|
for itemTag in itemsTag:
|
||||||
except KeyError:
|
try:
|
||||||
itemname="Unknown Item {0}".format(Item["id"].value)
|
id = itemTag["id"].value
|
||||||
outFile.write("{0} {1}\n".format(Item["Count"].value,itemname));
|
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:
|
if i % 100 == 0:
|
||||||
print "Chunk {0}...".format(i)
|
print "Chunk {0}...".format(i)
|
||||||
|
Reference in New Issue
Block a user