Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using keyboard is creating unexpected errors inside the internal code of mcpi. #28

Open
xboxone08 opened this issue Jul 5, 2022 · 0 comments

Comments

@xboxone08
Copy link

I am using keyboard for shortcuts. I have mapped the release of the key f5 to toggle the camera between setFollow(getPlayerEntityIds()[0]) and setNormal(getPlayerEntityIds()[0]). I also have a game loop processing block hits. It works fine a few times before either erroring out with:

Drained Data:  <b''>
Last Message: <events.block.hits()>
Traceback (most recent call last):
  File "foo_bar.py", line <irrelevant>, in <module>
    events = game.events.pollBlockHits()
  File "/usr/lib/python3/dist-packages/mcpi/minecraft.py", line 172, in pollBlockHits
    return [BlockEvent.Hit(*list(map(int, e.split(",")))) for e in events]
  File "/usr/lib/python3/dist-packages/mcpi/minecraft.py", line 172, in <listcomp>
    return [BlockEvent.Hit(*list(map(int, e.split(",")))) for e in events]
TypeError: Hit() missing 4 required positional arguments: 'y', 'z', 'face', and 'entityId'

I didn't right-click during the test
or

Drained Data: <b'525'>
Last Message: <world.getPlayerIds()>
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self.kwargs)
  File "/usr/local/lib/python3.7/dist-packages/keyboard/_generic.py", line 58, in process
    if self.pre_process_event(event)
  File "/usr/local/lib/python3.7/dist-packages/keyboard/__init__.py", line 213, in pre_process_event
    key_hook(event)
  File "/usr/local/lib/python3.7/dist-packages/keyboard/__init__.py", line 516, in <lambda>
    return hook_key(key, lambda e: e.event_type == KEY_DOWN or callback(e), suppress=suppress)
  File "foo_bar.py", line <earlier_irrelevant>, in toggle_view
    game.camera.setFollow(game.getPlayerEntityIds()[0])
  File "usr/lib/python3/dist-packages/mcpi/minecraft.py", line 351, in getPlayerEntityIds
    return list(map(int, ids.split("|")))
ValueError: invalid literal for int() with base 10: ''

This one might be fixed with #24
Note that game is the return value of mcpi.minecraft.Minecraft.create()

I did type that by hand at 1:00 AM, so a response would be appreciated.

@xboxone08 xboxone08 changed the title Using keyboard is created unexpected errors inside the internal code of mcpi. Using keyboard is creating unexpected errors inside the internal code of mcpi. Jul 5, 2022
@xboxone08 xboxone08 changed the title Using keyboard is creating unexpected errors inside the internal code of mcpi. Using keyboard is creating unexpected errors inside the internal code of mcpi. Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant