def connect(self, ip="raspberrypi.local"):
     # 连通性?ping
     self.mc = minecraft.Minecraft.create(address=ip)  # 使用 Scratch 设置
     pos = self.mc.player.getTilePos()
     #Using the Minecraft Turtle
     self.mcTurtle = MinecraftTurtle(self.mc, pos)
     if self.mc:
         if self.node:
             node.pub_notification("Minecraf Connected!",
                                   type="SUCCESS")  # 由一个积木建立连接到时触发
         self.is_connected = True
         return True
Пример #2
0
from mcpi.minecraft import Minecraft
from mcpi import block
from minecraftstuff import MinecraftTurtle
#from celAutomataRules import applyRule, printLine, printStart
import celAutomataRules

mc = Minecraft.create()
pos = mc.player.getPos()

terrapin = MinecraftTurtle(mc, pos)

terrapin.fly()
terrapin.speed(0)
#terrapin.penblock(3)

arr = []
celAutomataRules.fillWithZeros(arr, 30)
arr.append(1)
celAutomataRules.fillWithZeros(arr, 30)

update_arr = []

celAutomataRules.fillWithZeros(update_arr, len(arr))

for i in range(len(arr)):
    celAutomataRules.printLine(arr, terrapin)
    terrapin.setz(pos.z + 1)  # next line

    celAutomataRules.arr1ToArr2(arr, update_arr)
    arr = list(update_arr)
Пример #3
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff import MinecraftTurtle

mc = Minecraft.create()
diamond = MinecraftTurtle(mc)
diamond.setx(0)
diamond.sety(56)
diamond.setz(-47)
diamond.left(90)
diamond.penblock(50)
diamond.forward(51)
Пример #4
0
sys.path.append(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

# Minecraft Turtle Example
from minecraftstuff import MinecraftTurtle
from mcpi import minecraft

# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")

# get players position
pos = mc.player.getPos()

# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)

turtle.speed(10)

# draw a square
turtle.forward(10)
turtle.right(90)
turtle.forward(10)
turtle.right(90)
turtle.forward(10)
turtle.right(90)
turtle.forward(10)

# draw a square on the floor
turtle.walk()
turtle.forward(11)
Пример #5
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond = MinecraftTurtle(mc)
diamond.setx(201)
diamond.sety(71)
diamond.setz(102)

diamond.speed(10)
diamond.penblock(152)
diamond.forward(5)
Пример #6
0
from minecraftstuff import MinecraftTurtle
import mcpi.minecraft as minecraft
import mcpi.block as block

# connect to minecraft
mc = minecraft.Minecraft.create()
pos = mc.player.getTilePos()
print(pos)
# create minecraft turtle
steve = MinecraftTurtle(mc, pos)

# tests
# draw a pentagon at different speeds
steve.forward(5)
steve.right(72)
steve.speed(8)
steve.forward(5)
steve.right(72)
steve.speed(10)
steve.forward(5)
steve.right(72)
steve.speed(0)
steve.forward(5)
steve.right(72)
steve.forward(5)

# change pen
steve.penblock(block.WOOL.id, 0)

# backward
steve.speed(6)
Пример #7
0
def create_arch(playerInfo, turtleX, turtleY, turtleZ, archX):
    currentPlayerPosition = playerInfo[0].entity.getPos(playerInfo[1])

    skippy = MinecraftTurtle(playerInfo[0], currentPlayerPosition)
    skippy.penblock(block.SNOW_BLOCK.id, 1)
    skippy.speed(10)

    skippy.setposition(turtleX + archX - 1, turtleY, turtleZ - 1)
    skippy.up(90)
    skippy.forward(8)
    skippy.down(90)
    skippy.right(90)
    skippy.forward(11)
    skippy.down(90)
    skippy.forward(8)
    skippy.up(180)
    skippy.forward(8)
from mcpi.minecraft import *
from mcpi.block import *

from minecraftstuff import MinecraftTurtle

mc = Minecraft.create()
pos = mc.player.getTilePos()
pos.y += 1

turtle = MinecraftTurtle(mc, pos)

turtle.forward(5)
turtle.right(90)
turtle.forward(5)
turtle.right(90)
turtle.forward(5)
turtle.right(90)
turtle.forward(5)
Пример #9
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff  import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond =  MinecraftTurtle(mc)
diamond.setx(177)
diamond.sety(69)
diamond.setz(78)

diamond.speed(10)
diamond.penblock(152)
diamond.forward(1000)
diamond.left(180)
diamond.sety(70)
diamond.penblock(27)

diamond.forward(1000)
        t.down(40)
        t.right(90)
        tree(branchLen - 2, t)

        t.up(20)

        # go back
        # t.backward(branchLen)
        # for performance - rather than going back over every line
        t.setposition(x, y, z)


# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")

# get players position
pos = mc.player.getPos()

# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)

# point up
turtle.setverticalheading(90)

# set speed
turtle.speed(0)

# call the tree fractal
tree(20, turtle)
Пример #11
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond = MinecraftTurtle(mc)
diamond.setx(144)
diamond.sety(65)
diamond.setz(126)
diamond.left(90)
diamond.left(90)
diamond.penblock(133)
diamond.forward(9)
diamond.left(90)
diamond.forward(1)
diamond.left(90)
diamond.forward(9)
Пример #12
0
# These two lines are because of the folder the demos are located in, and aren't normally necessary
import os.path, sys
sys.path.append(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

# Minecraft Turtle Example - Crazy Pattern
from minecraftstuff import MinecraftTurtle
from mcpi import minecraft
from mcpi import block

# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")

# get players position
pos = mc.player.getPos()

# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)

turtle.penblock(block.WOOL.id, 11)
turtle.speed(10)

for step in range(0, 50):
    turtle.forward(50)
    turtle.right(123)
Пример #13
0
# These two lines are because of the folder the demos are located in, and aren't normally necessary
import os.path, sys
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

#Minecraft Turtle Example - Circle
from minecraftstuff import MinecraftTurtle
from mcpi import minecraft

# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")

# get players position
pos = mc.player.getPos()

# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)
turtle.speed(10)
for step in range(0, 100):
    turtle.right(5)
    turtle.forward(2)
Пример #14
0
from mcpi.minecraft import Minecraft
from mcpi import block
from minecraftstuff import MinecraftTurtle

mc = Minecraft.create()
pos = mc.player.getTilePos()

# create minecraft turtle
steve = MinecraftTurtle(mc, pos)

# draw a pentagon
steve.forward(5)
steve.right(72)
steve.forward(5)
steve.right(72)
steve.forward(5)
steve.right(72)
steve.forward(5)
steve.right(72)
steve.forward(5)
import path_helper

from mcpi.minecraft import Minecraft
from minecraftstuff import MinecraftTurtle

# connect to minecraft
mc = Minecraft.create()
pos = mc.player.getTilePos()
print(pos)
# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)

# tests
# draw a pentagon at different speeds
turtle.forward(5)
turtle.right(72)
turtle.speed(8)
turtle.forward(5)
turtle.right(72)
turtle.speed(10)
turtle.forward(5)
turtle.right(72)
turtle.speed(0)
turtle.forward(5)
turtle.right(72)
turtle.forward(5)

# change pen
turtle.penblock("white_wool")

# backward
Пример #16
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff  import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond =  MinecraftTurtle(mc)

#орога
diamond.setx(201)
diamond.sety(71)
diamond.setz(102)

diamond.speed(10)
diamond.penblock(152)
diamond.forward(5)
#diamond.left(90)

diamond.up(35)# вверх
diamond.forward(10)
diamond.right(90)
diamond.forward(7)
diamond.right(90)
diamond.forward(15)
diamond.down(35)# ровно
diamond.down(35)#вниз
diamond.forward(34)
diamond.right(90)
diamond.up(35)# ровно
diamond.up(35)# вверх
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

# Minecraft Turtle Example
# Ported from the scratch turtle project in "Adventures in Raspberry Pi"
from minecraftstuff import MinecraftTurtle
from mcpi import minecraft
from mcpi import block

# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")

# get players position
pos = mc.player.getPos()

# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)
turtle.speed(0)
turtle.setheading(90)
NumberOfSides = 5
Angle = 360 / NumberOfSides
SideLength = 20
WoolColour = 0

for count in range(24):
    for side in range(NumberOfSides):
        turtle.forward(SideLength)
        turtle.right(Angle)
    turtle.right(15)
    WoolColour += 1
    if WoolColour > 15:
        WoolColour = 0
Пример #18
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff  import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond =  MinecraftTurtle(mc)
diamond.setx(181)
diamond.sety(65)
diamond.setz(68)
diamond.up(34)
diamond.speed(10)

dlina = 150

#ступеньки
diamond.penblock(89)
diamond.forward(dlina)

#факела
diamond.setposition(181, 66, 68)
diamond.penblock(50)
diamond.forward(dlina)

#воздух
diamond.setposition(181, 67, 68)
diamond.penblock(0)
diamond.forward(dlina)
Пример #19
0
sys.path.append(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

# Minecraft Turtle Example
from minecraftstuff import MinecraftTurtle
from mcpi import minecraft
from mcpi import block

# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")

# get players position
pos = mc.player.getPos()

# create minecraft turtle
turtle = MinecraftTurtle(mc, pos)

turtle.speed(0)
turtle.penblock(block.WOOL.id, 14)
S = 50
for j in range(0, 20):
    turtle.up(j * 10)
    turtle.forward(S)

    turtle.left(90)
    turtle.down(j * 10)
    turtle.forward(S)

    turtle.left(90)
    turtle.down(j * 10)
    turtle.forward(S)
Пример #20
0
from minecraftstuff import MinecraftTurtle
from mcpi.minecraft import Minecraft
from usernames import USERNAME
# test code to be deleted later
mc = Minecraft.create("localhost", 4711)
myId = mc.getPlayerEntityId(USERNAME)
myPos = mc.entity.getPos(myId)
turtle = MinecraftTurtle(mc, myPos)


# helper methods
def line(turtle, x, y, z, units):
    turtle.setposition(x, y, z)
    turtle.forward(units)


def a(turtle, x, y, z):
    # two sideways lines
    turtle.right(90)
    line(turtle, x, y + 2, z, 4)
    line(turtle, x, y + 4, z, 4)
    turtle.left(90)

    # legs
    turtle.up(90)
    line(turtle, x, y, z + 4, 4)
    line(turtle, x, y, z, 4)
    turtle.down(90)


def r(turtle, x, y, z):
Пример #21
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond = MinecraftTurtle(mc)
diamond.setx(201)
diamond.sety(71)
diamond.setz(102)

diamond.speed(10)
diamond.penblock(152)
diamond.forward(5)
#diamond.left(90)

diamond.up(35)
diamond.forward(10)
diamond.right(90)
diamond.forward(7)
diamond.right(90)
diamond.forward(15)
diamond.down(35)
diamond.forward(15)

diamond.left(180)
diamond.sety(89)
diamond.penblock(27)
diamond.forward(217)
diamond.right(90)
diamond.forward(1468)
Пример #22
0
from mcpi.minecraft import Minecraft
from time import sleep
from random import randint
from minecraftstuff import MinecraftTurtle
print("hi ok")
mc = Minecraft.create()
diamond = MinecraftTurtle(mc)
diamond.setx(177)
diamond.sety(88)
diamond.setz(79)

diamond.speed(10)
diamond.penblock(152)
diamond.forward(1468)
diamond.left(90)
diamond.forward(217)
diamond.left(180)
diamond.sety(89)
diamond.penblock(27)
diamond.forward(217)
diamond.right(90)
diamond.forward(1468)