예제 #1
0
def sprite_in_minecraft(mc, sprite, pos):
    char_sprite = reversed(str(sprite).splitlines())
    for height, row in enumerate(char_sprite):
        for width, char in enumerate(row):
            if char == '0':
                blk = block.AIR
            else:
                blk = block.WOOD
            mc.setBlock(player_pos + Vec3(width, height, 0), blk)
예제 #2
0
def create_house(mc, house_slices, offset, base=block.STONE):
    center = mc.player.getTilePos()
    corner = center - offset
    for delta_y, house_slice in enumerate(house_slices):
        for delta_x, row in enumerate(house_slice):
            for delta_z, block_index in enumerate(row):
                block_type = block_types[int(block_index)]
                mc.setBlock(corner + Vec3(delta_x, delta_y, delta_z),
                            block_type)
예제 #3
0
def create_house(mc, house_slices, offset, base=block.STONE):
    center = mc.player.getTilePos()
    corner = center - offset
    for delta_y, house_slice in enumerate(house_slices):
        for delta_x, row in enumerate(house_slice):
            for delta_z, block_index in enumerate(row):
                block_type = block_types[int(block_index)]
                mc.setBlock(corner + Vec3(delta_x, delta_y, delta_z),
                            block_type)

    num_rows = len(house_slices[0])
    row_length = len(house_slices[0][0])
    mc.setBlocks(
        (corner.x, -64, corner.z),
        (corner.x + num_rows - 1, corner.y, corner.z + row_length - 1), base)
예제 #4
0
cursor = mc.player.getTilePos()
cursor.y = mc.getHeight(cursor.x, cursor.z)

BLINK_TIME = 0.3
start = time.time()
cursor_on = True
while True:
    if select.presses():
        blk = next(block_types)

    if place.presses():
        mc.setBlock(cursor, blk)
        cursor.y += 1

    old_cursor = cursor.clone()
    cursor += Vec3(0, 0, right.presses())
    cursor += Vec3(0, 0, -left.presses())
    cursor += Vec3(up.presses(), 0, 0)
    cursor += Vec3(-down.presses(), 0, 0)
    if old_cursor != cursor:
        mc.setBlock(old_cursor, block.AIR)
        cursor.y = mc.getHeight(cursor.x, cursor.z)
        start = 0
        cursor_on = True

    if time.time() - start > BLINK_TIME:
        mc.setBlock(cursor, block.STONE if cursor_on else block.AIR)
        start = time.time()
        cursor_on = not cursor_on

    time.sleep(0.01)
예제 #5
0
from rstem.button import Button
from rstem.mcpi import minecraft, control, block
from rstem.mcpi.vec3 import Vec3
import time
from math import sin, cos, radians

control.show(hide_at_exit=True)
mc = minecraft.Minecraft.create()
button = Button(7)

while True:
    if button.presses():
        heading = control.get_heading(mc)
        x_delta = sin(radians(heading))
        z_delta = cos(radians(heading))
        pos = mc.player.getPos() - Vec3(0, 1, 0)
        for i in range(100):
            pos += Vec3(x_delta, 0, z_delta)
            mc.setBlock(pos, block.STONE)

    time.sleep(0.01)

예제 #6
0
def create_house(mc, house_slices, offset, base=block.STONE):
    center = mc.player.getTilePos()
    corner = center - offset
    for delta_y, house_slice in enumerate(house_slices):
        for delta_z, row in enumerate(house_slice):
            for delta_x, block_index_letter in enumerate(row):
                block_index = int(block_index_letter,36)
                if block_index_letter.islower():
                    block_index += 26
                block_type = block_types[block_index]
                mc.setBlock(corner + Vec3(delta_x, delta_y, delta_z), block_type)

    num_rows = len(house_slices[0])
    row_length = len(house_slices[0][0])
    mc.setBlocks(
        (corner.x, -64, corner.z),
        (corner.x + num_rows - 1, corner.y - 1, corner.z + row_length - 1),
        base)
                
control.show(hide_at_exit=True)
mc = minecraft.Minecraft.create()
button = Button(7)

while True:
    if button.presses():
        create_house(mc, house, Vec3(0,1,0))

    time.sleep(0.01)

예제 #7
0
from rstem.button import Button
from rstem.mcpi import minecraft, control, block
from rstem.mcpi.vec3 import Vec3
import time
from math import sin, cos, radians

control.show(hide_at_exit=True)
mc = minecraft.Minecraft.create()
button = Button(7)

while True:
    if button.presses():
        h = control.get_heading(mc)
        x_delta = sin(radians(h))
        z_delta = cos(radians(h))
        pos = mc.player.getPos() - Vec3(0, 1, 0)
        for i in range(30):
            pos += Vec3(x_delta, 0, z_delta)
            for width in range(-3, 3 + 1):
                mc.setBlock(pos + Vec3(width * z_delta, 0, width * x_delta),
                            block.STONE)

    time.sleep(0.01)
예제 #8
0
def detonate(mc, pos, radius=1):
    r_vector = Vec3(radius, radius, radius)
    mc.setBlocks(pos - r_vector, pos + r_vector, block.AIR)
예제 #9
0
def dig(mc, pos, radius=1):
    r_vector = Vec3(radius,radius,radius)
    mc.setBlocks(hit.pos - r_vector, hit.pos + r_vector, block.AIR)
    Sprite(arrow15deg).rotate(180),
    Sprite(arrow30deg).rotate(180),
    Sprite(arrow45deg).rotate(180),
    Sprite(arrow60deg).rotate(180),
    Sprite(arrow75deg).rotate(180),
    Sprite(arrow0deg).rotate(270),
    Sprite(arrow15deg).rotate(270),
    Sprite(arrow30deg).rotate(270),
    Sprite(arrow45deg).rotate(270),
    Sprite(arrow60deg).rotate(270),
    Sprite(arrow75deg).rotate(270),
    ]

def vector_angle(start, end):
    return degrees(atan2(end.x - start.x, end.z - start.z))
    
compass = Button(24)
fb = FrameBuffer()
while True:
    if compass.presses():
        heading = control.get_heading(mc)
        angle_to_origin = vector_angle(mc.player.getPos(), Vec3(0,0,0))
        compass_angle = 90 + (angle_to_origin - heading)
        fb.erase()
        arrow_index = round(compass_angle/15) % 24
        fb.draw(arrows[arrow_index])
        fb.show()

    time.sleep(0.01)

예제 #11
0
        '111111',
    ],
]

block_types = [
    block.AIR,
    block.STONE,
]


def create_house(mc, house_slices, offset, base=block.STONE):
    center = mc.player.getTilePos()
    corner = center - offset
    for delta_y, house_slice in enumerate(house_slices):
        for delta_x, row in enumerate(house_slice):
            for delta_z, block_index in enumerate(row):
                block_type = block_types[int(block_index)]
                mc.setBlock(corner + Vec3(delta_x, delta_y, delta_z),
                            block_type)


control.show(hide_at_exit=True)
mc = minecraft.Minecraft.create()
button = Button(7)

while True:
    if button.presses():
        create_house(mc, house, Vec3(3, 1, 3))

    time.sleep(0.01)