Improved entity ticking

This commit is contained in:
Shoghi Cervantes
2014-10-06 13:10:59 +02:00
parent d53ba52d32
commit de11cce154
4 changed files with 34 additions and 19 deletions

View File

@@ -46,6 +46,8 @@ class DroppedItem extends Entity{
protected $gravity = 0.04;
protected $drag = 0.02;
public $canCollide = false;
protected function initEntity(){
$this->namedtag->id = new String("id", "Item");
$this->setMaxHealth(5);
@@ -87,7 +89,7 @@ class DroppedItem extends Entity{
$friction = 1 - $this->drag;
if($this->onGround){
if($this->onGround and ($this->motionX != 0 or $this->motionZ != 0)){
$friction = $this->getLevel()->getBlock(new Vector3($this->getFloorX(), $this->getFloorY() - 1, $this->getFloorZ()))->frictionFactor * $friction;
}

View File

@@ -134,6 +134,8 @@ abstract class Entity extends Position implements Metadatable{
public $fireTicks;
public $airTicks;
public $namedtag;
public $canCollide = true;
protected $isStatic = false;
protected $isColliding = false;
@@ -555,7 +557,9 @@ abstract class Entity extends Position implements Metadatable{
$pk->entities = [
[$this->getID(), $this->motionX, $this->motionY, $this->motionZ]
];
Server::broadcastPacket($this->hasSpawned, $pk);
foreach($this->hasSpawned as $player){
$player->dataPacket($pk);
}
if($this instanceof Player){
$this->motionX = 0;

View File

@@ -43,6 +43,8 @@ class FallingBlock extends Entity{
protected $drag = 0.02;
protected $blockId = 0;
public $canCollide = false;
protected function initEntity(){
$this->namedtag->id = new String("id", "FallingSand");
if(isset($this->namedtag->Tile)){