Added missing sound for creating grass path and farmland

closes #2776
This commit is contained in:
Dylan K. Taylor
2022-01-19 21:49:05 +00:00
parent a0bb7059c1
commit 8cdfef7861
3 changed files with 60 additions and 3 deletions

View File

@ -28,6 +28,7 @@ use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\sound\ItemUseOnBlockSound;
class Dirt extends Opaque{
@ -60,7 +61,10 @@ class Dirt extends Opaque{
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($face === Facing::UP and $item instanceof Hoe){
$item->applyDamage(1);
$this->position->getWorld()->setBlock($this->position, $this->coarse ? VanillaBlocks::DIRT() : VanillaBlocks::FARMLAND());
$newBlock = $this->coarse ? VanillaBlocks::DIRT() : VanillaBlocks::FARMLAND();
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
$this->position->getWorld()->setBlock($this->position, $newBlock);
return true;
}

View File

@ -33,6 +33,7 @@ use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\utils\Random;
use pocketmine\world\generator\object\TallGrass as TallGrassObject;
use pocketmine\world\sound\ItemUseOnBlockSound;
use function mt_rand;
class Grass extends Opaque{
@ -97,12 +98,16 @@ class Grass extends Opaque{
return true;
}elseif($item instanceof Hoe){
$item->applyDamage(1);
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::FARMLAND());
$newBlock = VanillaBlocks::FARMLAND();
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
$this->position->getWorld()->setBlock($this->position, $newBlock);
return true;
}elseif($item instanceof Shovel and $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){
$item->applyDamage(1);
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::GRASS_PATH());
$newBlock = VanillaBlocks::GRASS_PATH();
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
$this->position->getWorld()->setBlock($this->position, $newBlock);
return true;
}