From 001fab922ff16c179b37a26f1f46b1a0a7781dbc Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 14 Jan 2023 16:47:57 +0300 Subject: [PATCH] sheep can be colored once again --- src/entity/animal/Sheep.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php index 57f341bf..3b7a9826 100644 --- a/src/entity/animal/Sheep.php +++ b/src/entity/animal/Sheep.php @@ -50,12 +50,19 @@ class Sheep extends Animal{ } public function getColor(){ - return $this->data["Color"] & 16; //color === 16 -> color = 0, color === 17 -> color = 1 ... + return $this->data["Color"]; //color === 16 -> color = 0, color === 17 -> color = 1 ... } + public function switchColorMeta($meta){ + return abs($meta - 15); + } + + public function setColor($meta){ + $this->data["Color"] = $meta; + } public function getDrops(){ return ($this->isBaby() || $this->isSheared()) ? parent::getDrops() : [ - [WOOL, $this->getColor() & 0x0F, 1] + [WOOL, $this->getColor(), 1] ]; } @@ -72,10 +79,16 @@ class Sheep extends Animal{ $this->server->api->entity->drop($this, BlockAPI::getItem(WOOL, $this->getColor(), mt_rand(1, 3))); //$this->server->schedule(20, [$this, "eatGrass"]); if($slot->getMetadata() >= $slot->getMaxDurability()){ - $this->removeItem($slot->getID(), $slot->getMetadata(), $slot->count, true); + $e->player->removeItem($slot->getID(), $slot->getMetadata(), $slot->count, true); } } return true; + }elseif($slot->getID() === DYE){ + $this->setColor($this->switchColorMeta($slot->getMetadata())); + + if(($e->player->gamemode & 0x01) === SURVIVAL){ + $e->player->removeItem($slot->getID(), $slot->getMetadata(), 1, true); + } } } return parent::interactWith($e, $action);