Ejemplo n.º 1
0
def loadFile(fName):
    if not fName:
        fName = mcplatform.askOpenFile(title=_("Select a NBT (.dat) file..."), suffixes=['dat',])
    if fName:
        if not os.path.isfile(fName):
            alert("The selected object is not a file.\nCan't load it.")
            return
        dontSaveRootTag = False
        nbtObject = load(fName)
        if fName.endswith('.schematic'):
            nbtObject = TAG_Compound(name='Data', value=nbtObject)
            dontSaveRootTag = True
            dataKeyName = 'Data'
        elif nbtObject.get('Data', None):
            dataKeyName = 'Data'
        elif nbtObject.get('data', None):
            dataKeyName = 'data'
        else:
            nbtObject.name = 'Data'
            dataKeyName = 'Data'
            dontSaveRootTag = True
            nbtObject = TAG_Compound([nbtObject,])
#        dontSaveRootTag = not fName.endswith('.schematic')
        return nbtObject, dataKeyName, dontSaveRootTag, fName
    return [None,] * 4
Ejemplo n.º 2
0
        def change_value(data):
            s, i, c, d = data
            s = int(s)
            s_idx = 0
            if s in slots_set:
#                for slot in self.data['Player']['Inventory']:
                for slot in inventory:
                    if slot['Slot'].value == s:
                        if not i or int(c) < 1:
                            del inventory[s_idx]
                            i = ""
                            c = u'0'
                            d = u'0'
                        else:
                            slot['id'].value = 'minecraft:%s'%i
                            slot['Count'].value = int(c)
                            slot['Damage'].value = int(d)
                        break
                    s_idx += 1
            else:
                new_slot = TAG_Compound()
                new_slot['Slot'] = TAG_Byte(s)
                new_slot['id'] = TAG_String('minecraft:%s'%i)
                new_slot['Count'] = TAG_Byte(int(c))
                new_slot['Damage'] = TAG_Short(int(d))
                idx = s
                for slot in inventory:
                    if slot['Slot'].value >= s:
                        idx = slot['Slot'].value
                        break
                inventory.insert(s, new_slot)
                slots_set.append(s)
            table.slots[s] = slots[s] = s, i, c, d
Ejemplo n.º 3
0
 def loadFile(self, fName=None):
     if not fName:
         fName = mcplatform.askOpenFile(title="Select a NBT (.dat) file...",
                                        suffixes=[
                                            'dat',
                                        ])
         if fName:
             if not os.path.isfile(fName):
                 alert("The selected object is not a file.\nCan't load it.")
                 return
             dontSaveRootTag = False
             nbtObject = load(fName)
             dataKeyName = None
             if nbtObject.get('Data', None):
                 dataKeyName = 'Data'
             elif nbtObject.get('data', None):
                 dataKeyName = 'data'
             else:
                 nbtObject.name = 'Data'
                 dataKeyName = 'Data'
                 dontSaveRootTag = True
                 nbtObject = TAG_Compound([
                     nbtObject,
                 ])
             self.editor.currentTool = self
             self.showPanel(fName, nbtObject, dontSaveRootTag, dataKeyName)
             self.optionsPanel.dismiss()
Ejemplo n.º 4
0
def createExplosionFromOptions(options):
    explosion = TAG_Compound()

    if options["Flicker"]:
        flickerVal = 1
    else:
        flickerVal = 0
    explosion["Flicker"] = TAG_Byte(flickerVal)

    if options["Trail"]:
        trailVal = 1
    else:
        trailVal = 0
    explosion["Trail"] = TAG_Byte(trailVal)

    typeVal = fireworkTypes[options["Type"]]
    explosion["Type"] = TAG_Byte(typeVal)

    colors = []
    rang = range(1, 4)
    for i in rang:
        color = getColor(options, i)
        colors.append(color.rgb)
    explosion["Colors"] = TAG_Int_Array(colors)
    return explosion
Ejemplo n.º 5
0
def loadFile(fName):
    if not fName:
        fName = mcplatform.askOpenFile(title=_("Select a NBT (.dat) file..."), suffixes=['dat',])
    if fName:
        if not os.path.isfile(fName):
            alert("The selected object is not a file.\nCan't load it.")
            return
        dontSaveRootTag = False
        nbtObject = load(fName)
        if fName.endswith('.schematic'):
            nbtObject = TAG_Compound(name='Data', value=nbtObject)
            dontSaveRootTag = True
            dataKeyName = 'Data'
        elif nbtObject.get('Data', None):
            dataKeyName = 'Data'
        elif nbtObject.get('data', None):
            dataKeyName = 'data'
        else:
            nbtObject.name = 'Data'
            dataKeyName = 'Data'
            dontSaveRootTag = True
            nbtObject = TAG_Compound([nbtObject,])
#        dontSaveRootTag = not fName.endswith('.schematic')
        return nbtObject, dataKeyName, dontSaveRootTag, fName
    return [None,] * 4
Ejemplo n.º 6
0
def createCommandBlock(x, y, z, command):
    commandBlock = TAG_Compound()
    commandBlock["id"] = TAG_String("Control")
    commandBlock["x"] = TAG_Int(x)
    commandBlock["y"] = TAG_Int(y)
    commandBlock["z"] = TAG_Int(z)
    commandBlock["Command"] = TAG_String(command)
    commandBlock["SuccessCount"] = TAG_Int(0)
    commandBlock["LastOutput"] = TAG_String("")
    commandBlock["TrackOutput"] = TAG_Byte(0)
    return commandBlock
Ejemplo n.º 7
0
def perform(level, box, options):
    # go through all chunk slices which our box is in
    for (chunk, slices, point) in level.getChunkSlices(box):
        # go through all Tile Entities in a chunk (Chest is Tile Entity)
        for tileEntity in chunk.TileEntities:
            # the slices are not precisely cut for our box, so we need to check if tile entity is in our box
            x = tileEntity[
                "x"].value  # it's important not to forget '.value' because tileEntity["x"] refers to NBT tag
            y = tileEntity["y"].value
            z = tileEntity["z"].value
            if x >= box.minx and x < box.maxx and y >= box.miny and y < box.maxy and z >= box.minz and z < box.maxz:
                # we're only looking for chests, so we need to check if this is a chest.
                # Tile Entity IDs can be found at minecraftwiki.net on page Chunk Format
                if tileEntity["id"].value == "Chest":
                    # Now, we can do 3 things: add an item to the chest, edit the existing item, delete the existing item.
                    # ----------------------------------------------------------------------------------------------------
                    # 1.) Add an item
                    #     To add an item to the chest, we need to have its TAG_Compound first. I'll create the item here:
                    # ----------------------------------------------------------------------------------------------------
                    item = TAG_Compound()
                    item["id"] = TAG_Short(1)  # here comes the item ID
                    item["Damage"] = TAG_Short(0)  # here comes the damage/data
                    item["Count"] = TAG_Byte(1)  # count (usually 0 - 64)
                    item["Slot"] = TAG_Byte(
                        0
                    )  # this is ugly, because you may replace an existing item, but we'll assume our chest is empty for now.
                    #     We need to make sure there's already a TAG_List called "Items" so we can append our item safely
                    if not "Items" in tileEntity:
                        tileEntity["Items"] = TAG_List()
                    tileEntity["Items"].append(item)
                    # ----------------------------------------------------------------------------------------------------
                    # 2.) Edit an item
                    #     To edit an item in chest, we need to find the target item first, so we need to look through all items in the chest and see if it's what we're looking for.
                    #     In this example, I'll look for Diamond Pick(id 278) and change them to diamond hoes(293) >:)
                    # ----------------------------------------------------------------------------------------------------
                    if "Items" in tileEntity:
                        for item in tileEntity["Items"]:
                            if item["id"].value == 278:
                                item["id"].value = 293
                    # ----------------------------------------------------------------------------------------------------
                    # 3.) Delete an item
                    #     As in the previous example, we need to find the item to be deleted at first and then delete it.
                    #     In this example, I'll delete all music discs from the chest.
                    # ----------------------------------------------------------------------------------------------------
                    if "Items" in tileEntity:
                        index = 0
                        for item in tileEntity["Items"]:
                            if item["id"].value >= 2256 and item[
                                    "id"].value <= 2267:
                                del tileEntity["Items"][index]
                            ++index
                    # Cleanup: After you edit a chest, you need to tell MCEdit that you changed it. It's done by flagging the current chunk as "dirty".
                    chunk.dirty = True
Ejemplo n.º 8
0
        def change_value(data):
            s, i, c, d = data
            s = int(s)
            s_idx = 0
            #&# Prototype for blocks/items names
            name, state = map_items.get(mclangres.untranslate(i), (i, '0'))
            if ':' not in name:
                name = 'minecraft:%s' % name
            #&#

            if s in slots_set:
                for slot in inventory:
                    if slot['Slot'].value == s:
                        if not i or int(c) < 1:
                            del inventory[s_idx]
                            i = ""
                            c = u'0'
                            d = u'0'
                        else:
                            #&# Prototype for blocks/items names
                            #slot['id'].value = 'minecraft:%s'%i
                            slot['id'].value = name
                            #&#
                            slot['Count'].value = int(c)
                            slot['Damage'].value = int(state)
                        break
                    s_idx += 1
            else:
                new_slot = TAG_Compound()
                new_slot['Slot'] = TAG_Byte(s)
                #&# Prototype for blocka/items names
                #new_slot['id'] = TAG_String('minecraft:%s'%i)
                new_slot['id'] = TAG_String(name)
                #&#
                new_slot['Count'] = TAG_Byte(int(c))
                new_slot['Damage'] = TAG_Short(int(state))
                idx = s
                for slot in inventory:
                    if slot['Slot'].value >= s:
                        idx = slot['Slot'].value
                        break
                inventory.insert(s, new_slot)
                slots_set.append(s)
            #&# Prototype for blocks/items names
#            if i == name:
#                i = name
#&#
            if s >= 100:
                n = s - 100 + 36
            else:
                n = s
            table.slots[n] = slots[n] = s, i, c, state
Ejemplo n.º 9
0
def perform(level, box, options):
    if box.width == 1 and box.height == 1 and box.length == 1 and level.blockAt(
            box.minx, box.miny, box.minz) == 0:
        level.setBlockAt(box.minx, box.miny, box.minz, 54)
        chest = TAG_Compound()
        chest["Items"] = TAG_List()
        chest["id"] = TAG_String(u'Chest')
        chest["x"] = TAG_Int(box.minx)
        chest["y"] = TAG_Int(box.miny)
        chest["z"] = TAG_Int(box.minz)
        chunk = level.getChunk(box.minx / 16, box.minz / 16)
        chunk.TileEntities.append(chest)
        chunk.dirty = True
    for (chunk, slices, point) in level.getChunkSlices(box):
        for t in chunk.TileEntities:
            x = t["x"].value
            y = t["y"].value
            z = t["z"].value
            if x >= box.minx and x < box.maxx and y >= box.miny and y < box.maxy and z >= box.minz and z < box.maxz:
                if "Items" in t:
                    foundFirework = False
                    for item in t["Items"]:
                        if item["id"].value == 401:
                            foundFirework = True
                            if not "tag" in item:
                                item["tag"] = TAG_Compound()
                            if not "Fireworks" in item["tag"]:
                                item["tag"]["Fireworks"] = TAG_Compound()
                            if not "Explosions" in item["tag"][
                                    "Fireworks"] or options[
                                        "Overwrite Existing Explosions"]:
                                item["tag"]["Fireworks"][
                                    "Explosions"] = TAG_List()
                            item["tag"]["Fireworks"]["Flight"] = TAG_Byte(
                                options["Flight"])
                            item["tag"]["Fireworks"]["Explosions"].append(
                                createExplosionFromOptions(options))
                            chunk.dirty = True
                    if not foundFirework:
                        freeSlots = getFreeSlots(t)
                        if len(freeSlots) > 0:
                            fireworkItem = TAG_Compound()
                            fireworkItem["id"] = TAG_Short(401)
                            fireworkItem["Damage"] = TAG_Short(0)
                            fireworkItem["Slot"] = TAG_Byte(freeSlots[0])
                            fireworkItem["Count"] = TAG_Byte(64)
                            fireworkItem["tag"] = TAG_Compound()
                            fireworkItem["tag"]["Fireworks"] = TAG_Compound()
                            fireworkItem["tag"]["Fireworks"][
                                "Explosions"] = TAG_List()
                            fireworkItem["tag"]["Fireworks"][
                                "Flight"] = TAG_Byte(options["Flight"])
                            fireworkItem["tag"]["Fireworks"][
                                "Explosions"].append(
                                    createExplosionFromOptions(options))
                            t["Items"].append(fireworkItem)
                            chunk.dirty = True
Ejemplo n.º 10
0
def loadFile(fName):
    if not fName:
        fName = mcplatform.askOpenFile(title=_("Select a NBT (.dat) file..."), suffixes=['dat', ])
    if fName:
        if not os.path.isfile(fName):
            alert("The selected object is not a file.\nCan't load it.")
            return
        savePolicy = 0
        data = open(fName).read()

        if struct.Struct('<i').unpack(data[:4])[0] in (3, 4):
            if struct.Struct('<i').unpack(data[4:8])[0] != len(data[8:]):
                raise NBTFormatError()
            with littleEndianNBT():
                nbtObject = load(buf=data[8:])
            savePolicy = 1
        elif struct.Struct('<i').unpack(data[:4])[0] in (1, 2):
            alert(_("Old PE level.dat, unsupported at the moment."))
        else:
            nbtObject = load(buf=data)
        if fName.endswith('.schematic'):
            nbtObject = TAG_Compound(name='Data', value=nbtObject)
            savePolicy = -1
            dataKeyName = 'Data'
        elif nbtObject.get('Data', None):
            dataKeyName = 'Data'
        elif nbtObject.get('data', None):
            dataKeyName = 'data'
        else:
            nbtObject.name = 'Data'
            dataKeyName = 'Data'
            if savePolicy == 0:
                savePolicy = -1
            nbtObject = TAG_Compound([nbtObject, ])
        return nbtObject, dataKeyName, savePolicy, fName
    return [None] * 4
Ejemplo n.º 11
0
def loadFile(fName):
    if not fName:
        fName = mcplatform.askOpenFile(title=_("Select a NBT (.dat) file..."),
                                       suffixes=[
                                           'dat',
                                       ])
    if fName:
        if not os.path.isfile(fName):
            alert("The selected object is not a file.\nCan't load it.")
            return
        savePolicy = 0
        data = open(fName).read()

        if struct.Struct('<i').unpack(data[:4])[0] in (3, 4):
            if struct.Struct('<i').unpack(data[4:8])[0] != len(data[8:]):
                raise NBTFormatError()
            with littleEndianNBT():
                nbtObject = load(buf=data[8:])
            savePolicy = 1
        elif struct.Struct('<i').unpack(data[:4])[0] in (1, 2):
            alert(_("Old PE level.dat, unsupported at the moment."))
        else:
            nbtObject = load(buf=data)
        if fName.endswith('.schematic'):
            nbtObject = TAG_Compound(name='Data', value=nbtObject)
            savePolicy = -1
            dataKeyName = 'Data'
        elif nbtObject.get('Data', None):
            dataKeyName = 'Data'
        elif nbtObject.get('data', None):
            dataKeyName = 'data'
        else:
            nbtObject.name = 'Data'
            dataKeyName = 'Data'
            if savePolicy == 0:
                savePolicy = -1
            nbtObject = TAG_Compound([
                nbtObject,
            ])
        return nbtObject, dataKeyName, savePolicy, fName
    return [None] * 4
Ejemplo n.º 12
0
def perform(level, box, options):
	forward_offset = options['Forward offset']
	right_offset = options['Right offset']
	up_offset = options['Up offset']
	relative_position = options['Relative position']
	generate_surrounding_box = options['Generate surrounding box']
	if generate_surrounding_box:
		forward_offset += 1
		up_offset += 1
	if relative_position == 'North':
		execution_center = ((box.minx + box.maxx) // 2 - right_offset, box.miny - up_offset + 2, box.maxz + forward_offset - 1)
	elif relative_position == 'East':
		execution_center = (box.minx - forward_offset, box.miny - up_offset + 2, (box.minz + box.maxz) // 2 - right_offset)
	elif relative_position == 'South':
		execution_center = ((box.minx + box.maxx) // 2 + right_offset, box.miny - up_offset + 2, box.minz - forward_offset)
	elif relative_position == 'West':
		execution_center = (box.maxx + forward_offset - 1, box.miny - up_offset + 2, (box.minz + box.maxz) // 2 + right_offset)
	include_air = options['Include air']
	include_blocks = options['Include blocks']
	include_null_block_data = options['Include null block data']
	include_entities = options['Include entities']
	include_commandblockoutput_command = options['Include "gamerule commandBlockOutput false" command']
	include_logadmincommands_command = options['Include "gamerule logAdminCommands false" command']
	add_initialization_commands = options['Add initialization commands']
	add_finalization_commands = options['Add finalization commands']
	block_to_enqueue_input = re.split(r'\s*,\s*', options['Blocks to enqueue'].strip())
	blocks_to_enqueue = []
	for block_id in xrange(0, len(materials.block_map) - 1):
		if materials.block_map[block_id] in block_to_enqueue_input:
			blocks_to_enqueue.append(block_id)
	nbt_tags_to_ignore = re.split(r'\s*,\s*', options['NBT tags to ignore']) + ['x', 'y', 'z']
	save_command_to_file = options['Save the command to a file instead of to a Command Block']
	ignore_maximum_command_block_command_length = options['Ignore maximum Command Block command length']
	box_wall_material_block = options['Box wall material block']
	box_wall_material_data = options['Box wall material data value']
	box_floor_material_block = options['Box floor material block']
	box_floor_material_data = options['Box floor material data value']
	box_ceiling_material_block = options['Box ceiling material block']
	box_ceiling_material_data = options['Box ceiling material data value']
	add_box_signs = options['Add box signs']

	add_credits = True

	command = 'summon minecraft:falling_block ~ ~1 ~ {id:"minecraft:falling_block",Block:"minecraft:redstone_block",Time:1,Passengers:[{id:"minecraft:falling_block",Block:"minecraft:activator_rail",Time:1,Passengers:['
	unformatted_command = command
	first_element = True

	if include_commandblockoutput_command:
		command_part = '{id:"minecraft:commandblock_minecart",Command:"gamerule commandBlockOutput false"}'
		command += '\n\t' + command_part
		unformatted_command += command_part
		first_element = False

	if include_logadmincommands_command:
		if not first_element:
			command += ','
			unformatted_command += ','
		first_element = False
		command_part = '{id:"minecraft:commandblock_minecart",Command:"gamerule logAdminCommands false"}'
		command += '\n\t' + command_part
		unformatted_command += command_part

	if add_initialization_commands:
		file = mcplatform.askOpenFile('Select the text file containing the initialization commands...', False, ['txt'])
		if file is not None:
			input = open(file)
			if input is not None:
				for line in input.read().splitlines():
					if not first_element:
						command += ','
						unformatted_command += ','
					first_element = False
					command_part = '{id:"minecraft:commandblock_minecart",Command:"' + escape_string(line) + '"}'
					command += '\n\t' + command_part
					unformatted_command += command_part
				input.close()

	if include_blocks:
		if include_air:
			air_blocks = []
			for x in xrange(box.minx, box.maxx):
				air_blocks.append([])
				for y in xrange(box.miny, box.maxy):
					air_blocks[x - box.minx].append([])
					for z in xrange(box.minz, box.maxz):
						air_blocks[x - box.minx][y - box.miny].append(True)
			for cuboid in subdivide_in_cuboids(air_blocks, 32768, False, True, False):
				if not first_element:
					command += ','
					unformatted_command += ','
				first_element = False
				if volume(cuboid[0][0], cuboid[0][1], cuboid[0][2], cuboid[1][0], cuboid[1][1], cuboid[1][2]) == 1:
					command_part = '{id:"minecraft:commandblock_minecart",Command:"setblock ~' + str(cuboid[0][0] + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[0][2] + box.minz - execution_center[2]) + ' minecraft:air'
				else:
					command_part = '{id:"minecraft:commandblock_minecart",Command:"fill ~' + str(cuboid[0][0] + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[0][2] + box.minz - execution_center[2]) + ' ~' + str(cuboid[1][0] + box.minx - execution_center[0]) + ' ~' + str(cuboid[1][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[1][2] + box.minz - execution_center[2]) + ' minecraft:air'
				if include_null_block_data:
					command_part += ' 0'
				command_part += '"}'
				command += '\n\t' + command_part
				unformatted_command += command_part

		blocks = []
		for x in xrange(box.minx, box.maxx):
			blocks.append([])
			for y in xrange(box.miny, box.maxy):
				blocks[x - box.minx].append([])
				for z in xrange(box.minz, box.maxz):
					blocks[x - box.minx][y - box.miny].append((level.blockAt(x, y, z), level.blockDataAt(x, y, z), level.tileEntityAt(x, y, z)))
		enqueued = []
		for x in xrange(0, len(blocks)):
			for y in xrange(0, len(blocks[x])):
				for z in xrange(0, len(blocks[x][y])):
					block = blocks[x][y][z]
					if block[0] >= 1:
						for cuboid in subdivide_in_cuboids(blocks, 32768, False, block, (-1, 0, None)):
							if volume(cuboid[0][0], cuboid[0][1], cuboid[0][2], cuboid[1][0], cuboid[1][1], cuboid[1][2]) == 1:
								command_part = '{id:"minecraft:commandblock_minecart",Command:"setblock ~' + str(cuboid[0][0] + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[0][2] + box.minz - execution_center[2]) + ' ' + materials.block_map[block[0]]
							else:
								command_part = '{id:"minecraft:commandblock_minecart",Command:"fill ~' + str(cuboid[0][0] + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[0][2] + box.minz - execution_center[2]) + ' ~' + str(cuboid[1][0] + box.minx - execution_center[0]) + ' ~' + str(cuboid[1][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[1][2] + box.minz - execution_center[2]) + ' ' + materials.block_map[block[0]]
							if include_null_block_data or block[1] != 0 or (block[1] == 0 and block[2] is not None):
								command_part += ' ' + str(block[1])
							if block[2] is not None:
								command_part += ' replace ' + escape_string(nbt_to_string(block[2], nbt_tags_to_ignore))
							command_part += '"}'
							if block[0] not in blocks_to_enqueue:
								if not first_element:
									command += ','
									unformatted_command += ','
								first_element = False
								command += '\n\t' + command_part
								unformatted_command += command_part
							else:
								enqueued.append(command_part)
		for enqueued_command in enqueued:
			if not first_element:
				command += ','
				unformatted_command += ','
			first_element = False
			command += '\n\t' + enqueued_command
			unformatted_command += enqueued_command

	if include_entities:
		for (chunk, slices, point) in level.getChunkSlices(box):
			for entity in chunk.Entities:
				entity_x = entity['Pos'][0].value
				entity_y = entity['Pos'][1].value
				entity_z = entity['Pos'][2].value
				if (entity_x, entity_y, entity_z) in box:
					if not first_element:
						command += ','
						unformatted_command += ','
					first_element = False
					command_part = '{id:"minecraft:commandblock_minecart",Command:"summon ' + str(entity['id'].value) + ' ~' + str((Decimal(entity_x - execution_center[0]) - Decimal('0.5')).normalize()) + ' ~' + str((Decimal(entity_y - execution_center[1]) - Decimal('0.0625')).normalize()) + ' ~' + str((Decimal(entity_z - execution_center[2]) - Decimal('0.5')).normalize()) + ' ' + escape_string(nbt_to_string(entity, nbt_tags_to_ignore)) + '"}'
					command += '\n\t' + command_part
					unformatted_command += command_part

	if generate_surrounding_box:
		if volume(box.minx - 1, box.miny - 1, box.minz - 1, box.maxx, box.maxy, box.maxz) <= 32768:
			if not first_element:
				command += ','
				unformatted_command += ','
			first_element = False
			command_part = '{id:"minecraft:commandblock_minecart",Command:"fill ~' + str(box.minx - 1 - execution_center[0]) + ' ~' + str(box.miny - 1 - execution_center[1]) + ' ~' + str(box.minz - 1 - execution_center[2]) + ' ~' + str(box.maxx - execution_center[0]) + ' ~' + str(box.maxy - execution_center[1]) + ' ~' + str(box.maxz - execution_center[2]) + ' ' + escape_string(box_wall_material_block) + ' ' + str(box_wall_material_data) + ' outline"}'
			command += '\n\t' + command_part
			unformatted_command += command_part
		else:
			wall_blocks = []
			for x in xrange(0, box.maxx - box.minx + 2):
				wall_blocks.append([])
				for y in xrange(0, box.maxy - box.miny):
					wall_blocks[x].append([])
					for z in xrange(0, box.maxz - box.minz + 2):
						if x == 0 or x == box.maxx - box.minx + 1 or z == 0 or z == box.maxz - box.minz + 1:
							wall_blocks[x][y].append(True)
						else:
							wall_blocks[x][y].append(False)
			for cuboid in subdivide_in_cuboids(wall_blocks, 32768, False, True, False):
				if not first_element:
					command += ','
					unformatted_command += ','
				first_element = False
				command_part = '{id:"minecraft:commandblock_minecart",Command:"fill ~' + str(cuboid[0][0] - 1 + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[0][2] - 1 + box.minz - execution_center[2]) + ' ~' + str(cuboid[1][0] - 1 + box.minx - execution_center[0]) + ' ~' + str(cuboid[1][1] + box.miny - execution_center[1]) + ' ~' + str(cuboid[1][2] - 1 + box.minz - execution_center[2]) + ' ' + escape_string(box_wall_material_block)
				if include_null_block_data or box_wall_material_data != 0:
					command_part += ' ' + str(box_wall_material_data)
				command_part += '"}'
				command += '\n\t' + command_part
				unformatted_command += command_part

		if add_box_signs:
			file = mcplatform.askOpenFile('Select the text file containing the signs to put on front of the box...', False, ['txt'])
			if file is not None:
				input = open(file)
				if input is not None:
					signs = OrderedDict()
					signs_line = 0
					coordinate = (0, 0)
					for line in input.read().splitlines():
						if signs_line == 0:
							if line != '':
								coordinates = re.split(r'\s*,\s*', line.strip())
								coordinate = (int(coordinates[0]), int(coordinates[1]))
								signs[coordinate] = []
								signs_line += 1
						else:
							signs[coordinate].append(line)
							signs_line += 1
						if signs_line == 9:
							signs_line = 0

					for coordinate, sign in signs.items():
						if relative_position == 'North':
							world_coordinate = (box.minx - 1 + coordinate[0] - execution_center[0], box.miny - 1 + coordinate[1] - execution_center[1], box.maxz + 1 - execution_center[2])
							sign_data = 3
						elif relative_position == 'East':
							world_coordinate = (box.minx - 2 - execution_center[0], box.miny - 1 + coordinate[1] - execution_center[1], box.minz - 1 + coordinate[0] - execution_center[2])
							sign_data = 4
						elif relative_position == 'South':
							world_coordinate = (box.maxx - coordinate[0] - execution_center[0], box.miny - 1 + coordinate[1] - execution_center[1], box.minz - 2 - execution_center[2])
							sign_data = 2
						else:
							world_coordinate = (box.maxx + 1 - execution_center[0], box.miny - 1 + coordinate[1] - execution_center[1], box.maxz - coordinate[0] - execution_center[2])
							sign_data = 5

						if not first_element:
							command += ','
							unformatted_command += ','
						first_element = False
						command_part = '{id:"minecraft:commandblock_minecart",Command:"setblock ~' + str(world_coordinate[0]) + ' ~' + str(world_coordinate[1]) + ' ~' + str(world_coordinate[2]) + ' minecraft:wall_sign ' + str(sign_data) + ' replace {'
						for i in xrange(0, min(4, len(sign))):
							sign_text = sign[i]
							sign_command = sign[i + 4] if len(sign) > i + 4 and len(sign[i + 4]) > 0 else ''
							if i > 0:
								command_part += ','
							command_part += 'Text' + str(i + 1) + r':\"'
							if sign_text.startswith('{'):
								if sign_command != '':
									command_part += escape_string(escape_string('{"text":"","extra":[' + sign_text + ']'))
								else:
									command_part += escape_string(escape_string(sign_text))
							elif sign_text.startswith('['):
								if sign_command != '':
									command_part += escape_string(escape_string('{"text":"","extra":' + sign_text))
								else:
									command_part += escape_string(escape_string(sign_text))
							elif sign_text.startswith('"'):
								if sign_command != '':
									command_part += escape_string(escape_string('{"text":' + sign_text))
								else:
									command_part += escape_string(escape_string(sign_text))
							else:
								if sign_command != '':
									command_part += escape_string(escape_string('{"text":"' + escape_string(sign_text) + '"'))
								else:
									command_part += escape_string(escape_string('"' + sign_text + '"'))
							if sign_command != '':
								command_part += escape_string(escape_string(',"clickEvent":{"action":"run_command","value":"' + escape_string(sign_command) + '"}}'))
							command_part += r'\"'
						command_part += '}"}'
						command += '\n\t' + command_part
						unformatted_command += command_part

		floor_ceiling_blocks = []
		for x in xrange(0, box.maxx - box.minx + 2):
			floor_ceiling_blocks.append([])
			floor_ceiling_blocks[x].append([])
			for z in xrange(0, box.maxz - box.minz + 2):
				floor_ceiling_blocks[x][0].append(True)
		for cuboid in subdivide_in_cuboids(floor_ceiling_blocks, 32768, False, True, False):
			if not first_element:
				command += ','
				unformatted_command += ','
			first_element = False
			command_part = '{id:"minecraft:commandblock_minecart",Command:"fill ~' + str(cuboid[0][0] - 1 + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] - 1 + box.miny - execution_center[1]) + ' ~' + str(cuboid[0][2] - 1 + box.minz - execution_center[2]) + ' ~' + str(cuboid[1][0] - 1 + box.minx - execution_center[0]) + ' ~' + str(cuboid[1][1] - 1 + box.miny - execution_center[1]) + ' ~' + str(cuboid[1][2] - 1 + box.minz - execution_center[2]) + ' ' + escape_string(box_floor_material_block)
			if include_null_block_data or box_floor_material_data != 0:
				command_part += ' ' + str(box_floor_material_data)
			command_part += '"}'
			command += '\n\t' + command_part
			unformatted_command += command_part

			command_part = '{id:"minecraft:commandblock_minecart",Command:"fill ~' + str(cuboid[0][0] - 1 + box.minx - execution_center[0]) + ' ~' + str(cuboid[0][1] + box.maxy - execution_center[1]) + ' ~' + str(cuboid[0][2] - 1 + box.minz - execution_center[2]) + ' ~' + str(cuboid[1][0] - 1 + box.minx - execution_center[0]) + ' ~' + str(cuboid[1][1] + box.maxy - execution_center[1]) + ' ~' + str(cuboid[1][2] - 1 + box.minz - execution_center[2]) + ' ' + escape_string(box_ceiling_material_block)
			if include_null_block_data or box_ceiling_material_data != 0:
				command_part += ' ' + str(box_ceiling_material_data)
			command_part += '"}'
			command += ',\n\t' + command_part
			unformatted_command += ',' + command_part

	if add_finalization_commands:
		file = mcplatform.askOpenFile('Select the text file containing the finalization commands...', False, ['txt'])
		if file is not None:
			input = open(file)
			if input is not None:
				for line in input.read().splitlines():
					if not first_element:
						command += ','
						unformatted_command += ','
					first_element = False
					command_part = '{id:"minecraft:commandblock_minecart",Command:"' + escape_string(line) + '"}'
					command += '\n\t' + command_part
					unformatted_command += command_part
				input.close()

	if add_credits:
		if not first_element:
			command += ','
			unformatted_command += ','
		first_element = False
		command_part = '{id:"minecraft:commandblock_minecart",Command:"' + escape_string('tellraw @p {"color":"yellow","text":"Generated with Mamo\'s ","extra":[{"color":"blue","underlined":true,"text":"Structure spawner generator","clickEvent":{"action":"open_url","value":"https://github.com/xMamo/Structure-spawner-generator"},"hoverEvent":{"action":"show_text","value":"Click here if you want this filter too!"}},"."]}') + '"}'
		command += '\n\t' + command_part
		unformatted_command += command_part

	if not first_element:
		command += ','
		unformatted_command += ','
	command_part = r'{id:"minecraft:commandblock_minecart",Command:"setblock ~ ~1 ~ minecraft:command_block 0 replace {auto:1b,Command:\"fill ~ ~-3 ~ ~ ~ ~ minecraft:air'
	if include_null_block_data:
		command_part += ' 0'
	command_part += r'\"}"}'
	command += '\n\t' + command_part
	unformatted_command += command_part
	command_part = '{id:"minecraft:commandblock_minecart",Command:"kill @e[type=minecraft:commandblock_minecart,r=0]"}'
	command += ",\n\t" + command_part + '\n]}]}'
	unformatted_command += "," + command_part + ']}]}'

	if not ignore_maximum_command_block_command_length and len(unformatted_command) > 32500:
		editor.Notify('Unfortunately no command could be generated, as it would be longer than the Command Block command length limit of 32500 characters.')
		return

	command_output = None
	if save_command_to_file:
		output_file = mcplatform.askSaveFile(None, 'Select the text file to which you want to save the command...', 'command.txt', 'Text file (*.txt)\0*.txt\0\0', None)
		if output_file is not None:
			command_output = open(output_file, mode = 'w')

	if save_command_to_file and command_output is not None:
		command_output.write((command + '\n').encode('UTF-8'))
		command_output.flush()
		command_output.close()
	else:
		schematic = MCSchematic((1, 1, 1), None, None, level.materials)
		schematic.setBlockAt(0, 0, 0, 137)
		command_block = TAG_Compound()
		command_block['id'] = TAG_String('minecraft:command_block')
		command_block['x'] = TAG_Int(0)
		command_block['y'] = TAG_Int(0)
		command_block['z'] = TAG_Int(0)
		command_block['Command'] = TAG_String(unformatted_command)
		schematic.addTileEntity(command_block)
		editor.addCopiedSchematic(schematic)