mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
added custom update for painting
This commit is contained in:
parent
7c733886c2
commit
d1121e862e
1 changed files with 21 additions and 3 deletions
|
|
@ -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];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue