示例#1
0
def action_place_item():
    '''
    Place different block on top of another, using item() to select items.

    Uses control.item(), which is only consistent when used from program start
    (i.e., separate_session=True)
    '''
    mc = mc_create()

    # Place bottom block
    slow_look(down=300)
    control.item(2) # Cobblestone
    control.place(0.1)

    # Place top block
    slow_look(up=150)
    control.item(5) # Dirt
    control.place(0.1)

    # Verify blocks
    bottom_block = mc.getBlock(BOX_MIDDLE_TILE, 1, BOX_MIDDLE_TILE+1)
    top_block = mc.getBlock(BOX_MIDDLE_TILE, 2, BOX_MIDDLE_TILE+1)
    print("Bottom Block:", bottom_block)
    print("Top Block:", top_block)
    bottom_passed = block.Block(bottom_block) == block.COBBLESTONE
    top_passed = block.Block(top_block) == block.DIRT
    print("Bottom", "PASSED" if bottom_passed else "FAILED")
    print("Top", "PASSED" if top_passed else "FAILED")
    return bottom_passed and top_passed
示例#2
0
def action_smash():
    '''
    Place block and smash it

    Uses control.item(), which is only consistent when used from program start
    (i.e., separate_session=True)
    '''
    mc = mc_create()
    control.item(2) # Cobblestone
    control.place(0.1)
    block_before = mc.getBlock(BOX_MIDDLE_TILE, 2, BOX_WIDTH)
    control.smash(0.1)
    block_after = mc.getBlock(BOX_MIDDLE_TILE, 2, BOX_WIDTH)
    print("Block Before:", block_before)
    print("Block After:", block_after)
    before_passed = block.Block(block_before) == block.COBBLESTONE
    after_passed = block.Block(block_after) == block.AIR
    print("Before", "PASSED" if before_passed else "FAILED")
    print("After", "PASSED" if after_passed else "FAILED")
    return before_passed and after_passed
示例#3
0
def item_typeerror():
    try:
        control.item("string")
    except TypeError:
        return True
    return False
示例#4
0
def item_high():
    try:
        control.item(9)
    except ValueError:
        return True
    return False
示例#5
0
def item_low():
    try:
        control.item(0)
    except ValueError:
        return True
    return False