SpockBotMC / SpockBot

High level Python framework for building Minecraft clients and bots.
MIT License
198 stars 47 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xde in position 0: invalid continuation byte #75

Closed hlprimm closed 9 years ago

hlprimm commented 9 years ago

So I'm quite new to python and programming overall. I've managed to get example.py running. I tried it out in test.civcraft.co and it worked great. However, trying it out in the main civcraft server mc.civcraft.co causes this error. Let me know if there's anything else I can provide! BTW, I tried running python 3 on example.py with my login info in the blanks, but it kept throwing this error:

Traceback (most recent call last):
  File "example.py", line 26, in <module>
    from .example_plugin import ExamplePlugin
SystemError: Parent module '' not loaded, cannot perform relative import

So instead I've been running it as python3 -m basic.example ... Not sure if this is causing the problem or not!

Here is the full ouput!

hlprimm@apollo:~/Code/python/SpockBot/examples$ python3 -m basic.example
[INFO]: AUTHCORE: Attempting login with username: CENSORED
[INFO]: AUTHCORE: Logged in as: hlprimm
[INFO]: AUTHCORE: Selected Profile: {'id': '5505ae3e6d424a53ae059e19479d29e2', 'name': 'hlprimm'}
[INFO]: NETCORE: Attempting to connect to host: mc.civcraft.co port: 25565
[INFO]: NETCORE: Connected to host: mc.civcraft.co port: 25565
[INFO]: AUTHPLUGIN: Attempting to authenticate session with sessionserver.mojang.com
[INFO]: AUTHPLUGIN: Session authentication successful
Chat message received: [22:47:14] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'white', 'text': ' '}, {'color': 'white', 'text': ' '}, {'color': 'dark_blue', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'white', 'text': ' '}, {'color': 'white', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_red', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'blue', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'blue', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'blue', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}], 'text': ''}}
Chat message received: [22:47:14] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'gray', 'text': '[NSAccess] hlprimm: '}, {'color': 'white', 'text': 'Bot active.'}], 'text': ''}}
Chat message received: [22:47:15] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'red', 'text': 'You have engaged in combat. Type '}, {'color': 'aqua', 'text': '/ct '}, {'color': 'red', 'text': 'to check your timer.'}], 'text': ''}}
Chat message received: [22:47:15] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': ['You have been Combat Tagged on Login'], 'text': ''}}
My position: (-1819.13, 67.22, -11004.61) pitch: 8.99999713897705 yaw: 96.29989624023438
Before changing the block, the type had id 0 and name air.
Chat message received: [22:47:18] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'red', 'text': "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."}], 'text': ''}}
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/hlprimm/Code/python/SpockBot/examples/basic/example.py", line 46, in <module>
    client.start(SERVER, 25565)
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/helpers/start.py", line 37, in start
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 23, in event_loop
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 38, in emit
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 189, in tick
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 38, in emit
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 205, in handle_recv
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 129, in read_packet
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/mcpacket.py", line 70, in decode
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 220, in unpack
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 162, in unpack_metadata
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 214, in unpack
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xde in position 0: invalid continuation byte

Is there something I should change?

Thanks a bunch, spockbot is AWESOME!!

gamingrobot commented 9 years ago

Fixed the first error with 918d068

hlprimm commented 9 years ago

@gamingrobot thanks a bunch!!

here's the second error we're looking at. looks like it's still sticking around :/

hlprimm@apollo:~/Code/python/SlackMCRelay$ python example.py
[INFO]: AUTHCORE: Attempting login with username: CENSORED
[INFO]: AUTHCORE: Logged in as: hlprimm
[INFO]: AUTHCORE: Selected Profile: {u'id': u'5505ae3e6d424a53ae059e19479d29e2', u'name': u'hlprimm'}
[INFO]: NETCORE: Attempting to connect to host: mc.civcraft.co port: 25565
[INFO]: NETCORE: Connected to host: mc.civcraft.co port: 25565
[INFO]: AUTHPLUGIN: Attempting to authenticate session with sessionserver.mojang.com
[INFO]: AUTHPLUGIN: Session authentication successful
Chat message received: [00:22:37] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {u'text': u'', u'extra': [{u'color': u'yellow', u'text': u'You have auto-accepted invitation from the following groups while you were away: sjoby.'}]}}
Chat message received: [00:22:37] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {u'text': u'', u'extra': [{u'color': u'white', u'text': u' '}, {u'color': u'white', u'text': u' '}, {u'color': u'dark_blue', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'dark_green', u'text': u' '}, {u'color': u'white', u'text': u' '}, {u'color': u'white', u'text': u' '}, {u'color': u'dark_green', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'dark_red', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'blue', u'text': u' '}, {u'color': u'dark_green', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'blue', u'text': u' '}, {u'color': u'dark_green', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'blue', u'text': u' '}, {u'color': u'dark_green', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'black', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'gold', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'gold', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'gold', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'gold', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'gold', u'text': u' '}, {u'color': u'dark_aqua', u'text': u' '}, {u'color': u'gold', u'text': u' '}]}}
Chat message received: [00:22:37] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {u'text': u'', u'extra': [{u'color': u'gray', u'text': u'[NSAccess] hlprimm: '}, {u'color': u'white', u'text': u'Bot active.'}]}}
Chat message received: [00:22:37] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {u'text': u'', u'extra': [{u'color': u'red', u'text': u'You have engaged in combat. Type '}, {u'color': u'aqua', u'text': u'/ct '}, {u'color': u'red', u'text': u'to check your timer.'}]}}
Chat message received: [00:22:37] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {u'text': u'', u'extra': [u'You have been Combat Tagged on Login']}}
Traceback (most recent call last):
  File "example.py", line 46, in <module>
    client.start(SERVER, 25565)
  File "build/bdist.linux-x86_64/egg/spock/plugins/helpers/start.py", line 37, in start
  File "build/bdist.linux-x86_64/egg/spock/plugins/core/event.py", line 23, in event_loop
  File "build/bdist.linux-x86_64/egg/spock/plugins/core/event.py", line 38, in emit
  File "build/bdist.linux-x86_64/egg/spock/plugins/core/net.py", line 201, in tick
  File "build/bdist.linux-x86_64/egg/spock/plugins/core/event.py", line 38, in emit
  File "build/bdist.linux-x86_64/egg/spock/plugins/core/net.py", line 218, in handle_recv
  File "build/bdist.linux-x86_64/egg/spock/plugins/core/net.py", line 137, in read_packet
  File "build/bdist.linux-x86_64/egg/spock/mcp/mcpacket.py", line 70, in decode
  File "build/bdist.linux-x86_64/egg/spock/mcp/datautils.py", line 220, in unpack
  File "build/bdist.linux-x86_64/egg/spock/mcp/datautils.py", line 162, in unpack_metadata
  File "build/bdist.linux-x86_64/egg/spock/mcp/datautils.py", line 214, in unpack
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xde in position 0: invalid continuation byte
hlprimm commented 9 years ago

As requested from echo.py

[INFO]: [01:04:28] <<< (0x03, 0x1C): Entity Metadata               {'metadata': [(22, (0, 0)), (21, (2, 6)), (20, (2, 0)), (19, (3, 0.0)), (18, (2, 1)), (17, (2, 0)), (4, (0, 0)), (3, (0, 0)), (2, (4, '')), (1, (1, 300)), (0, (0, 0))], 'eid': 1341826}
[INFO]: [01:04:28] <<< (0x03, 0x12): Entity Velocity               {'velocity_z': 0, 'velocity_y': 0, 'velocity_x': 0, 'eid': 1341826}
[INFO]: [01:04:28] <<< (0x03, 0x19): Entity Head Look              {'head_yaw': 0, 'eid': 1341826}
[INFO]: [01:04:28] <<< (0x03, 0x0E): Spawn Object                  {'obj_data': 0, 'x': -1805.5, 'eid': 1341827, 'yaw': 0, 'y': 74.0625, 'obj_type': 10, 'z': -10992.5, 'pitch': 0}
[INFO]: [01:04:28] <<< (0x03, 0x1C): Entity Metadata               {'metadata': [(22, (0, 0)), (21, (2, 6)), (20, (2, 0)), (19, (3, 0.0)), (18, (2, 1)), (17, (2, 0)), (4, (0, 0)), (3, (0, 0)), (2, (4, '')), (1, (1, 300)), (0, (0, 0))], 'eid': 1341827}
[INFO]: [01:04:28] <<< (0x03, 0x12): Entity Velocity               {'velocity_z': 0, 'velocity_y': 0, 'velocity_x': 633, 'eid': 1341827}
[INFO]: [01:04:28] <<< (0x03, 0x19): Entity Head Look              {'head_yaw': 0, 'eid': 1341827}
[INFO]: [01:04:28] <<< (0x03, 0x0E): Spawn Object                  {'obj_data': 0, 'x': -1814.5, 'eid': 1341836, 'yaw': 64, 'y': 88.0, 'obj_type': 78, 'z': -11006.5, 'pitch': 0}
Traceback (most recent call last):
  File "echo.py", line 22, in <module>
    client.start('mc.civcraft.co', 25565)
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/helpers/start.py", line 37, in start
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 23, in event_loop
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 38, in emit
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 189, in tick
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 38, in emit
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 205, in handle_recv
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 129, in read_packet
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/mcpacket.py", line 70, in decode
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 220, in unpack
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 162, in unpack_metadata
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 214, in unpack
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xde in position 0: invalid continuation byte
hlprimm@apollo:~/Code/python/SpockBot-Extra/examples$ 
nickelpro commented 9 years ago

This is a problem in metadata decoding, probably, armor stands are an old bug that got ignored because they're kinda rare.

Side note: SpockBot was originally built to drive a service called SkyNet on Civcraft, so this is a fun full circle

gamingrobot commented 9 years ago

Fixed fully in #77

hlprimm commented 9 years ago

@gamingrobot thanks a bunch! glad to hear! @nickelpro yeah, i'm doing a similar project to pipe in game chat to my nation's slack chat. super nifty project you guys have going here!!