mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
remove World->isFullBlock(), add Block->isFullCube(), clean up some BB mess
This commit is contained in:
@ -46,6 +46,7 @@ use pocketmine\world\Position;
|
||||
use pocketmine\world\World;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function dechex;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
@ -713,6 +714,15 @@ class Block{
|
||||
return AxisAlignedBB::one();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isFullCube() : bool{
|
||||
$bb = $this->getCollisionBoxes();
|
||||
|
||||
return count($bb) === 1 and $bb[0]->getAverageEdgeLength() >= 1; //TODO: average length 1 != cube
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos1
|
||||
* @param Vector3 $pos2
|
||||
|
@ -35,8 +35,7 @@ class Thin extends Transparent{
|
||||
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$side = $this->getSide($facing);
|
||||
//FIXME: currently there's no proper way to tell if a block is a full-block, so we check the bounding box size
|
||||
if($side instanceof Thin or ($bb = $side->getBoundingBox()) !== null and $bb->getAverageEdgeLength() >= 1){
|
||||
if($side instanceof Thin or $side->isFullCube()){
|
||||
$this->connections[$facing] = true;
|
||||
}else{
|
||||
unset($this->connections[$facing]);
|
||||
|
@ -1120,20 +1120,6 @@ class World implements ChunkManager{
|
||||
return $collides;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Block $pos
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFullBlock(Block $pos) : bool{
|
||||
if($pos->isSolid()){
|
||||
return true;
|
||||
}
|
||||
$bb = $pos->getBoundingBox();
|
||||
|
||||
return $bb !== null and $bb->getAverageEdgeLength() >= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
* @param AxisAlignedBB $bb
|
||||
@ -2565,7 +2551,7 @@ class World implements ChunkManager{
|
||||
$y = (int) min($max - 2, $v->y);
|
||||
$wasAir = $this->getBlockAt($x, $y - 1, $z)->getId() === BlockLegacyIds::AIR; //TODO: bad hack, clean up
|
||||
for(; $y > 0; --$y){
|
||||
if($this->isFullBlock($this->getBlockAt($x, $y, $z))){
|
||||
if($this->getBlockAt($x, $y, $z)->isFullCube()){
|
||||
if($wasAir){
|
||||
$y++;
|
||||
break;
|
||||
@ -2576,8 +2562,8 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
for(; $y >= 0 and $y < $max; ++$y){
|
||||
if(!$this->isFullBlock($this->getBlockAt($x, $y + 1, $z))){
|
||||
if(!$this->isFullBlock($this->getBlockAt($x, $y, $z))){
|
||||
if(!$this->getBlockAt($x, $y + 1, $z)->isFullCube()){
|
||||
if(!$this->getBlockAt($x, $y, $z)->isFullCube()){
|
||||
return new Position($spawn->x, $y === (int) $spawn->y ? $spawn->y : $y, $spawn->z, $this);
|
||||
}
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user