mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Moved network ids to constants, improved some entity methods, more performance
This commit is contained in:
@ -988,10 +988,11 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
/**
|
||||
* @param AxisAlignedBB $bb
|
||||
* @param bool $targetFirst
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getCollisionBlocks(AxisAlignedBB $bb){
|
||||
public function getCollisionBlocks(AxisAlignedBB $bb, $targetFirst = false){
|
||||
$minX = Math::floorFloat($bb->minX);
|
||||
$minY = Math::floorFloat($bb->minY);
|
||||
$minZ = Math::floorFloat($bb->minZ);
|
||||
@ -1001,17 +1002,31 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
$collides = [];
|
||||
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($y = $minY; $y <= $maxY; ++$y){
|
||||
$block = $this->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||
if($block->getId() !== 0 and $block->collidesWithBB($bb)){
|
||||
$collides[] = $block;
|
||||
if($targetFirst){
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($y = $minY; $y <= $maxY; ++$y){
|
||||
$block = $this->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||
if($block->getId() !== 0 and $block->collidesWithBB($bb)){
|
||||
return [$block];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($y = $minY; $y <= $maxY; ++$y){
|
||||
$block = $this->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||
if($block->getId() !== 0 and $block->collidesWithBB($bb)){
|
||||
$collides[] = $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $collides;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user