From ce43fb6c3071caf2d5a671c1c1785237bda2c08b Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sun, 29 May 2022 00:50:29 +0300 Subject: [PATCH] chickens can hatch eggs, shears fix --- src/Player.php | 3 +++ src/world/Entity.php | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Player.php b/src/Player.php index 32a6c023..f8a649b4 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1848,6 +1848,9 @@ class Player{ ServerAPI::request()->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem(WOOL, $target->data["Color"], mt_rand(1,3))); $target->data["Sheared"] = 1; //i hope it means sheared right? $target->updateMetadata(); + if($slot->getMetadata() >= $slot->getMaxDurability()){ + $this->removeItem($slot->getID(), $slot->getMetadata(), $slot->count, true); + } $needsBreak = true; } } diff --git a/src/world/Entity.php b/src/world/Entity.php index 92d053ab..268df075 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -110,10 +110,15 @@ class Entity extends Position{ $this->size = 0.75; break; case ENTITY_MOB: - $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); - $this->update(); - //$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type)); - $this->size = 1; + switch($this->type){ + case MOB_CHICKEN: + $this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg")); + default: //no break uwu? + $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); + $this->update(); + //$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type)); + $this->size = 1; + } break; case ENTITY_FALLING: $this->setHealth(PHP_INT_MAX, "generic"); @@ -148,7 +153,10 @@ class Entity extends Position{ $this->close(); } } - + public function dropAnEgg(){ + 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")); + } public function updateFuse(){ if($this->closed === true){ return false; @@ -626,6 +634,7 @@ class Entity extends Position{ $d = array( 0 => array("type" => 0, "value" => $flags), 1 => array("type" => 1, "value" => $this->air), + //14 => array("type" => 0, "value" => 1), wip 16 => array("type" => 0, "value" => 0), 17 => array("type" => 6, "value" => array(0, 0, 0)), );