def __init__(self, mc, pos, maxRadius, minValue, maxValue, blocksToUse=None, angleIncrement=ANGLEINCREMENT): self.mc = mc self.pos = pos self.maxRadius = maxRadius self.minValue = minValue self.maxValue = maxValue #if no blocks to use have been passed, set them to the wool colours if blocksToUse == None: blocksToUse = [] for col in range(0, 15): blocksToUse.append(Block(block.WOOL.id, col)) self.blocksToUse = blocksToUse self.angleIncrement = angleIncrement self.currentBlock = 0 self.angle = 0 #create a dictionary of the lines for the angles in the circle # to keep track of the values so they can be cleared self.lines = {} #create the minecraft drawing object which will be used to draw the lines self.draw = MinecraftDrawing(mc)
def _drop(self, x, y, z, speed): exploded = False while not exploded: self.mc.setBlock(x, y, z, block.TNT.id) sleep(speed) self.mc.setBlock(x, y, z, block.AIR.id) y = y - 1 if self.mc.getBlock(x, y, z) != block.AIR.id: exploded = True self.mc.postToChat("boom") mcdraw = MinecraftDrawing(self.mc) mcdraw.drawSphere(x, y, z, self.blast, block.AIR.id)
def __init__( self, mc, pos, maxRadius, minValue, maxValue, blocksToUse = None, angleIncrement = ANGLEINCREMENT): self.mc = mc self.pos = pos self.maxRadius = maxRadius self.minValue = minValue self.maxValue = maxValue #if no blocks to use have been passed, set them to the wool colours if blocksToUse == None: blocksToUse = [] for col in range(0,15): blocksToUse.append(Block(block.WOOL.id, col)) self.blocksToUse = blocksToUse self.angleIncrement = angleIncrement self.currentBlock = 0 self.angle = 0 #create a dictionary of the lines for the angles in the circle # to keep track of the values so they can be cleared self.lines = {} #create the minecraft drawing object which will be used to draw the lines self.draw = MinecraftDrawing(mc)
def main(): mc = Minecraft.create("192.168.1.10") x, y, z = mc.player.getPos() mc.postToChat(f"drawing! {x} {y} {z}") mc.setBlock(x+2, y, z, 1) for i in range(100): mc.setBlock(SPAWN[0], SPAWN[1]+i, SPAWN[2], 1) mcdraw = MinecraftDrawing(mc) # draw a diagonal line mcdraw.drawLine(SPAWN[0], SPAWN[1], SPAWN[2], SPAWN[0] - 10, SPAWN[1] + 10, SPAWN[2]+10, block.STONE.id) mcdraw.drawSphere(SPAWN[0]+5, SPAWN[1]+80, SPAWN[2]+20, 20, block.GOLD_BLOCK.id)
from mcpi.minecraft import Minecraft from minecraftstuff import MinecraftDrawing from mcpi import block mc=Minecraft.create() pos=mc.player.getPos() x=pos.x y=pos.y z=pos.z blockType=block.WATER mcdrawing=MinecraftDrawing(mc) mcdrawing.drawCircle(x+6, y+10, z, 3, blockType)
import mcpi.minecraft as minecraft import mcpi.block as block from mcpi.minecraft import Vec3 from minecraftstuff import MinecraftDrawing from minecraftstuff import MinecraftShape, ShapeBlock from random import randint from time import sleep mc = minecraft.Minecraft.create() mcDrawing = MinecraftDrawing(mc) def main(): pass main()
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) x, y, z = mc.player.getTilePos() sleep(10) for meow in range(300): sleep(1) #mc.setBlock(x,y,z,meow) md.drawHorizontalCircle(x, meow, z, 10, meow)
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) x, y, z = mc.player.getTilePos() sleep(5) #md.drawHollowSphere(x,y,z,10,24) md.drawSphere(x, y, z, 10, 0) md.drawHollowSphere(x, y + 20, z, 10, 24)
from mcpi.minecraft import Minecraft from minecraftstuff import MinecraftDrawing mc=Minecraft.create() blocktype=103 x,y,z=mc.player.getPos() mcd=MinecraftDrawing(mc) mcd.drawCircle( x+10, y, z, 20,blocktype)
from minecraftstuff import MinecraftDrawing import math import time # функциия котороя определяет расстояние между 2 точками def distanceBetweenPoints(point1, point2): xd = point2.x - point1.x yd = point2.y - point1.y zd = point2.z - point1.z return math.sqrt((xd*xd) + (yd*yd) + (zd*zd)) # Константа расстояния TOO_FAR_AWAY = 15 # Создаём Minecraft для соединение и взаимолдействия с игрой mc = minecraft.Minecraft.create() # Создаём MinecraftDrawing обЪект для доступа к функциям рисования mcdrawing = MinecraftDrawing(mc) # зададим настроение друга 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) # Первая фраза нашего друга mc.postToChat("<block> hello friend!") # Задаем направление движения(координаты) для нашего друга target = friend.clone() while True:
import mcpi.minecraft as minecraft import mcpi.block as block from mcpi.minecraft import Vec3 from minecraftstuff import MinecraftDrawing from minecraftstuff import MinecraftShape, ShapeBlock from random import randint from time import sleep mc = minecraft.Minecraft.create() mcDrawing = MinecraftDrawing(mc) def prepare(): mcDrawing.drawSphere(0, 0, 0, 10, block.SAND) mc.setBlock(4, 3, 1, block.BEDROCK) mc.setBlock(9, 8, 9, block.GLASS) def game(): while True: pass mcDrawing.drawSphere(10, 10, 10, 5, block.DIAMOND_BLOCK) mcDrawing.drawSphere(10, 10, 10, 3, block.AIR) def main(): prepare() #game()
import time import datetime import math def findPointOnCircle(cx, cy, radius, angle): x = cx + math.sin(math.radians(angle)) * radius y = cy + math.cos(math.radians(angle)) * radius x = int(round(x, 0)) y = int(round(y, 0)) return (x, y) mc = Minecraft.create() mcdrawing = MinecraftDrawing(mc) pos = mc.player.getTilePos() clockMiddle = pos clockMiddle.y = clockMiddle.y + 25 CLOCK_RADIUS = 20 HOUR_HAND_LENG = 10 MIN_HAND_LENG = 18 SEC_HAND_LENG = 20 mcdrawing.drawCircle(clockMiddle.x, clockMiddle.y, clockMiddle.z, CLOCK_RADIUS, 57)
from mcpi.minecraft import Minecraft from minecraftstuff import MinecraftDrawing mc = Minecraft.create() import time pos = mc.player.getPos() x = pos.x y = pos.y z = pos.z front = 3 blockType = 1 radius = 5 hight = 6 mcdrawing = MinecraftDrawing(mc) mcdrawing.drawCircle(x + front, y + hight, z + front, radius, blockType)
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) x, y, z = mc.player.getTilePos() sleep(5) h = randint(1, 258) md.drawHollowSphere(x, y, z, 10, 80) md.drawHollowSphere(x, y + 12, z, 8, 80) md.drawHollowSphere(x, y + 22, z, 7, 80) #mc.setBlocks(x,y+2,z,x+10,y+2,z+10,86) md.drawHollowSphere(x, y + 22, z, 6, h)
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) while True: x, y, z = mc.player.getTilePos() blocks = mc.events.pollBlockHits() for block in blocks: bx, by, bz = block.pos x, y, z = mc.player.getTilePos() sleep(5) md.drawHorizontalCircle(x, y, z, 10, 21) md.drawCircle(x, y, z, 10, 21) md.drawHollowSphere(x, y, z, 9, 20)
from mcpi.minecraft import Minecraft from minecraftstuff import MinecraftDrawing from mcpi import block mc = Minecraft.create() import time x, y, z = mc.player.getPos() mcdrawing = MinecraftDrawing(mc) mcdrawing.drawCircle(x, y + 5, z, 5, block.BEDROCK.id)
import path_helper from minecraftstuff import Vec3, MinecraftDrawing, ShapeBlock from mcpi.minecraft import Minecraft #connect to minecraft mc = Minecraft.create() #test MinecraftDrawing #clear area mc.setBlocks(-25, 0, -25, 25, 25, 25, "air") #create drawing object mcDrawing = MinecraftDrawing(mc) #line mcDrawing.drawLine(0,0,-10,-10,10,-5,"stone") #circle mcDrawing.drawCircle(-15,15,-15,10,"WOOD") #sphere mcDrawing.drawSphere(-15,15,-15,5,"OBSIDIAN") #face - solid triangle faceVertices = [] faceVertices.append(Vec3(0,0,0)) faceVertices.append(Vec3(5,10,0)) faceVertices.append(Vec3(10,0,0)) mcDrawing.drawFace(faceVertices, True, "snow_block")
class SpikeyCircle(): """ Draws lines out from the centre, the lenght determines the value, the longer the line the greater the value """ ANGLEINCREMENT = 15 def __init__(self, mc, pos, maxRadius, minValue, maxValue, blocksToUse=None, angleIncrement=ANGLEINCREMENT): self.mc = mc self.pos = pos self.maxRadius = maxRadius self.minValue = minValue self.maxValue = maxValue #if no blocks to use have been passed, set them to the wool colours if blocksToUse == None: blocksToUse = [] for col in range(0, 15): blocksToUse.append(Block(block.WOOL.id, col)) self.blocksToUse = blocksToUse self.angleIncrement = angleIncrement self.currentBlock = 0 self.angle = 0 #create a dictionary of the lines for the angles in the circle # to keep track of the values so they can be cleared self.lines = {} #create the minecraft drawing object which will be used to draw the lines self.draw = MinecraftDrawing(mc) def addValue(self, value): """ Add a single value to the spikey circle ` """ if value > self.maxValue: value = self.maxValue if value < self.minValue: value = self.minValue #has a line already been drawn at this angle if self.angle in self.lines: #clear the line endX = self.lines[self.angle][0] endY = self.lines[self.angle][1] self.draw.drawLine(self.pos.x, self.pos.y, self.pos.z, endX, endY, self.pos.z, block.AIR.id) #calculate the length of the line lineLen = self._calcLength(value) #calculate the new end of the line endX, endY = self._findPointOnCircle(self.pos.x, self.pos.y, self.angle, lineLen) #draw the line self.draw.drawLine(self.pos.x, self.pos.y, self.pos.z, endX, endY, self.pos.z, self.blocksToUse[self.currentBlock].id, self.blocksToUse[self.currentBlock].data) #save the line to the dictionary, so next time we can clear it self.lines[self.angle] = [endX, endY] #increment the angle self._incrementAngle() #increment the block self._incrementBlock() def _incrementBlock(self): #increment the block self.currentBlock += 1 #if its the end, go back to the start if self.currentBlock + 1 > len(self.blocksToUse): self.currentBlock = 0 def _incrementAngle(self): #increment the angle self.angle += self.angleIncrement #if its over 360 go back to the start if self.angle >= 360: self.angle -= 360 def _calcLength(self, value): scale = self.maxValue - self.minValue flatValue = value - self.minValue return int(round((flatValue / scale) * self.maxRadius)) def _findPointOnCircle(self, cx, cy, angle, radius): x = cx + sin(radians(angle)) * radius y = cy + cos(radians(angle)) * radius x = int(round(x, 0)) y = int(round(y, 0)) return (x, y) def clear(self): """ Clears the spikey circle ` """ for angle in self.lines: endX = self.lines[angle][0] endY = self.lines[angle][1] self.draw.drawLine(self.pos.x, self.pos.y, self.pos.z, endX, endY, self.pos.z, block.AIR.id) #reset self.angle = 0 self.currentBlock = 0
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) x, y, z = mc.player.getTilePos() sleep(10) for efsgt in range(5): xw = randint(0, 250) wx = randint(0, 250) rz = randint(0, 50) rx = randint(0, 50) h = mc.getHeight(rx, rz) md.drawHollowSphere(rx, h + 4, rz, 3, wx) mc.setBlocks(rx, h, rz, rx, h + 4, rz, xw) mc.postToChat(rx) mc.postToChat(rz) mc.player.setPos(rx + 2, h, rz) mc.postToChat('tfhfhrrfhf')
from minecraftstuff import MinecraftDrawing, ShapeBlock, Points import mcpi.minecraft as minecraft import mcpi.block as block #connect to minecraft mc = minecraft.Minecraft.create() #test MinecraftDrawing #clear area mc.setBlocks(-25, 0, -25, 25, 25, 25, block.AIR.id) #create drawing object mcDrawing = MinecraftDrawing(mc) #line mcDrawing.drawLine(0,0,-10,-10,10,-5,block.STONE.id) #circle mcDrawing.drawCircle(-15,15,-15,10,block.WOOD.id) #sphere mcDrawing.drawSphere(-15,15,-15,5,block.OBSIDIAN.id) #face - solid triangle faceVertices = [] faceVertices.append(minecraft.Vec3(0,0,0)) faceVertices.append(minecraft.Vec3(5,10,0)) faceVertices.append(minecraft.Vec3(10,0,0)) mcDrawing.drawFace(faceVertices, True, block.SNOW_BLOCK.id)
from mcpi.minecraft import Minecraft from minecraftstuff import MinecraftDrawing logan = Minecraft.create() pos = logan.player.getPos() loganDrawing = MinecraftDrawing(logan) loganDrawing.drawCircle(pos.x, pos.y + 20, pos.z, 9, 11)
from minecraftstuff import MinecraftDrawing from mcpi.minecraft import Minecraft from mcpi import block mc = minecraft.create() pos = mc.player.getTilePos() mcdrawing = MinecraftDrawing(mc) mcdrawing.drawCircle(pos.x, pos.y + 15, pos.z, 10, 57)
class SpikeyCircle(): """ Draws lines out from the centre, the lenght determines the value, the longer the line the greater the value """ ANGLEINCREMENT = 15 def __init__( self, mc, pos, maxRadius, minValue, maxValue, blocksToUse = None, angleIncrement = ANGLEINCREMENT): self.mc = mc self.pos = pos self.maxRadius = maxRadius self.minValue = minValue self.maxValue = maxValue #if no blocks to use have been passed, set them to the wool colours if blocksToUse == None: blocksToUse = [] for col in range(0,15): blocksToUse.append(Block(block.WOOL.id, col)) self.blocksToUse = blocksToUse self.angleIncrement = angleIncrement self.currentBlock = 0 self.angle = 0 #create a dictionary of the lines for the angles in the circle # to keep track of the values so they can be cleared self.lines = {} #create the minecraft drawing object which will be used to draw the lines self.draw = MinecraftDrawing(mc) def addValue(self, value): """ Add a single value to the spikey circle ` """ if value > self.maxValue: value = self.maxValue if value < self.minValue: value = self.minValue #has a line already been drawn at this angle if self.angle in self.lines: #clear the line endX = self.lines[self.angle][0] endY = self.lines[self.angle][1] self.draw.drawLine( self.pos.x, self.pos.y, self.pos.z, endX, endY, self.pos.z, block.AIR.id) #calculate the length of the line lineLen = self._calcLength(value) #calculate the new end of the line endX, endY = self._findPointOnCircle( self.pos.x, self.pos.y, self.angle, lineLen) #draw the line self.draw.drawLine( self.pos.x, self.pos.y, self.pos.z, endX, endY, self.pos.z, self.blocksToUse[self.currentBlock].id, self.blocksToUse[self.currentBlock].data) #save the line to the dictionary, so next time we can clear it self.lines[self.angle] = [endX, endY] #increment the angle self._incrementAngle() #increment the block self._incrementBlock() def _incrementBlock(self): #increment the block self.currentBlock += 1 #if its the end, go back to the start if self.currentBlock + 1 > len(self.blocksToUse): self.currentBlock = 0 def _incrementAngle(self): #increment the angle self.angle += self.angleIncrement #if its over 360 go back to the start if self.angle >= 360: self.angle -= 360 def _calcLength(self, value): scale = self.maxValue - self.minValue flatValue = value - self.minValue return int(round((flatValue / scale) * self.maxRadius)) def _findPointOnCircle(self, cx, cy, angle, radius): x = cx + sin(radians(angle)) * radius y = cy + cos(radians(angle)) * radius x = int(round(x, 0)) y = int(round(y, 0)) return(x,y) def clear(self): """ Clears the spikey circle ` """ for angle in self.lines: endX = self.lines[angle][0] endY = self.lines[angle][1] self.draw.drawLine( self.pos.x, self.pos.y, self.pos.z, endX, endY, self.pos.z, block.AIR.id) #reset self.angle = 0 self.currentBlock = 0
from minecraftstuff import MinecraftDrawing from mcpi.minecraft import Minecraft from mcpi import block #https://minecraft-stuff.readthedocs.io/en/latest/minecraftdrawing.html ## pip install minecraftstuff #Connect to minecraft mc = Minecraft.create() # get the players position pos = mc.player.getTilePos() #Using the Minecraft Drawing API mcdrawing = MinecraftDrawing(mc) # draw a circle with a radius of 10 blocks #mcdrawing.drawCircle(pos.x, pos.y + 15, pos.z, 10, block.WOOD.id) mcdrawing.drawCircle(pos.x+10, pos.y+5, pos.z+10, 5, block.WOOD.id)
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) x,y,z = mc.player.getTilePos() sleep(5) #md.drawHorizontalCircle(x,y,z,10,21) #md.drawCircle(x,y,z,10,21) #md.drawHollowSphere(x,y,z,9,20) md.drawCircle(x+10,y-1,z,10,67) md.drawCircle(x+10,y-1,z+5,7,23) md.drawCircle(x+10,y-1,z+10,5,45) md.drawCircle(x+10,y-1,z+15,3,89) md.drawCircle(x+10,y-1,z+20,1,37)
os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) from minecraftstuff import MinecraftDrawing, ShapeBlock, Points import mcpi.minecraft as minecraft import mcpi.block as block # Connect to minecraft server 127.0.0.1 as player 'steve' mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve") mc.player.setPos(-25, 0, -25) #clear area mc.setBlocks(-25, 0, -25, 25, 25, 25, block.AIR.id) #create drawing object mcDrawing = MinecraftDrawing(mc) #line mcDrawing.drawLine(0, 0, -10, -10, 10, -5, block.STONE.id) #circle mcDrawing.drawCircle(-15, 15, -15, 10, block.WOOD.id) #sphere mcDrawing.drawSphere(-15, 15, -15, 5, block.OBSIDIAN.id) #face - solid triangle faceVertices = [] faceVertices.append(minecraft.Vec3(0, 0, 0)) faceVertices.append(minecraft.Vec3(5, 10, 0)) faceVertices.append(minecraft.Vec3(10, 0, 0))
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) while True: x, y, z = mc.player.getTilePos() blocks = mc.events.pollBlockHits() for block in blocks: bx, by, bz = block.pos x, y, z = mc.player.getTilePos() sleep(5) md.drawHollowSphere(x, y, z, 8, 166) md.drawHollowSphere(x, y, z, 9, 10) md.drawHollowSphere(x, y, z, 10, 166)
from mcpi.minecraft import Minecraft from time import sleep from random import randint from minecraftstuff import MinecraftDrawing print("hi ok") mc = Minecraft.create() md = MinecraftDrawing(mc) x, y, z = mc.player.getTilePos() print(x) sleep(10) mc.setBlocks(310, 60, 240, 550, 60, 390, 2)
from mcpi.minecraft import Minecraft from mcpi import block from minecraftstuff import MinecraftDrawing #pip install minecraftstuff mc = Minecraft.create() mcdraw = MinecraftDrawing(mc) # draw a diagonal line mcdraw.drawLine(0, 0, 0, 10, 10, 10, block.STONE.id)