From 3274db3ddcf02d2cda20a5a6107d826248e2d62a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 19 Aug 2019 18:57:26 +0100 Subject: [PATCH] DustParticle constructor now uses Color object --- changelogs/4.0-snapshot.md | 1 + src/command/defaults/ParticleCommand.php | 3 ++- src/world/particle/DustParticle.php | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/changelogs/4.0-snapshot.md b/changelogs/4.0-snapshot.md index 09ada3c52a..d8d617fa1d 100644 --- a/changelogs/4.0-snapshot.md +++ b/changelogs/4.0-snapshot.md @@ -699,6 +699,7 @@ This version features substantial changes to the network system, improving coher - `Location` has been moved to `pocketmine\entity\Location`. #### Particles +- `DustParticle->__construct()` now accepts a `pocketmine\utils\Color` object instead of `r, g, b, a`. - `pocketmine\world\particle\Particle` no longer extends `pocketmine\math\Vector3`, and has been converted to an interface. - Added the following `Particle` classes: - `DragonEggTeleportParticle` diff --git a/src/command/defaults/ParticleCommand.php b/src/command/defaults/ParticleCommand.php index 6a2c380f97..f3974d3217 100644 --- a/src/command/defaults/ParticleCommand.php +++ b/src/command/defaults/ParticleCommand.php @@ -31,6 +31,7 @@ use pocketmine\item\VanillaItems; use pocketmine\lang\TranslationContainer; use pocketmine\math\Vector3; use pocketmine\player\Player; +use pocketmine\utils\Color; use pocketmine\utils\Random; use pocketmine\utils\TextFormat; use pocketmine\world\particle\AngryVillagerParticle; @@ -224,7 +225,7 @@ class ParticleCommand extends VanillaCommand{ }elseif(strpos($name, "blockdust_") === 0){ $d = explode("_", $name); if(count($d) >= 4){ - return new DustParticle(((int) $d[1]) & 0xff, ((int) $d[2]) & 0xff, ((int) $d[3]) & 0xff, isset($d[4]) ? ((int) $d[4]) & 0xff : 255); + return new DustParticle(new Color(((int) $d[1]) & 0xff, ((int) $d[2]) & 0xff, ((int) $d[3]) & 0xff, isset($d[4]) ? ((int) $d[4]) & 0xff : 255)); } } diff --git a/src/world/particle/DustParticle.php b/src/world/particle/DustParticle.php index 483e87cd80..c698062396 100644 --- a/src/world/particle/DustParticle.php +++ b/src/world/particle/DustParticle.php @@ -24,9 +24,10 @@ declare(strict_types=1); namespace pocketmine\world\particle; use pocketmine\network\mcpe\protocol\types\ParticleIds; +use pocketmine\utils\Color; class DustParticle extends GenericParticle{ - public function __construct(int $r, int $g, int $b, int $a = 255){ - parent::__construct(ParticleIds::DUST, (($a & 0xff) << 24) | (($r & 0xff) << 16) | (($g & 0xff) << 8) | ($b & 0xff)); + public function __construct(Color $color){ + parent::__construct(ParticleIds::DUST, $color->toARGB()); } }