https://pastein.ru/t/XjX

  скопируйте уникальную ссылку для отправки


from mcpi.minecraft import Minecraft
from collections.abc import Iterable

import mcpi.block as block
import glob
import time
import random
import collections

collections.Iterable = collections.abc.Iterable
mc = Minecraft.create()

SIZEX = 10
SIZEY = 10
SIZEZ = 10
roomx = 1
roomy = 1
roomz = 1


def buildRoom(x, y, z):
    global roomx, roomy, roomz
    roomx = x
    roomy = y
    roomz = z
    mc.setBlocks(roomx, roomy, roomz,
                 roomx + SIZEX + 1, roomy + SIZEY + 1, roomz + SIZEZ + 1, block.GLASS.id)
    mc.setBlocks(roomx + 1, roomy + 1, roomz,
                 roomx + SIZEX, roomy + SIZEY, roomz + SIZEZ, block.AIR.id)


def demolishRoom():
    mc.setBlocks(roomx, roomy, roomz,
                 roomx + SIZEX + 1, roomy + SIZEY + 1, roomz + SIZEZ + 1, block.AIR.id)


def cleanRoom():
    mc.setBlocks(roomx + 1, roomy + 1, roomz + 1,
                 roomx + SIZEX, roomy + SIZEY, roomz + SIZEZ, block.AIR.id)


def listFiles():
    print("\nФАЙЛЫ:")
    files = glob.glob("*.csv")
    for filename in files:
        print(filename)
    print("\n")


def scan3D(filename, originx, originy, originz):
    f = open(filename, "w")
    f.write(str(SIZEX) + "," + str(SIZEY) + "," + str(SIZEZ) + "\n")
    for y in range(SIZEY):
        mc.postToChat("Cканирование:" + str(y))
        f.write("\n")
        for x in range(SIZEX):
            line = ""
            for z in range(SIZEZ):
                blockid = mc.getBlock(originx + x, originy + y, originz + z)
                if line != "":
                    line = line + ","
                line = line + str(blockid)
            f.write(line + "\n")
    f.close()


def print3D(filename, originx, originy, originz):
    f = open(filename, "r")
    lines = f.readlines()
    coords = lines[0].split(",")
    sizex = int(coords[0])
    sizey = int(coords[1])
    sizez = int(coords[2])
    lineidx = 1
    for y in range(sizey):
        mc.postToChat("Печать:" + str(y))
        lineidx = lineidx + 1
        for x in range(sizex):
            line = lines[lineidx]
            lineidx = lineidx + 1
            data = line.split(",")
            for z in range(sizez):
                blockid = int(data[z])
                mc.setBlock(originx + x, originy + y, originz + z, blockid)


def menu():
    while True:
        print("МЕНЮ ДУБЛИКАТОРА")
        print(" 1. ПОСТРОИТЬ принтер")
        print(" 2. СПИСОК файлов")
        print(" 3. СКАНИРОВАТЬ и сохранить в файл")
        print(" 4. ЗАГРУЗИТЬ из файла в принтер")
        print(" 5. РАСПЕЧАТАТЬ из принтера рядом с игроком используя player.pos")
        print(" 6. ОЧИСТИТЬ принтер")
        print(" 7. РАЗРУШИТЬ принтер")
        print(" 8. ВЫХОД")
        choice = int(input("пожалуйста, выберите: "))
        if choice < 1 or choice > 8:
            print("Извините, пожалуйста, выберите число от 1 до 8")
        else:
            return choice


anotherGo = True

while anotherGo:
    choice = menu()
    if choice == 1:
        pos = mc.player.getTilePos()
        buildRoom(pos.x, pos.y, pos.z)
    elif choice == 2:
        listFiles()
    elif choice == 3:
        filename = input("имя файла?")
        scan3D(filename, roomx + 1, roomy + 1, roomz + 1)
    elif choice == 4:
        filename = input("имя файла?")
        print3D(filename, roomx + 1, roomy + 1, roomz + 1)
    elif choice == 5:
        scan3D("scantemp", roomx + 1, roomy + 1, roomz + 1)
        pos = mc.player.getTilePos()
        print3D("scantemp", pos.x + 1, pos.y, pos.z + 1)
    elif choice == 6:
        cleanRoom()
    elif choice == 7:
        demolishRoom()
    elif choice == 8:
        anotherGo = False