entities will update every tick, fixed air(hopefully)

This commit is contained in:
GameHerobrine 2023-12-28 21:13:09 +03:00
parent 338902af19
commit a6f2c7e257
2 changed files with 10 additions and 14 deletions

View file

@ -1331,6 +1331,7 @@ class Player{
if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){ if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){
return; return;
} }
ConsoleAPI::debug("Got packet: {$packet->pid()}");
switch($packet->pid()){ switch($packet->pid()){
case 0x01: case 0x01:
break; break;
@ -1917,7 +1918,7 @@ class Player{
$this->teleport($this->spawnPosition); $this->teleport($this->spawnPosition);
if($this->entity instanceof Entity){ if($this->entity instanceof Entity){
$this->entity->fire = 0; $this->entity->fire = 0;
$this->entity->air = 300; $this->entity->air = $this->entity->maxAir;
$this->entity->setHealth(20, "respawn", true); $this->entity->setHealth(20, "respawn", true);
$this->entity->updateMetadata(); $this->entity->updateMetadata();
}else{ }else{

View file

@ -21,6 +21,7 @@ class Entity extends Position
public $boundingBox; public $boundingBox;
public $age; public $age;
public $air; public $air;
public $maxAir = 300;
public $spawntime; public $spawntime;
public $dmgcounter; public $dmgcounter;
public $eid; public $eid;
@ -103,7 +104,7 @@ class Entity extends Position
$this->health = 20; $this->health = 20;
$this->hasGravity = false; $this->hasGravity = false;
$this->dmgcounter = array(0, 0, 0); $this->dmgcounter = array(0, 0, 0);
$this->air = 200; $this->air = $this->maxAir;
$this->fire = 0; $this->fire = 0;
$this->crouched = false; $this->crouched = false;
$this->invincible = false; $this->invincible = false;
@ -360,7 +361,7 @@ class Entity extends Position
if($this->dead === true){ if($this->dead === true){
$this->fire = 0; $this->fire = 0;
$this->air = 200; $this->air = $this->maxAir;
return false; return false;
} }
if($this->isInVoid()){ if($this->isInVoid()){
@ -423,10 +424,10 @@ class Entity extends Position
$this->harm(2, "water"); $this->harm(2, "water");
} }
}else{ }else{
$this->air = 200; //TODO $this->maxAir; $this->air = $this->maxAir;
} }
}else{ }else{
$this->air = 200; //TODO $this->maxAir; $this->air = $this->maxAir;
} }
} }
@ -500,14 +501,8 @@ class Entity extends Position
$this->lastUpdate = $now; $this->lastUpdate = $now;
return; return;
} }
$tdiff = $now - $this->lastUpdate;
if($this->tickCounter === 0){ $hasUpdate = $this->environmentUpdate();
$this->tickCounter = 1;
$hasUpdate = $this->environmentUpdate();
} else{
$hasUpdate = true;
$this->tickCounter = 0;
}
if($this->closed === true){ if($this->closed === true){
return false; return false;
@ -1418,7 +1413,7 @@ class Entity extends Position
public function makeDead($cause){ public function makeDead($cause){
if($this->server->api->dhandle("entity.death", ["entity" => $this, "cause" => $cause]) === false) return false; if($this->server->api->dhandle("entity.death", ["entity" => $this, "cause" => $cause]) === false) return false;
$this->spawnDrops(); $this->spawnDrops();
$this->air = 200; $this->air = $this->maxAir;
$this->fire = 0; $this->fire = 0;
$this->crouched = false; $this->crouched = false;
$this->fallY = false; $this->fallY = false;