chickens do not drop eggs after they were killed/disappeared for other reason

This commit is contained in:
GameHerobrine 2022-07-11 23:40:32 +03:00
parent f5ad87e4a5
commit fd46b1e4f5

View file

@ -5,7 +5,7 @@ class Chicken extends Animal{
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$server = ServerAPI::request();
$server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg"));
$server->schedule(1, array($this, "dropAnEgg"));
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 4, "generic");
$this->update();
//$this->setName('Chicken');
@ -15,8 +15,11 @@ class Chicken extends Animal{
return $id === PUMPKIN_SEEDS || $id === MELON_SEEDS || $id === BEETROOT_SEEDS || $id === WHEAT_SEEDS;
}
public function dropAnEgg(){
if($this->closed){
return;
}
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG,0,1));
$this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg"));
$this->server->schedule(1, array($this, "dropAnEgg"));
}
public function getDrops(){