woder/TorchBot

Gravity doesn't work properly

Closed this issue · 5 comments

It bugs him out quite badly

Waiting on mcp as of now to fix this.

Could you explain what mcp is? Is this impossible to fix without it?

Minecraft coder pack, I believe this is possible to fix without - just that I have no idea how gravity works so if you know how that works you can go ahead an implement it. Its in the movement handler I believe.

We need to move more smoothly than currently for gravity to work. As far as I can tell, we are currently warping 1 block at a time, just at a slow enough pace so that the server treats it as a lagged connection which is moving at the normal rate. Under those conditions, I don't think it is possible to have functional gravity. In order to make gravity work, I think we'd need to set a goal-position, potentially 1 Tile at a time, and each tick have the bot move a set distance (4.317 blocks/second, or 0.21585 blocks/tick) closer to the goal-position until it reaches it. It might help to round this figure so that we reach each goal position in an integer number of ticks. This of course, would depend if we are walking diagonally (+-1, +-1) or along an axis (+-1,0) or (0,+-1).

If we changed the movement code to reflect this, we could then implement applyGravity() on each tick with an acceleration of (0.08 blocks/tick) with a drag of (0.02*velocity blocks/tick) afterwards.

I found these numbers on the minecraft wiki at http://minecraft.gamepedia.com/Gravity#Motion_of_entities
and http://minecraft.gamepedia.com/The_Player#Movement

This is now functional, acceleration still isn't perfect but it works.