mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
better body placement checks
This commit is contained in:
parent
933b92f41e
commit
0b7fd74175
2 changed files with 23 additions and 3 deletions
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -17,6 +17,19 @@ class FenceBlock extends TransparentBlock{
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
$v9 = self::canConnectTo($level, $x, $y, $z - 1);
|
||||
$v10 = self::canConnectTo($level, $x, $y, $z + 1);
|
||||
$v11 = self::canConnectTo($level, $x - 1, $y, $z);
|
||||
$v12 = self::canConnectTo($level, $x + 1, $y, $z);
|
||||
$minX = $v11 ? 0 : 0.375;
|
||||
$minZ = $v9 ? 0 : 0.375;
|
||||
$maxZ = $v10 ? 1 : 0.625;
|
||||
$maxX = !$v12 ? 0.625 : 1;
|
||||
StaticBlock::setBlockBounds(static::$blockID, $minX, 0, $minZ, $maxX, 1.5, $maxZ);
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$v8 = self::canConnectTo($level, $x, $y, $z - 1);
|
||||
$v9 = self::canConnectTo($level, $x, $y, $z + 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue