diff --git a/src/ipad54/composter/block/Composter.php b/src/ipad54/composter/block/Composter.php index 356bd9c..4b0c851 100644 --- a/src/ipad54/composter/block/Composter.php +++ b/src/ipad54/composter/block/Composter.php @@ -4,6 +4,7 @@ namespace ipad54\composter\block; +use pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket; use ipad54\composter\sound\ComposteEmptySound; use ipad54\composter\sound\ComposteFillSound; use ipad54\composter\sound\ComposteFillSuccessSound; @@ -95,19 +96,30 @@ public function getStateBitmask(): int return 0b1111; } + private function spawnParticleEffect(Vector3 $position): void + { + $packet = new SpawnParticleEffectPacket(); + $packet->position = $position; + $packet->particleName = "minecraft:crop_growth_emitter"; + $recipients = $this->position->getWorld()->getViewersForPosition($this->position); + foreach($recipients as $player){ + $player->getNetworkSession()->sendDataPacket($packet); + } + } + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null): bool { if ($this->fill >= 8) { $this->fill = 0; $this->position->getWorld()->setBlock($this->position, $this); $this->position->getWorld()->addSound($this->position, new ComposteEmptySound()); - $this->position->getWorld()->dropItem($this->position, VanillaItems::BONE_MEAL()); + $this->position->getWorld()->dropItem($this->position->add(0.5, 1.1, 0.5), VanillaItems::BONE_MEAL()); return true; } if (isset($this->ingridients[$item->getId()]) && $this->fill < 7) { $item->pop(); + $this->spawnParticleEffect($this->position->add(0.5, 0.5, 0.5)); if ($this->fill == 0) { - $this->incrimentFill(true); return true; } @@ -121,7 +133,6 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player return true; } - public function incrimentFill(bool $playsound = false): bool { if ($this->fill >= 7) { @@ -146,4 +157,4 @@ public function onScheduledUpdate(): void $this->position->getWorld()->addSound($this->position, new ComposteReadySound()); } } -} \ No newline at end of file +}