Remove remaining direct protocol usages for particles

This commit is contained in:
Dylan K. Taylor
2019-03-26 17:00:00 +00:00
parent 1bf0802275
commit 37b5ad8350
5 changed files with 102 additions and 10 deletions

View File

@ -27,11 +27,11 @@ use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\level\particle\EndermanTeleportParticle;
use pocketmine\level\sound\EndermanTeleportSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\RayTraceResult;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class EnderPearl extends Throwable{
public const NETWORK_ID = self::ENDER_PEARL;
@ -51,7 +51,7 @@ class EnderPearl extends Throwable{
//TODO: check end gateways (when they are added)
//TODO: spawn endermites at origin
$this->level->broadcastLevelEvent($owner, LevelEventPacket::EVENT_PARTICLE_ENDERMAN_TELEPORT);
$this->level->addParticle($owner, new EndermanTeleportParticle());
$this->level->addSound($owner, new EndermanTeleportSound());
$owner->teleport($target = $event->getRayTraceResult()->getHitVector());
$this->level->addSound($target, new EndermanTeleportSound());

View File

@ -24,9 +24,8 @@ declare(strict_types=1);
namespace pocketmine\entity\projectile;
use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\level\particle\PotionSplashParticle;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\utils\Color;
use function mt_rand;
class ExperienceBottle extends Throwable{
@ -39,7 +38,7 @@ class ExperienceBottle extends Throwable{
}
public function onHit(ProjectileHitEvent $event) : void{
$this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_PARTICLE_SPLASH, (new Color(0x38, 0x5d, 0xc6))->toARGB());
$this->level->addParticle($this, new PotionSplashParticle(PotionSplashParticle::DEFAULT_COLOR()));
$this->level->broadcastLevelSoundEvent($this, LevelSoundEventPacket::SOUND_GLASS);
$this->level->dropExperience($this, mt_rand(3, 11));

View File

@ -32,8 +32,8 @@ use pocketmine\event\entity\ProjectileHitBlockEvent;
use pocketmine\event\entity\ProjectileHitEntityEvent;
use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\item\Potion;
use pocketmine\level\particle\PotionSplashParticle;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\utils\Color;
use function round;
@ -68,9 +68,7 @@ class SplashPotion extends Throwable{
$hasEffects = true;
if(empty($effects)){
$colors = [
new Color(0x38, 0x5d, 0xc6) //Default colour for splash water bottle and similar with no effects.
];
$particle = new PotionSplashParticle(PotionSplashParticle::DEFAULT_COLOR());
$hasEffects = false;
}else{
$colors = [];
@ -80,9 +78,10 @@ class SplashPotion extends Throwable{
$colors[] = $effect->getColor();
}
}
$particle = new PotionSplashParticle(Color::mix(...$colors));
}
$this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_PARTICLE_SPLASH, Color::mix(...$colors)->toARGB());
$this->level->addParticle($this, $particle);
$this->level->broadcastLevelSoundEvent($this, LevelSoundEventPacket::SOUND_GLASS);
if($hasEffects){