Moved network ids to constants, improved some entity methods, more performance

This commit is contained in:
Shoghi Cervantes
2015-05-30 23:59:24 +02:00
parent 32680843fa
commit 9e14435dbb
58 changed files with 197 additions and 436 deletions

View File

@ -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;
}