PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.95k stars 904 forks source link

placeBlock update the wrong block type for some block #317

Closed rom1504 closed 9 years ago

rom1504 commented 9 years ago

https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/inventory.js#L257

Netherwart item has an id of 372. Netherwart BLOCK however has an ID of 115.

We need the item-> placed block correspondence data to fix that issue

Are many blocks concerned ? about 20 apparently

To extract that data we can use the fact that both the item id and block id are in http://minecraft.gamepedia.com/Netherwart#Data_values

rom1504 commented 9 years ago

Maybe placeBlock shouldn't be updating the block, and instead it should call a callback when the correct block has been placed by waiting for the correct blockUpdate event. That requires to solve the same problem though (knowing which block should have been placed).

Related to #261

A reason why we might need to update the block right now : when placing a block under you after jumping, the physics engine need to know not to go through the placed block.

So anyway we need to know what block should have been placed.

rom1504 commented 9 years ago

Knowing what block should be placed is not really important : listening to the blockUpdate and checking if the block changed is enough to know if block_place worked or not. Fixed in 2ff681ed032a3451af6f28af3fc509c0374c61f2