diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index f2623019f..6b74f723c 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -28,6 +28,10 @@ use pocketmine\Player; class Anvil extends Fallable{ + const TYPE_NORMAL = 0; + const TYPE_SLIGHTLY_DAMAGED = 4; + const TYPE_VERY_DAMAGED = 8; + protected $id = self::ANVIL; public function isSolid(){ @@ -51,7 +55,12 @@ class Anvil extends Fallable{ } public function getName(){ - return "Anvil"; + static $names = [ + self::TYPE_NORMAL => "Anvil", + self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil", + self::TYPE_VERY_DAMAGED => "Very Damaged Anvil" + ]; + return $names[$this->meta & 0x0c] ?? "Anvil"; } public function getToolType(){ @@ -66,10 +75,16 @@ class Anvil extends Fallable{ return true; } + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ + $direction = ($player !== null ? $player->getDirection() : 0) & 0x03; + $this->meta = ($this->meta & 0x0c) | $direction; + $this->getLevel()->setBlock($block, $this, true, true); + } + public function getDrops(Item $item){ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [$this->id, 0, 1], //TODO break level + [$this->id, $this->meta & 0x0c, 1], ]; }else{ return [];