コード例 #1
0
def chop_chop(mc):
    """ clicks left mouse button, chopchop!
        returns true if a flower was chopped, otherwise false.
        'mc' is minecraft connection object """

    currentBlockPosition = get_block_position(mc)
    if currentBlockPosition == Vec3(999,999,999):
        logging.debug("no block in range")
        return False
    else:
        blockPreChop = mc.getBlock(currentBlockPosition)
        #logging.debug("blockprechop is: %s" % (blockPreChop))
        aid.mouseClick('left')
        time.sleep(0.05) # allow block to change type
        blockPostChop = mc.getBlock(currentBlockPosition)
        #logging.debug("blockpostchop is: %s" % (blockPostChop))

    if blockPreChop == 38 and blockPostChop != 38:
        #logging.debug("that was a flowah! returning true good sir")
        #time.sleep(2)
        return True
    else:
        #logging.debug("that was not a flower, so get your shit together!")
        #time.sleep(2)
        return False
コード例 #2
0
ファイル: get_block_position.py プロジェクト: fohria/maia
def get_block_position(mc):
    """ requires sword in player hand. right clicks to get position of block.
        if a block is in range, it returns block position otherwise returns Vec3(999,999,999)
        'mc' is minecraft connection object """

    position = Vec3(999, 999, 999)  # hack because Vec3 doesn't support None
    # logging.debug("inside get_block_position, position is now: %s" % (position))
    aid.mouseClick("right")  # needed to catch event properly, without this events are empty first
    time.sleep(0.05)

    hitcounter = 0

    while True:
        blockHits = mc.events.pollBlockHits()
        aid.mouseClick("right")
        # logging.debug("clicked right button")
        if blockHits:
            for blockHit in blockHits:
                # logging.debug("blockhit")
                # logging.debug(blockHit.pos)
                hitcounter += 1
            if hitcounter > 1:
                position = blockHits[hitcounter - 1].pos
            else:
                position = blockHits[0].pos

            # logging.debug("i shall now return the position which is: %s" % (position))
            break
        else:
            # logging.debug("no block in range, returning position which is: %s" % (position))
            break

    mc.events.clearAll()
    return position
コード例 #3
0
ファイル: get_block_position.py プロジェクト: fohria/maia
def get_block_position(mc):
    """ requires sword in player hand. right clicks to get position of block.
        if a block is in range, it returns block position otherwise returns Vec3(999,999,999)
        'mc' is minecraft connection object """

    position = Vec3(999, 999, 999)  # hack because Vec3 doesn't support None
    #logging.debug("inside get_block_position, position is now: %s" % (position))
    aid.mouseClick(
        'right'
    )  # needed to catch event properly, without this events are empty first
    time.sleep(0.05)

    hitcounter = 0

    while True:
        blockHits = mc.events.pollBlockHits()
        aid.mouseClick('right')
        #logging.debug("clicked right button")
        if blockHits:
            for blockHit in blockHits:
                #logging.debug("blockhit")
                #logging.debug(blockHit.pos)
                hitcounter += 1
            if hitcounter > 1:
                position = blockHits[hitcounter - 1].pos
            else:
                position = blockHits[0].pos

            #logging.debug("i shall now return the position which is: %s" % (position))
            break
        else:
            #logging.debug("no block in range, returning position which is: %s" % (position))
            break

    mc.events.clearAll()
    return position