Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.8 kB
1
Indexable
Never
from mcpi.minecraft import Minecraft
import mcpi.block as block
import minecraftstuff as mine
from minecraftstuff import MinecraftDrawing
# import MinecraftDrawing
import math
import time
import collections


from collections.abc import Iterable


collections.Iterable = Iterable

mc = Minecraft.create()
mcdraw = MinecraftDrawing(mc)

def distanceBetweenPoints(pos1, pos2):
    xd = pos2.x - pos1.x
    yd = pos2.y - pos1.y
    zd = pos2.z - pos1.z
    return math.sqrt((xd*xd) + (yd*yd) + (zd*zd))

FAR_AWAY = 15
blockMood = "happy"
friend = mc.player.getTilePos()
friend.x = friend.x + 5
friend.y = mc.getHeight(friend.x, friend.z)  
mc.setBlock(friend.x, friend.y, friend.z, block.DIAMOND_BLOCK.id)

while True:
    pos = mc.player.getTilePos()
    distance = distanceBetweenPoints(pos, friend)  
    if blockMood == "happy":  
        if distance < FAR_AWAY:
            target = pos.clone()
        else:
            blockMood = "sad"
            mc.postToChat("<Бот> Пожалуйста, вернись. Я скучаю по тебе...")
    elif blockMood == "sad":  
        if distance <= 2:
            blockMood = "happy"
            mc.postToChat("<Бот> Юхууу!! Ты вернулся, я иду за тобой!")
    if friend != target:
        line = mcdraw.getLine(friend.x, friend.y, friend.z, target.x, target.y, target.z)
        for nextBlock in line[:-1]:
            mc.setBlock(friend.x, friend.y, friend.z, block.AIR.id)
            friend = nextBlock.clone()  
            friend.y = mc.getHeight(friend.x, friend.z)  
            mc.setBlock(friend.x, friend.y, friend.z, block.CHEST.id )
            time.sleep(0.25)
        target = friend.clone()
        time.sleep(0.25)
Leave a Comment