SpockBotMC / SpockBot

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

Error in smpmap.py #207

Closed DefinitlyEvil closed 8 years ago

DefinitlyEvil commented 8 years ago
Traceback (most recent call last):
  File "example.py", line 87, in <module>
    client.start(SERVER, 25565)
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\helpers\start.py", line 34, in start
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\core\event.py", line 25, in event_loop
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\core\event.py", line 34, in run_continuous
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\core\event.py", line 62, in emit
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\core\timers.py", line 132, in tick
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\core\timers.py", line 28, in update
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\core\timers.py", line 31, in fire
  File "D:\Github\example_plugin.py", line 109, in periodic_event_handler
    block_pos.z)
  File "D:\Programs\Python35\lib\site-packages\spockbot-0.1.3-py3.5.egg\spockbot\plugins\tools\smpmap.py", line 160, in get_block
TypeError: list indices must be integers or slices, not float
Gjum commented 8 years ago

@nickelpro sounds like it wasn't such a good idea to remove that line bf7002f89e349abcb70db871cc9deba51e054b37

DefinitlyEvil commented 8 years ago

@Gjum Thx for rapid respond, so it can be fixed now?

DefinitlyEvil commented 8 years ago

Btw it also says list indicies must be integer at line 50:

        return self.data[x + ((y * 16) + z) * 16]
rom1504 commented 8 years ago

@DefinitlyEvil if you want it to work right now, convert the position to int yourself before calling the get_block function

DefinitlyEvil commented 8 years ago

@rom1504 I was playing around with example.py. xD And TONs of errors messed me up.

Gjum commented 8 years ago

I'm not sure if we will "fix" that, because you are supposed to only supply integer (block) coordinates.

So instead of get_block(floaty_pos), it should be get_block(floaty_pos.floor()).

The examples are quite outdated, see also #188.

DefinitlyEvil commented 8 years ago

@Gjum Okay. ;P Thanks for making this awesome project and thanks for noticing me about that example script. xD

DefinitlyEvil commented 8 years ago

@Gjum Btw I didn't call get_block() in example.py, it seems that some other script invoked it. xD

nickelpro commented 8 years ago

I dislike having to do that conversion there. Rightfully if we do it there we should do it for all the get and set functions in smpmap.

Really I'd like to just track down everywhere we're passing floats to smpmap, fix them, and then just ban passing floats when you really should pass an integer

Gjum commented 8 years ago

I agree. Although the error message can be a bit misleading.

nickelpro commented 8 years ago

So we're agreed this is not an error in smpmap then. This is a problem with our horribly outdated examples. I'll put it on my "high priority" ToDo list along with vehicle Physics and auth tokens

DefinitlyEvil commented 8 years ago

@nickelpro Thx so much. Muah!

Gjum commented 8 years ago

fixed in c09dbfaf85f936dce8ce99e6f99be057e51167b0

subdavis commented 8 years ago

This appears to still be an issue...

In offline mode, the bot crashes after joining the game on TypeError: list indices must be integers, not float

Full stack trace:

[INFO]: My position: PlayerPosition(0, 0, 0) pitch: 0.0 yaw: 0.0
[DEBUG]: EVENTCORE: Exception while emitting physics_tick None
[DEBUG]: EVENTCORE: Exception while emitting event_tick None
Traceback (most recent call last):
  File "example.py", line 56, in <module>
    client.start(SERVER, 25565)
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/helpers/start.py", line 34, in start
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/event.py", line 29, in event_loop
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/event.py", line 36, in run_continuous
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/event.py", line 62, in emit
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/timers.py", line 132, in tick
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/timers.py", line 28, in update
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/timers.py", line 31, in fire
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/ticker.py", line 19, in client_tick
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/core/event.py", line 62, in emit
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/helpers/physics.py", line 109, in physics_tick
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/helpers/physics.py", line 152, in get_mtv
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/tools/collision.py", line 43, in check_collision
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/tools/collision.py", line 51, in block_collision
  File "build/bdist.linux-x86_64/egg/spockbot/plugins/tools/smpmap.py", line 230, in get_block
TypeError: list indices must be integers, not float

I checked, and my code does have the fix applied in commit c09dbfa.

rom1504 commented 8 years ago

@suBDavis you are flooring the position before passing it to get_block, right ?

subdavis commented 8 years ago

@rom1504 I'm using the example plugin, which is indeed performing the floor on line 100 block_pos = self.clientinfo.position.floor()

nickelpro commented 8 years ago

Apparently Physics is generating floating point block positions which I don't understand

subdavis commented 8 years ago

Are you able to reproduce?

I was trying to document my entire configuration (python version, steps to install, etc) and I started over. I'm now unable to reproduce that error.

nickelpro commented 8 years ago

I just said that based on the stack trace. That sort of thing should be impossible with the current code base. Old version?

subdavis commented 8 years ago

Definitely not. both came from a git clone https://github.com/SpockBotMC/SpockBot

However, I could have had some outdated packages... or... something. I originally installed SpockBot at the system level, and then tried to repro it in a virtual environment, which would have installed the dependencies fresh from pip.

nickelpro commented 8 years ago

Dependencies don't enter into it. The offending get_block call is here: https://github.com/SpockBotMC/SpockBot/blob/master/spockbot/plugins/tools/collision.py#L51

Which takes a block position from a generator that clearly floors its base position: https://github.com/SpockBotMC/SpockBot/blob/master/spockbot/plugins/tools/collision.py#L15-L20

If this can't be reproduced I'm not sure how to fix