From 5eb3c52a3712045f57e9448e1f9288e9d359ce23 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 May 2019 15:40:58 +0100 Subject: [PATCH] added PunchBlockParticle, encapsulate more network logic --- src/pocketmine/Player.php | 7 +-- .../world/particle/PunchBlockParticle.php | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 src/pocketmine/world/particle/PunchBlockParticle.php diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b171a01fc..c0c32313c 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -113,6 +113,7 @@ use pocketmine\utils\UUID; use pocketmine\world\ChunkListener; use pocketmine\world\ChunkLoader; use pocketmine\world\format\Chunk; +use pocketmine\world\particle\PunchBlockParticle; use pocketmine\world\Position; use pocketmine\world\World; use function abs; @@ -1932,11 +1933,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, public function continueBreakBlock(Vector3 $pos, int $face) : void{ $block = $this->world->getBlock($pos); - $this->world->broadcastLevelEvent( - $pos, - LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, - $block->getRuntimeId() | ($face << 24) - ); + $this->world->addParticle($pos, new PunchBlockParticle($block, $face)); //TODO: destroy-progress level event } diff --git a/src/pocketmine/world/particle/PunchBlockParticle.php b/src/pocketmine/world/particle/PunchBlockParticle.php new file mode 100644 index 000000000..ff461c87e --- /dev/null +++ b/src/pocketmine/world/particle/PunchBlockParticle.php @@ -0,0 +1,48 @@ +block = $block; + $this->face = $face; + } + + public function encode(Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, $this->block->getRuntimeId() | ($this->face << 24), $pos); + } +}