remove GenericParticle, work on isolating network crap in particles

This commit is contained in:
Dylan K. Taylor 2019-08-19 19:26:26 +01:00
parent 4dfa335ae7
commit 8557c93f04
30 changed files with 220 additions and 121 deletions

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class AngryVillagerParticle extends GenericParticle{ class AngryVillagerParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::VILLAGER_ANGRY); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::VILLAGER_ANGRY, 0, $pos);
} }
} }

View File

@ -23,10 +23,20 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class BlockForceFieldParticle extends GenericParticle{ class BlockForceFieldParticle implements Particle{
/** @var int */
private $data;
public function __construct(int $data = 0){ public function __construct(int $data = 0){
parent::__construct(ParticleIds::BLOCK_FORCE_FIELD, $data); //TODO: proper encode/decode of data $this->data = $data; //TODO: proper encode/decode of data
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::BLOCK_FORCE_FIELD, $this->data, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class BubbleParticle extends GenericParticle{ class BubbleParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::BUBBLE); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::BUBBLE, 0, $pos);
} }
} }

View File

@ -23,10 +23,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class CriticalParticle extends GenericParticle{ class CriticalParticle implements Particle{
/** @var int */
private $scale;
public function __construct(int $scale = 2){ public function __construct(int $scale = 2){
parent::__construct(ParticleIds::CRITICAL, $scale); $this->scale = $scale;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::CRITICAL, $this->scale, $pos);
} }
} }

View File

@ -23,11 +23,20 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
use pocketmine\utils\Color; use pocketmine\utils\Color;
class DustParticle extends GenericParticle{ class DustParticle implements Particle{
/** @var Color */
private $color;
public function __construct(Color $color){ public function __construct(Color $color){
parent::__construct(ParticleIds::DUST, $color->toARGB()); $this->color = $color;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::DUST, $this->color->toARGB(), $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class EnchantParticle extends GenericParticle{ class EnchantParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::MOB_SPELL); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::MOB_SPELL, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class EnchantmentTableParticle extends GenericParticle{ class EnchantmentTableParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::ENCHANTMENT_TABLE); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::ENCHANTMENT_TABLE, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class EntityFlameParticle extends GenericParticle{ class EntityFlameParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::MOB_FLAME); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::MOB_FLAME, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class ExplodeParticle extends GenericParticle{ class ExplodeParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::EXPLODE); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::EXPLODE, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class FlameParticle extends GenericParticle{ class FlameParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::FLAME); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::FLAME, 0, $pos);
} }
} }

View File

@ -1,43 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GenericParticle implements Particle{
/** @var int */
protected $id;
/** @var int */
protected $data;
public function __construct(int $id, int $data = 0){
$this->id = $id & 0xFFF;
$this->data = $data;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle($this->id, $this->data, $pos);
}
}

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class HappyVillagerParticle extends GenericParticle{ class HappyVillagerParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::VILLAGER_HAPPY); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::VILLAGER_HAPPY, 0, $pos);
} }
} }

View File

@ -23,10 +23,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class HeartParticle extends GenericParticle{ class HeartParticle implements Particle{
/** @var int */
private $scale;
public function __construct(int $scale = 0){ public function __construct(int $scale = 0){
parent::__construct(ParticleIds::HEART, $scale); $this->scale = $scale;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::HEART, $this->scale, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class HugeExplodeParticle extends GenericParticle{ class HugeExplodeParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::HUGE_EXPLODE); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::HUGE_EXPLODE, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class HugeExplodeSeedParticle extends GenericParticle{ class HugeExplodeSeedParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::HUGE_EXPLODE_SEED); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::HUGE_EXPLODE_SEED, 0, $pos);
} }
} }

View File

@ -23,10 +23,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class InkParticle extends GenericParticle{ class InkParticle implements Particle{
/** @var int */
private $scale;
public function __construct(int $scale = 0){ public function __construct(int $scale = 0){
parent::__construct(ParticleIds::INK, $scale); $this->scale = $scale;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::INK, $this->scale, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class InstantEnchantParticle extends GenericParticle{ class InstantEnchantParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::MOB_SPELL_INSTANTANEOUS); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::MOB_SPELL_INSTANTANEOUS, 0, $pos);
} }
} }

View File

@ -24,10 +24,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class ItemBreakParticle extends GenericParticle{ class ItemBreakParticle implements Particle{
/** @var Item */
private $item;
public function __construct(Item $item){ public function __construct(Item $item){
parent::__construct(ParticleIds::ITEM_BREAK, ($item->getId() << 16) | $item->getMeta()); $this->item = $item;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::ITEM_BREAK, ($this->item->getId() << 16) | $this->item->getMeta(), $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class LavaDripParticle extends GenericParticle{ class LavaDripParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::DRIP_LAVA); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::DRIP_LAVA, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class LavaParticle extends GenericParticle{ class LavaParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::LAVA); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::LAVA, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class PortalParticle extends GenericParticle{ class PortalParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::PORTAL); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::PORTAL, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class RainSplashParticle extends GenericParticle{ class RainSplashParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::RAIN_SPLASH); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::RAIN_SPLASH, 0, $pos);
} }
} }

View File

@ -23,10 +23,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class RedstoneParticle extends GenericParticle{ class RedstoneParticle implements Particle{
/** @var int */
private $lifetime;
public function __construct(int $lifetime = 1){ public function __construct(int $lifetime = 1){
parent::__construct(ParticleIds::REDSTONE, $lifetime); $this->lifetime = $lifetime;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::REDSTONE, $this->lifetime, $pos);
} }
} }

View File

@ -23,10 +23,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class SmokeParticle extends GenericParticle{ class SmokeParticle implements Particle{
/** @var int */
private $scale;
public function __construct(int $scale = 0){ public function __construct(int $scale = 0){
parent::__construct(ParticleIds::SMOKE, $scale); $this->scale = $scale;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::SMOKE, $this->scale, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class SnowballPoofParticle extends GenericParticle{ class SnowballPoofParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::SNOWBALL_POOF, 0); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::SNOWBALL_POOF, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class SplashParticle extends GenericParticle{ class SplashParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::WATER_SPLASH); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::WATER_SPLASH, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class SporeParticle extends GenericParticle{ class SporeParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::TOWN_AURA); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::TOWN_AURA, 0, $pos);
} }
} }

View File

@ -24,10 +24,19 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class TerrainParticle extends GenericParticle{ class TerrainParticle implements Particle{
/** @var Block */
private $block;
public function __construct(Block $b){ public function __construct(Block $b){
parent::__construct(ParticleIds::TERRAIN, $b->getRuntimeId()); $this->block = $b;
}
public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::TERRAIN, $this->block->getRuntimeId(), $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class WaterDripParticle extends GenericParticle{ class WaterDripParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::DRIP_WATER); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::DRIP_WATER, 0, $pos);
} }
} }

View File

@ -23,10 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\particle; namespace pocketmine\world\particle;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\ParticleIds; use pocketmine\network\mcpe\protocol\types\ParticleIds;
class WaterParticle extends GenericParticle{ class WaterParticle implements Particle{
public function __construct(){
parent::__construct(ParticleIds::WATER_WAKE); public function encode(Vector3 $pos){
return LevelEventPacket::standardParticle(ParticleIds::WATER_WAKE, 0, $pos);
} }
} }