コード例 #1
0
ファイル: minecraftstuff.py プロジェクト: liviuq/mcpi
 def __init__(self, mc, position=minecraft.Vec3(0, 0, 0)):
     # set defaults
     self.mc = mc
     # start position
     self.startposition = position
     # set turtle position
     self.position = position
     # set turtle angles
     self.heading = 0
     self.verticalheading = 0
     # set pen down
     self._pendown = True
     # set pen block to black wool
     self._penblock = block.Block(block.WOOL.id, 15)
     # flying to true
     self.flying = True
     # set speed
     self.turtlespeed = 6
     # create turtle
     self.showturtle = True
     # create drawing object
     self.mcDrawing = MinecraftDrawing(self.mc)
     # set turtle block
     self.turtleblock = block.Block(block.DIAMOND_BLOCK.id)
     # draw turtle
     self._drawTurtle(int(self.position.x), int(self.position.y), int(self.position.y))
コード例 #2
0
def main():

    # for Mossy brick stone
    start_x = -2447
    start_y = 130
    start_z = -1103

    length = 30
    wide = 30
    tall = 30
    ID = block.Block(98,1)
    fill(start_x, start_y, start_z, length, tall, wide, ID)
    

    # for Brick blocks
    start_x = -2428
    start_y = 130
    start_z = -1160
   
    length = 30
    wide = -30
    tall = 30
    ID = block.BRICK_BLOCK
    fill(start_x, start_y, start_z, length, tall, wide, ID)
    mc.postToChat("END")
コード例 #3
0
 def penblock(self, blockId, blockData=0):
     """
     set the block the turtle uses as its pen.
     :param int blockType:
         The block id.
     :param int blockData:
         The block data value, defaults to ``0``.
     """
     self._penblock = block.Block(blockId, blockData)
コード例 #4
0
 def __init__(self, x, y, z, blockType, blockData=0):
     #persist data
     self.blockType = blockType
     self.blockData = blockData
     #store the positions
     # relative pos - block position relatively to other shape blocks
     self.relativePos = minecraft.Vec3(x, y, z)
     # actual pos - actual block position in the world
     self.actualPos = minecraft.Vec3(x, y, z)
     # the mc block object
     self.mcBlock = block.Block(blockType, blockData)
コード例 #5
0
ファイル: main.py プロジェクト: xjq-mc/robot_mc
def prepare(name, r):
    mc.postToChat('Clear some space for class')
    my_id = mc.getPlayerEntityId(name)
    my_tilepos = mc.entity.getTilePos(my_id)
    x = int(my_tilepos.x)
    y = int(my_tilepos.y)
    z = int(my_tilepos.z)
    x0 = x - r
    z0 = z - r
    y0 = 0
    x1 = x + r
    z1 = z + r
    y1 = y + 100
    mc.setBlocks(x0, y0, z0, x1, y1, z1, block.Block(0))
コード例 #6
0
ファイル: main.py プロジェクト: xjq-mc/robot_mc
def pyramid(name, n):
    mc.postToChat('Create a pyramid')
    my_id = mc.getPlayerEntityId(name)
    my_tilepos = mc.entity.getTilePos(my_id)
    x = int(my_tilepos.x)
    y = int(my_tilepos.y)
    z = int(my_tilepos.z)
    r = n * 2 + 1
    x_int = x + r
    z_int = z + r
    for i in range(n):
        l = 2 * (n - i) + 1
        for j in range(l):
            for k in range(l):
                mc.setBlock(x_int - k - i, y + i, z_int - j - i,
                            block.Block(24))
コード例 #7
0
ファイル: scratchplug.py プロジェクト: jrmhaig/rube-mc-pi
    def receive_from_scratch(self, queue):
        """Look for a "x,y" broadcast and convert to a block.
        If a broadcast is received that doesn't parse into x,y then leave the
        state unchanged.
        """
        self.from_scratch = None
        received = self.scratch_link.scratch_connection.receive()[1]
        try:
            id, data = received.split(",")
            _block = block.Block(int(id), int(data))
        except ValueError:
            #Assume that the broadcast wasn't intended as a block change
            print("Unparsable broadcast:" + received)
            _block = None

        if _block:
            queue.put(_block)
コード例 #8
0
    def __init__(self, x, y, z, blockType, blockData=0, tag=""):
        #persist data
        self.blockType = blockType
        self.blockData = blockData

        #store the positions
        # original pos
        self.originalPos = minecraft.Vec3(x, y, z)
        # relative pos - block position relatively to other shape blocks
        self.relativePos = minecraft.Vec3(x, y, z)
        # actual pos - actual block position in the world
        self.actualPos = minecraft.Vec3(x, y, z)

        #the tag system is used to give a particular block inside a shape meaning
        # e.g. for an animal shape you could tag the block which is its head
        self.tag = tag

        # the mc block object
        self.mcBlock = block.Block(blockType, blockData)
コード例 #9
0
def buildBlocks(card):
    playerPos = mc.player.getTilePos()
    #angle = radians(mc.player.getRotation()) #the X is -90 degrees facing axis Z
    px = playerPos.x
    py = playerPos.y
    pz = playerPos.z
    mc.player.setPos(px,py + DEPTH, pz)
    #random color for the WOOL block
    rBlock = block.Block(35, random.randint(1,15))
    for i, row in enumerate(card):
        for j, col in enumerate(row):
            if col == 'X':
                blockType = rBlock
            else:
                blockType = GAP
            for c in range(DEPTH):
                mc.setBlock(px + j - 4, py + c, pz + i - 4, blockType)
        if i >= 7:
            break # ignore mirror test data at end of card buffer
コード例 #10
0
ファイル: main.py プロジェクト: xjq-mc/robot_mc
def ball(name, r):
    mc.postToChat('Create a ball')
    my_id = mc.getPlayerEntityId(name)
    my_tilepos = mc.entity.getTilePos(my_id)
    x = int(my_tilepos.x)
    y = int(my_tilepos.y)
    z = int(my_tilepos.z)
    x_int = x - r
    z_int = z + 2 * r + 5
    y_int = 0
    x_c = x
    y_c = r
    z_c = z + r + 5
    for i in range(r * 2):
        for j in range(r * 2):
            for k in range(r * 2):
                if ((x_int + k - x_c)**2 + (y_int + i - y_c)**2 +
                    (z_int - j - z_c)**2) <= r**2:
                    mc.setBlock(x_int + k, y_int + i, z_int + j,
                                block.Block(1))
コード例 #11
0
ファイル: elka.py プロジェクト: BogdanPohiluk2008/Hello-World
def elka():
    block.Block(17, 1)
    mc.setBlocks(0, 170, 0, 0, 164, 0, 17)
    mc.setBlocks(0, 171, 0, 0, 173, 0, 41, 29)
    mc.setBlock(1, 172, -0, 41, 29)
    mc.setBlock(-1, 172, -0, 41, 29)
    mc.setBlock(-1, 170, -0, 133, 85)
    mc.setBlock(1, 170, -0, 133, 85)
    mc.setBlock(0, 170, -1, 133, 85)
    mc.setBlock(0, 170, 1, 133, 85)
    mc.setBlock(0, 169, 2, 133, 85)
    mc.setBlock(0, 169, -2, 133, 85)
    mc.setBlock(2, 169, 0, 133, 85)
    mc.setBlock(-2, 169, 0, 133, 85)
    mc.setBlock(-3, 168, 0, 133, 85)
    mc.setBlock(0, 168, -3, 133, 85)
    mc.setBlock(3, 168, 0, 133, 85)
    mc.setBlock(0, 168, 3, 133, 85)
    mc.setBlocks(50, 163, 0, 0, 163, 50, 2)
    while True:
        mc.setBlock(-2, 169, 0, 57)
        time.sleep(2)
        mc.setBlock(-2, 169, 0, 10)
        time.sleep(2)
コード例 #12
0
 def test_iteration(self):
     data = (7, 8)
     for i, x in enumerate(block.Block(7, 8)):
         assert x == data[i]
コード例 #13
0
ファイル: pyramid.py プロジェクト: xjq-mc/robot_mc
import mcpi.minecraft as minecraft
import mcpi.block as block

server = 'mc.xjqpro.com'
me = 'your ID'
mc = minecraft.Minecraft.create(server)

my_id = mc.getPlayerEntityId(me)
my_tilepos = mc.entity.getTilePos(my_id)
x = int(my_tilepos.x)
y = int(my_tilepos.y)
z = int(my_tilepos.z)
r = n * 2 + 1
x_int = x + r
z_int = z + r
for i in range(n):
    l = 2 * (n - i) + 1
    for j in range(l):
        for k in range(l):
            mc.setBlock(x_int - k - i, y + i, z_int - j - i, block.Block(24))
コード例 #14
0
import mcpi.minecraft as minecraft
import mcpi.block as block
#import time

mc = minecraft.Minecraft.create()

#testing connection to game
mc.postToChat("building structure perimeter base and flooring")

#assign desired block ids for structure and floor
structureBlockId = 45  #brick block
floorBlockId = 5

structureBlock = block.Block(structureBlockId)
floorBlock = block.Block(floorBlockId)

xmin = -10
xmax = 10

groundlevel = 1
ceiling = groundlevel + 5

zmin = -10
zmax = 10

for y in range(groundlevel, ceiling + 1):
    for x in range(xmin, xmax + 1):
        for z in range(zmin, zmax + 1):
            if (x == xmin or x == xmax) or (z == zmin or z == zmax):
                mc.setBlock(x, y, z, structureBlock)
            elif (y == groundlevel):
コード例 #15
0
    (99, 135, 210),  # light blue
    (194, 181, 28),  # yellow
    (57, 186, 46),  # lime
    (217, 129, 153),  # pink
    (65, 65, 65),  # grey
    (160, 167, 167),  # light grey
    (38, 113, 145),  # cyan
    (126, 52, 191),  # purple
    (37, 49, 147),  # blue
    (86, 51, 28),  # brown
    (54, 75, 24),  # green
    (158, 43, 39),  # red
    (24, 20, 20)  # black
]


def d(a, b):
    return math.sqrt(sum((u - v) * (u - v) for u, v in zip(a, b)))


types = list(range(len(wool_colors)))
wool_counter = Counter()
for i in range(img.width):
    for j in range(img.height):
        color = pixels[i, j]
        wool_type = min(types, key=lambda k: d(wool_colors[k], color))
        wool_counter[wool_type] += 1
        mc.setBlock(x + i, y, z + j, block.Block(35, wool_type))

print(wool_counter)
コード例 #16
0
"""
Bare-bones but we don't even import block in any tests yet
"""

from mcpi import block

block.Block(block.AIR)
コード例 #17
0
ファイル: Nether.py プロジェクト: justknow23/learn
mc.postToChat("Coded by ice1000")
mc.postToChat("Nether Wolrd!")
mc.postToChat("Wait for the God!!")
dis = 3

(x1,y1,z1) = mc.player.getPos()
x = x1-dis
z = z1-dis
height = y1-dis
while height <= y1:
    z = z1-dis
    while z <= (z1+dis):
        x = x1-dis
        while x <= (x1+dis):
            if mc.getBlock(x,height,z) != 0:
                mc.setBlock(x,height,z,block.Block(87))
            x += 1
        z += 1
    height += 1

height -= 1
x = 0
z = 0
while x < 4:
    mc.setBlock(x1-2+x,height  ,z1,block.OBSIDIAN)
    mc.setBlock(x1-2+x,height+4,z1,block.OBSIDIAN)
    x += 1
while z < 3:
    mc.setBlock(x1-2,height+1+z,z1,block.OBSIDIAN)
    mc.setBlock(x1+1,height+1+z,z1,block.OBSIDIAN)
    z += 1
コード例 #18
0
def timethis(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.clock()
        r = func(*args, **kwargs)
        end = time.clock()
        print '{} - {}.{} : {}'.format(
            type(args[0]).__name__, func.__module__, func.__name__,
            end - start)
        return r

    return wrapper


#wooden pressure plate:
TABLE_TOP = mblock.Block(72)

SLEEP_SECS = 0.1

DEBUG_BLOCK_WRITES = True
DEBUG_BLOCK_CTOR = False
DEBUG_BLOCK_ROTATION = False
DEBUG_LAYERS = False
DISPLAY_BLOCK_DESCRIPTIONS = True

# building apt block overloads bukkit server, (this was down to incorrect data value for carrots, has been corrected)
DELAY_MULTIPLIER = 0
BLOCK_BUILD_DELAY = 0.05 * DELAY_MULTIPLIER
LAYER_BUILD_DELAY = 0.05 * DELAY_MULTIPLIER  # first block wil add another 0.1 to delay
BUILDING_DELAY = 0.1 * DELAY_MULTIPLIER
コード例 #19
0
ファイル: minecraftstuff.py プロジェクト: liviuq/mcpi
 def penblock(self, blockId, blockData=0):
     self._penblock = block.Block(blockId, blockData)
コード例 #20
0
 def test_with_data(self):
     data = 'bar'
     b = block.Block(4).withData(data)
     assert b.data == data
コード例 #21
0
 def test_repr(self):
     assert repr(block.Block(5)) == 'Block(5, 0)'
     assert repr(block.Block(5, 6)) == 'Block(5, 6)'
コード例 #22
0
ファイル: Grapher.py プロジェクト: CanyonTurtle/RasPi
class Graph:
    """This class can be used to graph a function in minecraft."""

    step = 0.01
    graph_block_list = [
        block.Block(35, 1),
        block.Block(35, 2),
        block.Block(35, 3),
        block.Block(35, 4),
        block.Block(35, 5)
    ]
    background_block = block.GLASS

    def setup_graph(self):
        """Draws the background for the graph."""
        ox, oy, oz = self.origin_pos
        #mc.setBlocks(ox + self.xMin, oy + self.yMin, oz + 1, ox + self.xMax, oy + self.yMax, oz + 1, 35, 1)
        mc.setBlocks(ox + self.xMin, oy + self.yMin, oz, ox + self.xMax,
                     oy + self.yMax, oz, self.background_block.id,
                     self.background_block.data)
        mc.setBlocks(ox + self.xMin, oy, oz, ox + self.xMax, oy, oz, 35, 15)
        mc.setBlocks(ox, oy + self.yMin, oz, ox, oy + self.yMax, oz, 35, 15)

    def __init__(self, origin_pos, xMin, xMax, yMin, yMax, mc):
        self.origin_pos = origin_pos
        self.xMin = xMin
        self.xMax = xMax
        self.yMin = yMin
        self.yMax = yMax
        self.mc = mc
        self.setup_graph()

    def plot_on_graph(self, x, y, color):
        """This function plots a point at x,y in the graph, with specified color. MC instance needed."""
        ox, oy, oz = self.origin_pos
        b = self.graph_block_list[color]
        if (y >= self.yMin and y <= self.yMax):
            self.mc.setBlock(ox + x, oy + y, oz, b.id, b.data)

    def prompt_graph_mc(self, function):
        self.mc.postToChat(
            "Right click the ground with your sword to spawn a graph with the origin at that point."
        )
        mc.postToChat("Graph will be " + str(self.xMax - self.xMin) +
                      " units long and " + str(self.yMax - self.yMin) +
                      " units tall.")

        run = True
        while (run == True):
            evs = self.mc.events.pollBlockHits()
            for e in evs:
                self.origin_pos = vec3.Vec3(
                    e.pos.x, e.pos.y + ((self.yMax - self.yMin) / 2), e.pos.z)
                self.setup_graph()
                self.draw_function(function)
                run = False

    def prompt_graph_mc_shell(self):
        function = raw_input("y = ")
        print("Waiting for user input in minecraft...")
        self.prompt_graph_mc(function)

    def prompt_graph_shell(self):
        function = raw_input("y = ")
        x = input("x position: ")
        y = input("y position: ")
        z = input("z position: ")
        self.origin_pos = vec3.Vec3(x, y, z)
        self.xMin = input("xMin: ")
        self.xMax = input("xMax: ")
        self.yMin = input("yMin: ")
        self.yMax = input("yMax: ")

        self.setup_graph()
        self.draw_function(function)

    def draw_function(self, function):
        """draws a function on the graph."""
        x = self.xMin * 1.0
        while (x < self.xMax):
            y = eval(function)
            self.plot_on_graph(x, y, 3)
            x += self.step
コード例 #23
0
import mcpi.minecraft as minecraft
import mcpi.block as block
from room import Room

mc = minecraft.Minecraft.create('127.0.0.1')
room = Room()
room.draw_room(mc)
room.set_lighting(mc)

#make the pumpkin
orangeWool = block.Block(35, 1)
greyWool = block.Block(35, 8)


def clear_pumpkin():
    #Body of pumpkin
    mc.setBlocks(-5, 0, 15, 5, 0, 15, orangeWool)
    mc.setBlocks(-8, 1, 15, 8, 1, 15, orangeWool)
    mc.setBlocks(-9, 3, 15, 9, 2, 15, orangeWool)
    mc.setBlocks(-10, 7, 15, 10, 4, 15, orangeWool)
    mc.setBlocks(-9, 9, 15, 9, 7, 15, orangeWool)
    mc.setBlocks(-8, 10, 15, 8, 10, 15, orangeWool)
    mc.setBlocks(-5, 11, 15, 5, 11, 15, orangeWool)

    #Stalk
    mc.setBlocks(-1, 12, 15, 1, 12, 15, greyWool)
    mc.setBlocks(0, 13, 15, 2, 13, 15, greyWool)
    mc.setBlocks(1, 14, 15, 2, 14, 15, greyWool)


clear_pumpkin()
コード例 #24
0
ファイル: NewYear.py プロジェクト: Oleg355/helloworld
def b(x, y):
    return block.Block(x, y)
コード例 #25
0
ファイル: NewYear.py プロジェクト: Oleg355/helloworld
import mcpi.block as block
import keyboard

a = 0.5
if keyboard.is_pressed('u'):
    a = a + 0.1
if keyboard.is_pressed('i'):
    a = a - 0.1


def b(x, y):
    return block.Block(x, y)


lis = [b(35, 14), b(35, 1), b(35, 4), b(35, 5), b(35, 11)]
mc = minecraft.Minecraft.create()
tree = block.Block(35, 13)
mc.setBlocks(29999983, 99, 87, 29999958, 0, 62, 0)
mc.setBlocks(29999983, 72, 87, 29999958, 72, 62, 80)
mc.setBlocks(29999969, 73, 76, 29999975, 73, 70, tree)
mc.setBlocks(29999974, 74, 75, 29999970, 74, 71, tree)
mc.setBlocks(29999971, 75, 72, 29999973, 75, 74, tree)
mc.setBlocks(29999974, 76, 75, 29999970, 76, 71, tree)
mc.setBlocks(29999971, 77, 72, 29999973, 77, 74, tree)
mc.setBlock(29999972, 78, 73, tree)
while True:
    for i in lis:

        mc.setBlock(29999973, 74, 70, i)
        time.sleep(a)
コード例 #26
0
ファイル: build.py プロジェクト: ridhdi/Minecraft
import mcpi.minecraft as minecraft
mc = minecraft.Minecraft.create()

import mcpi.block as block

pos = mc.player.getTilePos()
for y in range(20):
    for x in range(20):
        mc.setBlock(pos.x+x,pos.y+y,pos.z,block.Block(20).id)


for y in range(20):
    for z in range(20):
        mc.setBlock(pos.x,pos.y+y,pos.z+z,block.Block(20).id)


for y in range(20):
    for x in range(20):
        mc.setBlock(pos.x+x,pos.y+y,pos.z+20,block.Block(20).id)

for y in range(20):
    for z in range(20):
        mc.setBlock(pos.x+20,pos.y+y,pos.z+z,block.Block(20).id)

for x in range(20):
    for z in range(20):
        mc.setBlock(pos.x+x,pos.y,pos.z+z,block.Block(20).id)

for x in range(20):
    for z in range(20):
        mc.setBlock(pos.x+x,pos.y+20,pos.z+z,block.Block(20).id)
コード例 #27
0
 def turtleBlock(self, blockId, blockData=0):
     self._turtleblock = block.Block(blockId, blockData)
コード例 #28
0
ファイル: tower.py プロジェクト: haxac/minecraft_scripts
     "id": block.STONE.id,
     "dtag": 0
 }  #石
 ,
 4: {
     "id": block.COBBLESTONE.id,
     "dtag": 0
 }  #丸石
 ,
 44: {
     "id": block.STONE_SLAB.id,
     "dtag": 0
 }  #石ハーフブロック
 ,
 44.5: {
     "id": block.Block(block.STONE_SLAB.id, 5).id,
     "dtag": 5
 }  #石レンガハーフブロック
 ,
 44.58: {
     "id": block.Block(block.STONE_SLAB.id, 5).id,
     "dtag": 13
 }  #石レンガハーフブロック 上向き
 ,
 50: {
     "id": block.TORCH.id,
     "dtag": 0
 }  #松明
 ,
 5.0: {
     "id": block.WOOD_PLANKS_OAK.id,
コード例 #29
0
ファイル: types.py プロジェクト: petemulholland/learning
import mcpi.block as block

PAINTING = block.Block(321)


class PlankData:
    OAK = 0
    SPRUCE = 1
    BIRCH = 2
    JUNGLE = 3
    ACACIA = 4
    DARK_OAK = 5


TORCH_REDSTONE_INACTIVE = block.Block(75)
TORCH_REDSTONE_ACTIVE = block.Block(76)

STAIRS_BRICK = block.Block(108)
STAIRS_STONE_BRICK = block.Block(109)
STAIRS_NETHER_BRICK = block.Block(114)
STAIRS_SANDSTONE = block.Block(128)
STAIRS_SPRUCE = block.Block(134)
STAIRS_BIRCH = block.Block(135)
STAIRS_JUNGLE = block.Block(136)
STAIRS_QUARTZ = block.Block(156)

# TODO: other oriented blocks to be defined: ??
# http://minecraft.gamepedia.com/Data_values#Block_IDs
#	- redstone repeater
#	- piston (& sticky piston)
#	- button
コード例 #30
0
 def test_instantiation(self):
     b = block.Block(0)
     assert b.id == 0