Implemented Vector3 List and AxisAlignedBB Pool to decrease object allocation

This commit is contained in:
Shoghi Cervantes
2014-10-27 15:39:20 +01:00
parent be948f99cc
commit 7abf52e615
39 changed files with 273 additions and 223 deletions

View File

@ -43,11 +43,8 @@ class Cactus extends Transparent{
}
public function getBoundingBox(){
if($this->boundingBox !== null){
return $this->boundingBox;
}
return $this->boundingBox = new AxisAlignedBB(
return AxisAlignedBB::getBoundingBoxFromPool(
$this->x + 0.0625,
$this->y,
$this->z + 0.0625,
@ -82,7 +79,7 @@ class Cactus extends Transparent{
if($this->getSide(0)->getID() !== self::CACTUS){
if($this->meta == 0x0F){
for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
$b = $this->getLevel()->getBlock(Vector3::createVector($this->x, $this->y + $y, $this->z));
if($b->getID() === self::AIR){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
if(!$ev->isCancelled()){