added custom update for painting

This commit is contained in:
GameHerobrine 2024-11-27 15:54:45 +03:00
parent 7c733886c2
commit d1121e862e

View file

@ -38,6 +38,22 @@ class Painting extends Entity{
} }
} }
public $counter = 0;
public function update($now){
if($this->closed === true){
return false;
}
if(++$this->counter >= 100){
$this->counter = 0;
if(!$this->survives() && !$this->dead){ //maybe dont check entity collision?
$this->makeDead("nosurvive");
}
}
return true;
}
public function setRandomMotive($dir){ public function setRandomMotive($dir){
$tochoose = []; $tochoose = [];
foreach(PaintingItem::$motives as $name => $motive){ foreach(PaintingItem::$motives as $name => $motive){
@ -50,8 +66,10 @@ class Painting extends Entity{
} }
if(count($tochoose) > 0){ if(count($tochoose) > 0){
$ind = mt_rand(0, count($tochoose)-1); $ind = mt_rand(0, count($tochoose)-1);
}else{ }else{ //shouldnt be possible in vanilla but possible here
$ind = 0; $this->motive = "Kebab";
$this->setDirection($dir);
return;
} }
$this->motive = $tochoose[$ind]; $this->motive = $tochoose[$ind];
@ -176,7 +194,7 @@ class Painting extends Entity{
$data["zPos"] = $this->zPos; $data["zPos"] = $this->zPos;
return $data; return $data;
} }
public function spawn($player){ public function spawn($player){
$pk = new AddPaintingPacket; $pk = new AddPaintingPacket;
$pk->eid = $this->eid; $pk->eid = $this->eid;