better body placement checks

This commit is contained in:
GameHerobrine 2025-04-12 21:14:09 +03:00
parent 933b92f41e
commit 0b7fd74175
2 changed files with 23 additions and 3 deletions

View file

@ -501,9 +501,16 @@ class BlockAPI{
$hand->position($block);
//$face = -1;
}
if($hand->isSolid === true and $block->boundingBox->intersectsWith($player->entity->boundingBox) && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
return $this->cancelAction($block, $player, false); //Entity in block
if($hand->isSolid === true && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
$aabb = $hand->getAABB($block->level, $block->x, $block->y, $block->z);
$playerbb = $player->entity->boundingBox;
//$aabb->intersectsWith($playerbb) is not good enough for this case
//minY+0.21 is used to stop sneaking from triggering action cancelling
if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY+0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){
return $this->cancelAction($block, $player, false); //Entity in block
}
}
if($this->server->api->dhandle("player.block.place", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) === false){