from mcpi.minecraft import Minecraft
import time
import serial
ser=None
mc=None
def connect(com=None):
    global ser
    if com==None:
        print('请输入端口号(请注意大小写):')
        com=input()
    ser=serial.Serial(com,9600)
def control(s):
    global ser
    
    if(s>0):
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('+'.encode())
        mc.postToChat("+")
    if(s<0):
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('-'.encode())
        mc.postToChat("-")
def main():
    global mc
    mc=Minecraft.create()
    connect('COM5')
    lastPos=mc.player.getTilePos()
    while True:
        time.sleep(0.5)
        pos=mc.player.getTilePos()
        control(pos.x-lastPos.x)
main()

ea440a6fc3f492cea3118ab96c73101928887beb
<mask token>


def connect(com=None):
    global ser
    if com == None:
        print('请输入端口号(请注意大小写):')
        com = input()
    ser = serial.Serial(com, 9600)


def control(s):
    global ser
    if s > 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('+'.encode())
        mc.postToChat('+')
    if s < 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('-'.encode())
        mc.postToChat('-')


def main():
    global mc
    mc = Minecraft.create()
    connect('COM5')
    lastPos = mc.player.getTilePos()
    while True:
        time.sleep(0.5)
        pos = mc.player.getTilePos()
        control(pos.x - lastPos.x)


<mask token>

<mask token>


def connect(com=None):
    global ser
    if com == None:
        print('请输入端口号(请注意大小写):')
        com = input()
    ser = serial.Serial(com, 9600)


def control(s):
    global ser
    if s > 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('+'.encode())
        mc.postToChat('+')
    if s < 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('-'.encode())
        mc.postToChat('-')


def main():
    global mc
    mc = Minecraft.create()
    connect('COM5')
    lastPos = mc.player.getTilePos()
    while True:
        time.sleep(0.5)
        pos = mc.player.getTilePos()
        control(pos.x - lastPos.x)


main()

<mask token>
ser = None
mc = None


def connect(com=None):
    global ser
    if com == None:
        print('请输入端口号(请注意大小写):')
        com = input()
    ser = serial.Serial(com, 9600)


def control(s):
    global ser
    if s > 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('+'.encode())
        mc.postToChat('+')
    if s < 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('-'.encode())
        mc.postToChat('-')


def main():
    global mc
    mc = Minecraft.create()
    connect('COM5')
    lastPos = mc.player.getTilePos()
    while True:
        time.sleep(0.5)
        pos = mc.player.getTilePos()
        control(pos.x - lastPos.x)


main()

from mcpi.minecraft import Minecraft
import time
import serial
ser = None
mc = None


def connect(com=None):
    global ser
    if com == None:
        print('请输入端口号(请注意大小写):')
        com = input()
    ser = serial.Serial(com, 9600)


def control(s):
    global ser
    if s > 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('+'.encode())
        mc.postToChat('+')
    if s < 0:
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('-'.encode())
        mc.postToChat('-')


def main():
    global mc
    mc = Minecraft.create()
    connect('COM5')
    lastPos = mc.player.getTilePos()
    while True:
        time.sleep(0.5)
        pos = mc.player.getTilePos()
        control(pos.x - lastPos.x)


main()

from mcpi.minecraft import Minecraft
import time
import serial
ser=None
mc=None
def connect(com=None):
    global ser
    if com==None:
        print('请输入端口号(请注意大小写):')
        com=input()
    ser=serial.Serial(com,9600)
def control(s):
    global ser
    
    if(s>0):
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('+'.encode())
        mc.postToChat("+")
    if(s<0):
        ser.write('s'.encode())
        ser.write('t'.encode())
        ser.write('-'.encode())
        mc.postToChat("-")
def main():
    global mc
    mc=Minecraft.create()
    connect('COM5')
    lastPos=mc.player.getTilePos()
    while True:
        time.sleep(0.5)
        pos=mc.player.getTilePos()
        control(pos.x-lastPos.x)
main()
