Ejemplo n.º 1
0
 def process_world(self, world_folder, randomSpawners):
         try:
                 world = WorldFolder(world_folder)
         except:
                 return
         for region in world.iter_regions():
                 print(region.filename)
                 chunk_moved = False
                 for chunk in region.iter_chunks():
                         if(self.randomize_Spawners(chunk["Level"], randomSpawners)):
                                 x=chunk["Level"]["xPos"].value
                                 z=chunk["Level"]["zPos"].value
                                 if x < 0:
                                         while x < 0:
                                                 x += 32
                                 elif x > 31:
                                         while x > 31:
                                                 x -= 32
                                 if z < 0:
                                         while z < 0:
                                                 z += 32
                                 elif z > 31:
                                         while z > 31:
                                                 z -= 32
                                         
                                 print("Updating apawners in chunk: x: "+str(x)+" z: "+str(z))
                                 try:
                                         #print("HERP")
                                         if(region.write_chunk(x,z,chunk)):
                                                 chunk_moved = True
                                         #print("DERP")
                                 except ValueError as e:
                                         print("ERROR:  Failed to update chunk.")
                                         print(e)
Ejemplo n.º 2
0
def main(world_folder, start=None, stop=None):
    world = WorldFolder(world_folder)

    try:
        for region in world.iter_regions():
            process_region_file(region, start, stop)

    except KeyboardInterrupt:
        print('Keyboard interrupt!')
        print_results(block_counts)
        return 75 # EX_TEMPFAIL

    print_results()
    return 0 # EX_OK
Ejemplo n.º 3
0
def main(world_folder, start=None, stop=None):
    world = WorldFolder(world_folder)

    try:
        for region in world.iter_regions():
            process_region_file(region, start, stop)

    except KeyboardInterrupt:
        print('Keyboard interrupt!')
        print_results(block_counts)
        return 75  # EX_TEMPFAIL

    print_results()
    return 0  # EX_OK
Ejemplo n.º 4
0
def main(world_folder, options):
    world = WorldFolder(world_folder)

    if not isinstance(world, nbt.world.AnvilWorldFolder):
        print(world_folder + " is not an Anvil world")
        return 0

    level = NBTFile(os.path.join(world_folder, "level.dat"))
    version = Util.get_version(level)

    print("\nLoading level at " + world_folder)
    if version != "1.8" or options.force:
        if options.force:
            print("[Forcing level conversion attempt]")
        print("Level saved as Minecraft version " + version)
        try:
            total_nbt_edits = 0
            total_block_edits = 0
            for region in world.iter_regions():
                for chunk in region.iter_chunks():
                    chunk, nbt_edits = convert_chunk(chunk)
                    chunk, block_edits = convert_block(chunk)
                    total_nbt_edits += nbt_edits
                    total_block_edits += block_edits
                    if options.save and nbt_edits > 0 or block_edits > 0:
                        save_chunk(region, chunk)
            if total_nbt_edits > 0 or total_block_edits > 0:
                print("%d modifications made to the level nbt" %
                      (total_nbt_edits))
                print("%d modifications made to block section byte arrays" %
                      (total_block_edits))
                if options.save:
                    save_level(level, world_folder)
                else:
                    print("No modifications saved to level (using -n flag)")
            else:
                print("No level data was changed (nothing to modify)")
        except KeyboardInterrupt:
            return 75
    else:
        print("Level is already saved for Minecraft 1.8 (or older)")

    if options.disable_keep_inv and options.save:
        disable_keep_inv(level, world_folder)

    return 0