def rotateLeft(self): self._fakeEntities = None self._Blocks = swapaxes(self._Blocks, 1, 2)[:, ::-1, :] # x=z; z=-x if "Biomes" in self.root_tag: self.root_tag["Biomes"].value = swapaxes(self.root_tag["Biomes"].value, 0, 1)[::-1, :] self.root_tag["Data"].value = swapaxes(self.root_tag["Data"].value, 1, 2)[:, ::-1, :] # x=z; z=-x self._update_shape() blockrotation.RotateLeft(self.Blocks, self.Data) log.info(u"Relocating entities...") for entity in self.Entities: for p in "Pos", "Motion": if p == "Pos": zBase = self.Length else: zBase = 0.0 newX = entity[p][2].value newZ = zBase - entity[p][0].value entity[p][0].value = newX entity[p][2].value = newZ entity["Rotation"][0].value -= 90.0 if entity["id"].value in ("Painting", "ItemFrame"): x, z = entity["TileX"].value, entity["TileZ"].value newx = z newz = self.Length - x - 1 entity["TileX"].value, entity["TileZ"].value = newx, newz facing = entity.get("Facing", entity.get("Direction")) if facing is None: dirFacing = entity.get("Dir") if dirFacing is not None: if dirFacing.value == 0: dirFacing.value = 2 elif dirFacing.value == 2: dirFacing.value = 0 facing = dirFacing else: raise Exception("None of tags Facing/Direction/Dir found in entity %s during rotating - %r" % (entity["id"].value, entity)) facing.value = (facing.value - 1) % 4 for tileEntity in self.TileEntities: if not 'x' in tileEntity: continue newX = tileEntity["z"].value newZ = self.Length - tileEntity["x"].value - 1 tileEntity["x"].value = newX tileEntity["z"].value = newZ if "TileTicks" in self.root_tag: for tileTick in self.TileTicks: newX = tileTick["z"].value newZ = tileTick["x"].value tileTick["x"].value = newX tileTick["z"].value = newZ
def rotateLeft(self): self._fakeEntities = None self._Blocks = swapaxes(self._Blocks, 1, 2)[:, ::-1, :] # x=z; z=-x if "Biomes" in self.root_tag: self.root_tag["Biomes"].value = swapaxes( self.root_tag["Biomes"].value, 0, 1)[::-1, :] self.root_tag["Data"].value = swapaxes(self.root_tag["Data"].value, 1, 2)[:, ::-1, :] # x=z; z=-x self._update_shape() blockrotation.RotateLeft(self.Blocks, self.Data) log.info(u"Relocating entities...") for entity in self.Entities: for p in "Pos", "Motion": if p == "Pos": zBase = self.Length else: zBase = 0.0 newX = entity[p][2].value newZ = zBase - entity[p][0].value entity[p][0].value = newX entity[p][2].value = newZ entity["Rotation"][0].value -= 90.0 if entity["id"].value in ("Painting", "ItemFrame"): x, z = entity["TileX"].value, entity["TileZ"].value newx = z newz = self.Length - x - 1 entity["TileX"].value, entity["TileZ"].value = newx, newz entity["Facing"].value = (entity["Facing"].value - 1) % 4 for tileEntity in self.TileEntities: if not 'x' in tileEntity: continue newX = tileEntity["z"].value newZ = self.Length - tileEntity["x"].value - 1 tileEntity["x"].value = newX tileEntity["z"].value = newZ if "TileTicks" in self.root_tag: for tileTick in self.TileTicks: newX = tileTick["z"].value newZ = tileTick["x"].value tileTick["x"].value = newX tileTick["z"].value = newZ
def rotateLeft(self): self.Blocks = swapaxes(self.Blocks, 1, 0)[:, ::-1, :] # x=z; z=-x self.Data = swapaxes(self.Data, 1, 0)[:, ::-1, :] # x=z; z=-x self._update_shape() blockrotation.RotateLeft(self.Blocks, self.Data) info(u"Relocating entities...") for entity in self.Entities: for p in "Pos", "Motion": if p == "Pos": zBase = self.Length else: zBase = 0.0 newX = entity[p][2].value newZ = zBase - entity[p][0].value entity[p][0].value = newX entity[p][2].value = newZ entity["Rotation"][0].value -= 90.0 if entity["id"].value == "Painting": x, z = entity["TileX"].value, entity["TileZ"].value newx = z newz = self.Length - x - 1 entity["TileX"].value, entity["TileZ"].value = newx, newz entity["Dir"].value = (entity["Dir"].value + 1) % 4 for tileEntity in self.TileEntities: if not 'x' in tileEntity: continue newX = tileEntity["z"].value newZ = self.Length - tileEntity["x"].value - 1 tileEntity["x"].value = newX tileEntity["z"].value = newZ
def rotateLeftBlocks(self): """ rotateLeft the blocks direction without there location """ blockrotation.RotateLeft(self.Blocks, self.Data)