Added dumpchests command, contributed by user JYF
Merge remote branch 'JYF/master' Conflicts: mce.py
This commit is contained in:
commit
f4724cfe8b
61
mce.py
Executable file → Normal file
61
mce.py
Executable file → Normal file
@ -40,6 +40,7 @@ class mce(object):
|
||||
Entity commands:
|
||||
{commandPrefix}removeEntities [ <EntityID> ]
|
||||
{commandPrefix}dumpSigns [ <filename> ]
|
||||
{commandPrefix}dumpChests [ <filename> ]
|
||||
|
||||
Chunk commands:
|
||||
{commandPrefix}createChunks <box>
|
||||
@ -96,6 +97,7 @@ class mce(object):
|
||||
|
||||
"removeentities",
|
||||
"dumpsigns",
|
||||
"dumpchests",
|
||||
|
||||
"createchunks",
|
||||
"deletechunks",
|
||||
@ -644,6 +646,65 @@ class mce(object):
|
||||
rf.repair()
|
||||
|
||||
|
||||
def _dumpchests(self, command):
|
||||
"""
|
||||
dumpChests [ <filename> ]
|
||||
|
||||
Saves the content and location of every chest in the world to a text file.
|
||||
With no filename, saves signs to <worldname>.chests
|
||||
|
||||
Output is delimited by brackets and newlines. A set of coordinates in
|
||||
brackets begins a chest, followed by a line for each inventory slot.
|
||||
For example:
|
||||
|
||||
[222, 51, 22]
|
||||
2 String
|
||||
3 String
|
||||
3 Iron bar
|
||||
|
||||
Coordinates are ordered the same as point inputs:
|
||||
[North/South, Down/Up, East/West]
|
||||
|
||||
"""
|
||||
from items import items
|
||||
if len(command):
|
||||
filename = command[0]
|
||||
else:
|
||||
filename = self.level.displayName + ".chests"
|
||||
|
||||
outFile = file(filename, "w");
|
||||
|
||||
print "Dumping chests..."
|
||||
chestCount = 0;
|
||||
|
||||
for i, cPos in enumerate(self.level.allChunks):
|
||||
try:
|
||||
chunk = self.level.getChunk(*cPos);
|
||||
except mclevel.ChunkMalformed:
|
||||
continue;
|
||||
|
||||
for tileEntity in chunk.TileEntities:
|
||||
if tileEntity["id"].value == "Chest":
|
||||
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));
|
||||
|
||||
|
||||
if i % 100 == 0:
|
||||
print "Chunk {0}...".format(i)
|
||||
|
||||
chunk.unload();
|
||||
|
||||
print "Dumped {0} chests to {1}".format(chestCount, filename);
|
||||
|
||||
outFile.close();
|
||||
|
||||
def _removeentities(self, command):
|
||||
"""
|
||||
removeEntities [ [except] [ <EntityID> [ <EntityID> ... ] ] ]
|
||||
|
Reference in New Issue
Block a user