Enchantment: Implement Silk Touch (#1912)

This commit is contained in:
Dylan K. Taylor
2018-01-14 13:37:27 +00:00
committed by GitHub
parent 96f6362117
commit 8d7c65585c
18 changed files with 92 additions and 2 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
@ -56,7 +57,10 @@ class Ice extends Transparent{
}
public function onBreak(Item $item, Player $player = null) : bool{
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::WATER), true);
if(!$item->hasEnchantment(Enchantment::SILK_TOUCH)){
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::WATER), true);
}
return parent::onBreak($item, $player);
}
public function ticksRandomly() : bool{