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
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 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)
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)
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)
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):
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)