baby sheep color is based on its parents colours

This commit is contained in:
GameHerobrine 2026-01-10 23:32:19 +03:00
parent d990c7c6b3
commit f36ab5aa6c
4 changed files with 19 additions and 6 deletions

View file

@ -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),