some (modded?) tile entities don't have x/y/z position attributes, so skip them... needs investigation

This commit is contained in:
David Vierra 2011-04-05 19:18:29 -10:00
parent 3bcc93657b
commit 80f1fd4944

View File

@ -1028,6 +1028,8 @@ class MCLevel(object):
def getTileEntitiesInRange(self, sourceBox, tileEntities): def getTileEntitiesInRange(self, sourceBox, tileEntities):
entsInRange = []; entsInRange = [];
for tileEntity in tileEntities: for tileEntity in tileEntities:
if not 'x' in tileEntity: continue
x,y,z = tileEntity['x'].value, tileEntity['y'].value, tileEntity['z'].value x,y,z = tileEntity['x'].value, tileEntity['y'].value, tileEntity['z'].value
if not (x,y,z) in sourceBox: continue if not (x,y,z) in sourceBox: continue
entsInRange.append(tileEntity) entsInRange.append(tileEntity)
@ -1075,6 +1077,8 @@ class MCLevel(object):
self.addEntity(eTag); self.addEntity(eTag);
for tileEntity in chunk.TileEntities: for tileEntity in chunk.TileEntities:
if not 'x' in tileEntity: continue
x,y,z = tileEntity['x'].value, tileEntity['y'].value, tileEntity['z'].value x,y,z = tileEntity['x'].value, tileEntity['y'].value, tileEntity['z'].value
if x-wx<slices[0].start or x-wx>=slices[0].stop: continue if x-wx<slices[0].start or x-wx>=slices[0].stop: continue
if y<slices[2].start or y>=slices[2].stop: continue if y<slices[2].start or y>=slices[2].stop: continue
@ -1107,6 +1111,8 @@ class MCLevel(object):
for entity in sourceLevel.getTileEntitiesInRange(sourceBox, sourceLevel.TileEntities): for entity in sourceLevel.getTileEntitiesInRange(sourceBox, sourceLevel.TileEntities):
if not 'x' in entity: continue
x,y,z = entity['x'].value, entity['y'].value, entity['z'].value x,y,z = entity['x'].value, entity['y'].value, entity['z'].value
eTag = deepcopy(entity) eTag = deepcopy(entity)
@ -1539,6 +1545,8 @@ class MCSchematic (MCLevel):
entity["Dir"].value = (entity["Dir"].value + 1) % 4 entity["Dir"].value = (entity["Dir"].value + 1) % 4
for tileEntity in self.TileEntities: for tileEntity in self.TileEntities:
if not 'x' in tileEntity: continue
newX = tileEntity["z"].value newX = tileEntity["z"].value
newZ = self.Length - tileEntity["x"].value - 1 newZ = self.Length - tileEntity["x"].value - 1
@ -1576,6 +1584,8 @@ class MCSchematic (MCLevel):
entity["Dir"].value = northSouthPaintingMap[entity["Dir"].value] entity["Dir"].value = northSouthPaintingMap[entity["Dir"].value]
for tileEntity in self.TileEntities: for tileEntity in self.TileEntities:
if not 'x' in tileEntity: continue
tileEntity["x"].value = self.Width - tileEntity["x"].value - 1 tileEntity["x"].value = self.Width - tileEntity["x"].value - 1
def flipEastWest(self): def flipEastWest(self):
@ -3482,6 +3492,8 @@ class MCInfdevOldLevel(MCLevel):
def addTileEntity(self, entity): def addTileEntity(self, entity):
assert isinstance(entity, TAG_Compound) assert isinstance(entity, TAG_Compound)
if not 'x' in entity: return
x = int(entity['x'].value) x = int(entity['x'].value)
y = int(entity['y'].value) y = int(entity['y'].value)
z = int(entity['z'].value) z = int(entity['z'].value)
@ -3492,7 +3504,7 @@ class MCInfdevOldLevel(MCLevel):
return return
# raise Error, can't find a chunk? # raise Error, can't find a chunk?
def samePosition(a): def samePosition(a):
return (a['x'].value == x and a['y'].value == y and a['z'].value == z) return ('x' in a and (a['x'].value == x and a['y'].value == y and a['z'].value == z))
try: try:
chunk.TileEntities.remove(filter(samePosition, chunk.TileEntities)); chunk.TileEntities.remove(filter(samePosition, chunk.TileEntities));