PrismarineJS / prismarine-physics

Provide the physics engine for minecraft entities
MIT License
35 stars 41 forks source link

Bot can't ride bubble elevators #11

Closed OldStarchy closed 4 years ago

OldStarchy commented 4 years ago

Taken from https://github.com/PrismarineJS/mineflayer/issues/1229:

The bot can't ride bubble elevators. I walked the bot into the bubble column and it just stands at the bottom on the soul sand. Leading the bot into the top of the elevator, it just falls all the way down to the bottom.

Karang commented 4 years ago

Yes indeed, that would be a nice and useful feature to implement. First step is doing some research about how this feature is implemented in vanilla. There is multiple way to do that:

The main infos that are needed to implement this are:

With those questions answered it would be easy to implement.

TheDudeFromCI commented 4 years ago

Useful link: https://minecraft.gamepedia.com/Bubble_Column

TheDudeFromCI commented 4 years ago

Okay, so it looks like Bubble Columns are implemented as a block type that water is converted into. The two types are upward and downward, which basically appear to act the same, just in opposite directions. The implementation is pretty straightforward, just increasing velocity by a set amount each game tick that an entity is inside it.

The average movement upward speed is 11m/s, downward speed is 4.9m/s. But, as the bubble column is acceleration-based, these are not the actual values. The code will need to be used for that.

Bubble columns were implemented in 1.13 and have remained unchanged since.

TheDudeFromCI commented 4 years ago

It's also worth noting that boats moving over downward bubbles will be pulled under after a short delay. Entities in upward bubbles will bounce on top of the bubbles over the water, however, this is likely a side effect of the upward acceleration launching the entity in the air.

IdanHo commented 4 years ago

The 1.16 implementation is very simple, and is velocity based (note that the boolean drag parameter is true for downwards columns and false for upwards): image onBubbleColumnSurfaceCollision is for water blocks that are on the surface (aka the block above is air), onBubbleColumnSurfaceCollision is for all other ones

IdanHo commented 4 years ago

Implemented this, just doing some testing and then ill open a pull.