Ejemplo n.º 1
0
    def test_loading(self):
        # world_obj = self.loader.load_world(get_world_path("1.12.2 World"))
        world_obj = load_world(get_world_path("1.12.2 World"))
        self.assertIsInstance(world_obj, world.World)

        # world_obj = self.loader.load_world(get_world_path("1.13 World"))
        world_obj = load_world(get_world_path("1.13 World"))
        self.assertIsInstance(world_obj, world.World)
Ejemplo n.º 2
0
 def __init__(self, parent, world_path):
     try:
         self._world = world_interface.load_world(world_path)
     except Exception as e:
         traceback.print_exc()
         parent.Show(True)
         return
     wx.Frame.__init__(self, parent, title=world_path, size=(500, 450))
     self._create_ui()
     self.Bind(wx.EVT_CLOSE, self._exit)
     self.Show(True)
Ejemplo n.º 3
0
 def __init__(self, parent, path):
     SimpleNotebook.__init__(self, parent, wx.NB_LEFT)
     self._finished = False
     self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self._page_change)
     try:
         self.world = world_interface.load_world(path)
     except LoaderNoneMatched as e:
         self.Destroy()
         raise e
     self.world_name = self.world.world_wrapper.world_name
     self._extensions: List[BaseWorldProgram] = []
     self._last_extension: int = -1
     self._load_extensions()
     self._finished = True
Ejemplo n.º 4
0
 def __init__(self, parent: wx.Window, path: str,
              close_self_callback: Callable[[], None]):
     super().__init__(parent, style=wx.NB_LEFT)
     self._path = path
     self._close_self_callback = close_self_callback
     try:
         self.world = world_interface.load_world(path)
     except LoaderNoneMatched as e:
         self.Destroy()
         raise e
     self.world_name = self.world.world_wrapper.world_name
     self._extensions: List[BaseWorldProgram] = []
     self._last_extension: int = -1
     self._load_extensions()
     self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self._page_change)
Ejemplo n.º 5
0
 def _setUp(self, world_name):
     self.world = load_world(get_world_path(world_name))
def fill(booksPerBarrel,
         position,
         world=False,
         dimension="overworld",
         skipChunk=0,
         skipArticles=0,
         filePath="",
         totalArticleCount=-1):
    zimfile = ZIMFile(filePath, "utf-8")

    if totalArticleCount == -1:
        totalArticleCount = getLastArticleId(zimfile)
        print("Article count: ", totalArticleCount)

    barrelPositionList = generateBarrelPositionList()
    barrelsPerChunk = len(barrelPositionList)
    chunkBookCapacity = barrelsPerChunk * booksPerBarrel

    chunkList = generateChunkList(totalArticleCount, chunkBookCapacity,
                                  position, world == False)
    if world:

        wallChunkList = generateWallList(chunkList)

        totalChunkCount = len(chunkList) + len(wallChunkList)
        completedChunks = 0
        currentArticle = skipArticles
        for chunkCoords in chunkList:
            if skipChunk > 0:
                skipChunk -= 1
                completedChunks += 1
                currentArticle += booksPerBarrel * barrelsPerChunk
                continue

            start = time.perf_counter()

            worldObj = load_world(path.expandvars(world))
            chunk = worldObj.get_chunk(chunkCoords[0], chunkCoords[1],
                                       dimension)
            fillChunk(chunk, barrelPositionList, worldObj, dimension,
                      currentArticle, booksPerBarrel, filePath, chunkList,
                      position)
            currentArticle += booksPerBarrel * barrelsPerChunk

            worldObj.create_undo_point(
            )  #workaround suggested by amulet team so that saving works (can possibly be removed in the future)
            worldObj.save()
            worldObj.close()

            completedChunks += 1
            print("chunk time (m): ", (time.perf_counter() - start) / 60)
            print("completed chunk: ", completedChunks)
            yield 100 * completedChunks / totalChunkCount

        for wallChunkCoords, orientation in wallChunkList:
            chunk = worldObj.get_chunk(wallChunkCoords[0], wallChunkCoords[1],
                                       dimension)
            placeWall(chunk, orientation, worldObj)

            completedChunks += 1
            yield 100 * completedChunks / totalChunkCount

        worldObj.create_undo_point(
        )  #workaround suggested by amulet team so that saving works (can possibly be removed in the future)
        worldObj.save()
Ejemplo n.º 7
0
if __name__ == "__main__":
    args = sys.argv[1:]
    if len(args) == 0:
        print("Command line arguments required")
        print("random_chunk <origin_world_path> <cx> <cz>")
        print("convert <origin_world_path> <destination_world_path>")
    elif len(args) >= 1:
        mode = args[0]
        if mode in ["random_chunk", "air", "stone"]:
            if len(args) >= 4:
                world_path = args[1]
                cx, cz = int(args[2]), int(args[3])

                print(f"Loading world at {world_path}")
                world = load_world(world_path)
                print(f"Loading chunk at {cx}, {cz}")
                chunk = world.get_chunk(cx, cz)
                print("A vertical column of blocks in the chunk:")
                for block in chunk.blocks[
                    0, :, 0
                ].ravel():  # the blockstates of one vertical column
                    print(world.palette[block])
                air = world.palette.get_add_block(
                    Block(namespace="universal_minecraft", base_name="air")
                )
                print("Filling chunk with blocks")
                if mode == "air":
                    chunk.blocks[0, 0, 0] = air
                elif mode == "random_chunk":
                    blocks = numpy.random.randint(
Ejemplo n.º 8
0
from amulet.world_interface import load_world

from util.color_util import block_from_tile, process_tile
from util.file_util import handle_files
from util.map_loader import load_terrain
from util.mc_util import set_block, initialize_world
from util.region import Region

if __name__ == "__main__":
    empty_world_path = "resources/emptymap"
    # WARNING ANY DIRECTORY AT THE OUTPUT PATH WILL BE DELETED
    output_world_path = "output/testworld1"

    handle_files(empty_world_path, output_world_path)
    world = load_world(output_world_path)
    initialize_world(world)
    # set_block(world, 0, 64, 0)
    # world.save()
    path = "rscachedump/tiledata"
    regions = []
    pattern = re.compile("m(\d+)_(\d+).dat")
    for filename in os.listdir(path):
        with open(os.path.join(path, filename), 'rb') as f:
            match = pattern.match(filename)
            regionX = match.group(1)
            regionY = match.group(2)
            region = Region(int(regionX), int(regionY))
            load_terrain(region, f)
            regions.append(region)
            f.close()