mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
baby sheep color is based on its parents colours
This commit is contained in:
parent
d990c7c6b3
commit
f36ab5aa6c
4 changed files with 19 additions and 6 deletions
|
|
@ -61,9 +61,9 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
|||
return $this->getAge() < 0;
|
||||
}
|
||||
|
||||
public function breed(){
|
||||
if($this->server->dhandle("entity.animal.breed", ["parent" => $this]) !== false){
|
||||
$c = $this->spawnChild();
|
||||
public function breed($mate){
|
||||
if($this->server->dhandle("entity.animal.breed", ["parent" => $this, "parent2" => $mate]) !== false){
|
||||
$c = $this->spawnChild($mate);
|
||||
$c->parent = $this; //TODO save eid to avoid memory leaks?
|
||||
$this->server->api->entity->spawnToAll($c);
|
||||
return $c;
|
||||
|
|
@ -108,7 +108,7 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
|||
$this->age = $i;
|
||||
}
|
||||
|
||||
public function spawnChild()
|
||||
public function spawnChild($mate)
|
||||
{
|
||||
return $this->server->api->entity->add($this->level, $this->class, $this->type, [
|
||||
"x" => $this->x + lcg_value() * mt_rand(-1, 1),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
interface Breedable{
|
||||
public function isFood($id); //original name
|
||||
|
||||
public function spawnChild();
|
||||
public function spawnChild($mate);
|
||||
|
||||
public function isInLove();
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ class TaskMate extends TaskBase
|
|||
/**
|
||||
* @var Animal $baby
|
||||
*/
|
||||
$baby = $ai->entity->breed();
|
||||
$baby = $ai->entity->breed($entpar2);
|
||||
//this.theAnimal.setGrowingAge(6000); TODO growing age?
|
||||
//this.targetMate.setGrowingAge(6000);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,19 @@ class Sheep extends Animal{
|
|||
$this->ai->addTask(new TaskFollowParent(1.0));
|
||||
}
|
||||
|
||||
public function spawnChild($mate)
|
||||
{
|
||||
$child = parent::spawnChild($mate);
|
||||
if($child instanceof Sheep){
|
||||
if($mate instanceof Sheep){
|
||||
$child->setColor(mt_rand(0, 1) == 0 ? $this->getColor() : $mate->getColor());
|
||||
}else{
|
||||
$child->setColor($this->getColor());
|
||||
}
|
||||
}
|
||||
return $child;
|
||||
}
|
||||
|
||||
public function createSaveData(){
|
||||
$data = parent::createSaveData();
|
||||
$data["Color"] = @$this->data["Color"];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue