def draw_circle(mc: minecraft.Minecraft, center, radius, block=block.STONE, start_angle=0, stop_angle=np.pi * 2, steps=None): """Draw a horizontal circle around center with radius""" x, y, z = center steps = steps or radius * 20 def coord(angle): return ( x + (np.sin(angle) * radius), y, z + (np.cos(angle) * radius), ) positions = [ coord(angle) for angle in np.arange(0, 2 * np.pi, (2 * np.pi) / (steps)) ] for (x, y, z) in positions: print([round(x), round(y), round(z)]) mc.setBlock( x, y, z, block, )
def __decorate(self, mc: mmc.Minecraft): if random.random() < 0.5: mc.setBlock(self.bottom.up(), block.TORCH.id) elif random.random() < 0.2: mc.setBlock(self.bottom, block.GLOWSTONE_BLOCK.id) elif random.random() < 0.1: mc.setBlock(self.bottom.down(), block.OBSIDIAN.id) mc.setBlock(self.bottom, block.LAVA.id)
def __door(self, mc: mmc.Minecraft, dir: str, type: Gate): DOORS = {Gate.ACA: block.DOOR_ACACIA, Gate.BIR: block.DOOR_BIRCH, Gate.DAR: block.DOOR_DARK_OAK, Gate.JUN: block.DOOR_JUNGLE, Gate.SPR: block.DOOR_SPRUCE, Gate.WOO: block.DOOR_WOOD} if type == Gate.SEP: return if dir == 'b': pos = self.bottom else: pos = self.bottom.__getattribute__(dir)(self.height if dir == 't' else self.length // 2) if type == Gate.AIR or dir == 'n' or dir == 'w': mc.setBlock(pos.up(), block.AIR.id) mc.setBlock(pos.up(2), block.AIR.id) else: mc.setBlock(pos.up(), DOORS[type].id, 0) # Lower part mc.setBlock(pos.up(2), DOORS[type].id, 8) # Upper part
"""changes the x and z variables for a block. If the block in front of the block is less than 2 blocks higher, it will move forward; otherwise it will try to move left, than backward, then finally right. """ x = pos.x y = pos.y z = pos.z currentHeight = mc.getHeight( x, z, ) - 1 forwardHeight = mc.getHight(x + 1, z) rightHeight = mc.getHeight(x, z + 1) backwardHeight = mc.getHeight(s, z + 1) leftHeight = mc.getHeight(x, z - 1) if forwardHeight - currentHeight < 3: x += 1 elif rightHeight - currentHeight < 3: z += 1 elif leftHeight - currentHeight < 3: z -= 1 elif backwardHeight - currentHeight < 3: x -= 1 y = mc.getHeight(x, z) while True: calculateMove() mc.setBlock(x, y, z, 103) time.sleep(1) mc.setBlock(x, y, z, 0)
from mcpi.minecraft import Minecraft as mc import time time.sleep(5) mcs = mc.create() x, y, z = mcs.player.getTilePos() s = 40 mc.setBlock(x + s, y - s, z + s, x - s, y, z - s, 0)