Fixed CPU leak

This commit is contained in:
Shoghi Cervantes
2014-10-31 21:05:37 +01:00
parent ae06681b60
commit 8601405a88
73 changed files with 304 additions and 564 deletions

View File

@ -90,8 +90,7 @@ class FallingSand extends Entity{
if(!$this->dead){
if($this->ticksLived === 1){
$pos = Vector3::cloneVector($this);
$block = $this->level->getBlock($pos->floor());
$block = $this->level->getBlock((new Vector3($this->x, $this->y, $this->z))->floor());
if($block->getID() != $this->blockId){
$this->kill();
return true;
@ -110,8 +109,7 @@ class FallingSand extends Entity{
$this->motionY *= 1 - $this->drag;
$this->motionZ *= $friction;
$pos = Vector3::cloneVector($this);
$pos = $pos->floor();
$pos = (new Vector3($this->x, $this->y, $this->z))->floor();
if($this->onGround){
$this->kill();
@ -119,7 +117,7 @@ class FallingSand extends Entity{
if(!$block->isFullBlock){
$this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1));
}else{
$this->server->getPluginManager()->callEvent($ev = EntityBlockChangeEvent::createEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($pos, $ev->getTo(), true);
}
@ -154,7 +152,7 @@ class FallingSand extends Entity{
}
public function spawnTo(Player $player){
$pk = AddEntityPacket::getFromPool();
$pk = new AddEntityPacket();
$pk->type = FallingSand::NETWORK_ID;
$pk->eid = $this->getID();
$pk->x = $this->x;
@ -163,7 +161,7 @@ class FallingSand extends Entity{
$pk->did = -($this->getBlock() | $this->getDamage() << 0x10);
$player->dataPacket($pk);
$pk = SetEntityMotionPacket::getFromPool();
$pk = new SetEntityMotionPacket();
$pk->entities = [
[$this->getID(), $this->motionX, $this->motionY, $this->motionZ]
];