Improved Vector3 and Block handling, less allocation on Positions

This commit is contained in:
Shoghi Cervantes
2014-10-28 10:03:10 +01:00
parent 69492474e4
commit 144a871c07
18 changed files with 85 additions and 35 deletions

View File

@@ -40,7 +40,7 @@ use pocketmine\level\Location;
use pocketmine\level\Position;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Math;
use pocketmine\math\Vector3 as Vector3;
use pocketmine\math\Vector3;
use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\tag\Byte;
@@ -737,7 +737,7 @@ abstract class Entity extends Location implements Metadatable{
}
public function getPosition(){
return new Position($this->x, $this->y, $this->z, $this->level);
return Position::createPosition($this->x, $this->y, $this->z, $this->level);
}
public function getLocation(){

View File

@@ -88,7 +88,7 @@ class FallingBlock extends Entity{
if(!$this->dead){
if($this->ticksLived === 1){
$block = $this->level->getBlock($pos = Vector3::createVector($this->x, $this->y, $this->z)->floor());
$block = $this->level->getBlock($pos = Vector3::cloneVector($this)->floor());
if($block->getID() != $this->blockId){
$this->kill();
return true;
@@ -107,7 +107,7 @@ class FallingBlock extends Entity{
$this->motionY *= 1 - $this->drag;
$this->motionZ *= $friction;
$pos = Vector3::createVector($this->x, $this->y, $this->z)->floor();
$pos = Vector3::cloneVector($this)->floor();
if($this->onGround){
$this->kill();