def loadWorld(self, world): worldpath = os.path.expanduser(world) if os.path.exists(worldpath): self.level = mclevel.fromFile(worldpath) else: self.level = mclevel.loadWorld(world)
def load_world(world, dim=0): world_path = os.path.expanduser('~/.minecraft/saves/{}/'.format(world)) w = mclevel.loadWorld(world_path) if dim == 0: return w else: return w.dimensions[dim]
def create_house_in_player_pos(): level = mclevel.loadWorld("New World") player_pos = level.getPlayerPosition() house = House() house.load() level = house.generate(level, x=player_pos[0], y=player_pos[1], z=player_pos[2]) level.saveInPlace()
def create_house_in_pos(x=0, y=0, z=0): level = mclevel.loadWorld("New World") player_pos = (x, y, z) house = House() house.load() level = house.generate(level, x=player_pos[0], y=player_pos[1], z=player_pos[2]) level.generateLights() level.saveInPlace()
def loadWorld(self, world, dimension): worldpath = os.path.expanduser(world) if os.path.exists(worldpath): level = mclevel.fromFile(worldpath) else: level = mclevel.loadWorld(world) if dimension is not None: if dimension in level.dimensions: level = level.dimensions[dimension] else: raise InvalidDimensionError, "Dimension {0} does not exist".format(dimension) return level
from __future__ import print_function import mclevel import numpy as np __author__ = "Cosmo Harrigan" # Load the level data: set the path using level_filename here # level_filename = "/Users/cosmo/minecraft-dataset-generation/world/level.dat" # Unprocessed repository version level_filename = "/Users/cosmo/minecraft-server/world/level.dat" # Server version # level_filename = "/Users/cosmo/minecraft-dataset-generation/world-processed/level.dat" # Processed repository version # level_filename = "/Users/cosmo/Library/Application Support/minecraft/saves/test6b/level.dat" # MCEdit saved version READ_ONLY = False world = mclevel.loadWorld(level_filename) # Check how many chunks are defined in the world chunks = world.getChunks() print("Number of chunks: {0}".format(len(list(chunks)))) # # Print the position of each chunk # chunk_positions = list(world.allChunks) # print("Chunk positions:") # for chunk_position in chunk_positions: # print(chunk_position) # In this case, we will only work with the chunk located at (0, 0) since we # are defining a small world that fits within one chunk. chunk = world.getChunk(-1, 0)
rail_way = RailWay() rail_way.load() level = rail_way.generate(level, x=player_pos[0], y=player_pos[1], z=player_pos[2]) # level.generateLights() # level.saveInPlace() def create_rail_system_from_a_to_b(level, point_a, point_b): rail_system = TwoWaysRailSystem(level, point_a=point_a, point_b=point_b) rail_system.generate() rail_system.save_level() if __name__ == "__main__": level = mclevel.loadWorld("testworld") # dist = 50 # create_rail_station_in_pos(level, 733, 6, 1453) # z_start = 1460 # z_end = z_start + dist # for i in xrange(0, dist): # create_rail_way_in_pos(level, 731, 5, z_start+i) # create_rail_way_in_pos(level, 735, 5, z_start+i) # create_rail_station_in_pos(level, 733, 6, z_end + 6, flip=True) # level.generateLights() # level.saveInPlace() point_a = [700, 7, 1450] point_b = [700, 7, 1500] create_rail_system_from_a_to_b(level, point_a=point_a, point_b=point_b)