PrismarineJS / prismarine-physics

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

Bedrock - Falling through partial blocks. #113

Open irkmandeer opened 8 months ago

irkmandeer commented 8 months ago

I'm attempting to get physics to work somewhat reliably on bedrock. There's a quirk I can seem to figure out.

When standing on a partial block, eg farmland, mud, etc, and the block gets converted into a solid block, eg. dirt or clay, the bot falls thought the block.

What is the the difference between how BBs are handled Java and Bedrock?

I have added a temporary hack in moveEntity() to prevent this from happening:

...

if (dy != 0 && entity.onGround) {
for (const blockBB of surroundingBBs) {
  dy = blockBB.computeOffsetY(playerBB, dy)
}

if (dy != 0 && entity.onGround) {

  const block = world.getBlock(pos)

  for (const shape of block.shapes) {

    const BB = new AABB(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5])
    BB.offset(block.position.x, block.position.y, block.position.z)

    console.log(JSON.stringify(shape), playerBB.intersects(BB))

    if (playerBB.intersects(BB)) {

      dy = Math.abs(block.position.y - pos.y)
      break
    }
  }
}

`