mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Improved entity ticking
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)){
|
||||
|
||||
Reference in New Issue
Block a user