https://pastein.ru/t/SpV

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

Загрузка данных


from mcpi.minecraft import Minecraft
import mcpi.block as block
import minecraftstuff
import time
import random
import threading

from mcpi import minecraft

# Константы арены
ARENAX = 10
ARENAZ = 20
ARENAY = 3


# Создание арены
def createArena(pos):
    mc = Minecraft.create()

    mc.setBlocks(pos.x - 1, pos.y, pos.z - 1,
                 pos.x + ARENAX + 1, pos.y - 3, pos.z + ARENAZ + 1,
                 block.GRASS.id)

    mc.setBlocks(pos.x - 1, pos.y + 1, pos.z - 1,
                 pos.x + ARENAX + 1, pos.y + ARENAY, pos.z + ARENAZ + 1,
                 block.GLASS.id)
    mc.setBlocks(pos.x, pos.y + 1, pos.z,
                 pos.x + ARENAX, pos.y + ARENAY, pos.z + ARENAZ,
                 block.AIR.id)


def theWall(arenaPos, wallZPos):
    mc = Minecraft.create()

    wallPos = minecraft.Vec3(arenaPos.x, arenaPos.y + 1, arenaPos.z + wallZPos)
    wallShape = minecraftstuff.MinecraftShape(mc, wallPos)

    wallShape.setBlocks(
        0, 1, 0,
        ARENAX, ARENAY - 1, 0,
        block.BRICK_BLOCK.id)

    while not gameOver:
        wallShape.moveBy(0, 1, 0)
        time.sleep(1)
        wallShape.moveBy(0, -1, 0)
        time.sleep(1)


def theRiver(arenaPos, riverZPos):
    mc = Minecraft.create()

    RIVERWIDTH = 4
    BRIDGEWIDTH = 2

    mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos,
                 arenaPos.x + ARENAX, arenaPos.y, arenaPos.z + riverZPos + RIVERWIDTH - 1,
                 block.AIR.id)
    mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos,
                 arenaPos.x + ARENAX, arenaPos.y - 2, arenaPos.z + riverZPos + RIVERWIDTH - 1,
                 block.WATER.id)
    bridgePos = minecraft.Vec3(arenaPos.x, arenaPos.y, arenaPos.z + riverZPos + 1)
    bridgeShape = minecraftstuff.MinecraftShape(mc, bridgePos)

    bridgeShape.setBlocks(
        0, 0, 0,
        BRIDGEWIDTH - 1, 0, RIVERWIDTH - 3,
        block.WOOD_PLANKS.id)

    # Движение моста влево и вправо
    # Сколько шагов между левым и правым краем арены
    steps = ARENAX - BRIDGEWIDTH + 1
    while not gameOver:
        for left in range(0, steps):
            bridgeShape.moveBy(1, 0, 0)
            time.sleep(1)
        for right in range(0, steps):
            bridgeShape.moveBy(-1, 0, 0)
            time.sleep(1)


def theHoles(arenaPos, holesZPos):
    mc = Minecraft.create()

    HOLES = 15
    HOLESWIDTH = 3

    while not gameOver:
        holes = []
        for count in range(0, HOLES):
            x = random.randint(arenaPos.x, arenaPos.x + ARENAX)
            z = random.randint(arenaPos.z + holesZPos, arenaPos.z + holesZPos + HOLESWIDTH)
            holes.append(minecraft.Vec3(x, arenaPos.y, z))

        for hole in holes:
            mc.setBlock(hole.x, hole.y, hole.z, block.WOOL.id, 15)
        time.sleep(0.25)

        for hole in holes:
            mc.setBlocks(hole.x, hole.y, hole.z,
                         hole.x, hole.y - 2, hole.z,
                         block.AIR.id)
        time.sleep(2)

        for hole in holes:
            mc.setBlocks(hole.x, hole.y, hole.z,
                         hole.x, hole.y - 2, hole.z,
                         block.GRASS.id)
        time.sleep(0.25)


def createDiamonds(arenaPos, number):
    pass


mc = Minecraft.create()

gameOver = False

# Арена
arenaPos = mc.player.getTilePos()
createArena(arenaPos)

# Стена
WALLZ = 10

wall_t = threading.Thread(
    target=theWall,
    args=(arenaPos, WALLZ))
wall_t.start()

# Ров
RIVERZ = 4

river_t = threading.Thread(
    target=theRiver,
    args=(arenaPos, RIVERZ))
river_t.start()

# Ямы

HOLESZ = 15

holes_t = threading.Thread(
    target=theHoles,
    args=(arenaPos, HOLESZ))
holes_t.start()