Particle no longer extends Vector3

This commit is contained in:
Dylan K. Taylor 2018-12-16 14:15:41 +00:00
parent ebf9cb3e62
commit 3c520aa786
40 changed files with 122 additions and 186 deletions

View File

@ -105,7 +105,7 @@ class ParticleCommand extends VanillaCommand{
$data = isset($args[8]) ? (int) $args[8] : null; $data = isset($args[8]) ? (int) $args[8] : null;
$particle = $this->getParticle($name, $pos, $xd, $yd, $zd, $data); $particle = $this->getParticle($name, $data);
if($particle === null){ if($particle === null){
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.particle.notFound", [$name])); $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.particle.notFound", [$name]));
@ -118,12 +118,11 @@ class ParticleCommand extends VanillaCommand{
$random = new Random((int) (microtime(true) * 1000) + mt_rand()); $random = new Random((int) (microtime(true) * 1000) + mt_rand());
for($i = 0; $i < $count; ++$i){ for($i = 0; $i < $count; ++$i){
$particle->setComponents( $level->addParticle($pos->add(
$pos->x + $random->nextSignedFloat() * $xd, $random->nextSignedFloat() * $xd,
$pos->y + $random->nextSignedFloat() * $yd, $random->nextSignedFloat() * $yd,
$pos->z + $random->nextSignedFloat() * $zd $random->nextSignedFloat() * $zd
); ), $particle);
$level->addParticle($particle);
} }
return true; return true;
@ -131,97 +130,93 @@ class ParticleCommand extends VanillaCommand{
/** /**
* @param string $name * @param string $name
* @param Vector3 $pos
* @param float $xd
* @param float $yd
* @param float $zd
* @param int|null $data * @param int|null $data
* *
* @return Particle|null * @return Particle|null
*/ */
private function getParticle(string $name, Vector3 $pos, float $xd, float $yd, float $zd, int $data = null){ private function getParticle(string $name, int $data = null){
switch($name){ switch($name){
case "explode": case "explode":
return new ExplodeParticle($pos); return new ExplodeParticle();
case "hugeexplosion": case "hugeexplosion":
return new HugeExplodeParticle($pos); return new HugeExplodeParticle();
case "hugeexplosionseed": case "hugeexplosionseed":
return new HugeExplodeSeedParticle($pos); return new HugeExplodeSeedParticle();
case "bubble": case "bubble":
return new BubbleParticle($pos); return new BubbleParticle();
case "splash": case "splash":
return new SplashParticle($pos); return new SplashParticle();
case "wake": case "wake":
case "water": case "water":
return new WaterParticle($pos); return new WaterParticle();
case "crit": case "crit":
return new CriticalParticle($pos); return new CriticalParticle();
case "smoke": case "smoke":
return new SmokeParticle($pos, $data ?? 0); return new SmokeParticle($data ?? 0);
case "spell": case "spell":
return new EnchantParticle($pos); return new EnchantParticle();
case "instantspell": case "instantspell":
return new InstantEnchantParticle($pos); return new InstantEnchantParticle();
case "dripwater": case "dripwater":
return new WaterDripParticle($pos); return new WaterDripParticle();
case "driplava": case "driplava":
return new LavaDripParticle($pos); return new LavaDripParticle();
case "townaura": case "townaura":
case "spore": case "spore":
return new SporeParticle($pos); return new SporeParticle();
case "portal": case "portal":
return new PortalParticle($pos); return new PortalParticle();
case "flame": case "flame":
return new FlameParticle($pos); return new FlameParticle();
case "lava": case "lava":
return new LavaParticle($pos); return new LavaParticle();
case "reddust": case "reddust":
return new RedstoneParticle($pos, $data ?? 1); return new RedstoneParticle($data ?? 1);
case "snowballpoof": case "snowballpoof":
return new ItemBreakParticle($pos, ItemFactory::get(Item::SNOWBALL)); return new ItemBreakParticle(ItemFactory::get(Item::SNOWBALL));
case "slime": case "slime":
return new ItemBreakParticle($pos, ItemFactory::get(Item::SLIMEBALL)); return new ItemBreakParticle(ItemFactory::get(Item::SLIMEBALL));
case "itembreak": case "itembreak":
if($data !== null and $data !== 0){ if($data !== null and $data !== 0){
return new ItemBreakParticle($pos, ItemFactory::get($data)); return new ItemBreakParticle(ItemFactory::get($data));
} }
break; break;
case "terrain": case "terrain":
if($data !== null and $data !== 0){ if($data !== null and $data !== 0){
return new TerrainParticle($pos, BlockFactory::get($data)); return new TerrainParticle(BlockFactory::get($data));
} }
break; break;
case "heart": case "heart":
return new HeartParticle($pos, $data ?? 0); return new HeartParticle($data ?? 0);
case "ink": case "ink":
return new InkParticle($pos, $data ?? 0); return new InkParticle($data ?? 0);
case "droplet": case "droplet":
return new RainSplashParticle($pos); return new RainSplashParticle();
case "enchantmenttable": case "enchantmenttable":
return new EnchantmentTableParticle($pos); return new EnchantmentTableParticle();
case "happyvillager": case "happyvillager":
return new HappyVillagerParticle($pos); return new HappyVillagerParticle();
case "angryvillager": case "angryvillager":
return new AngryVillagerParticle($pos); return new AngryVillagerParticle();
case "forcefield": case "forcefield":
return new BlockForceFieldParticle($pos, $data ?? 0); return new BlockForceFieldParticle($data ?? 0);
} }
if(strpos($name, "iconcrack_") === 0){ if(strpos($name, "iconcrack_") === 0){
$d = explode("_", $name); $d = explode("_", $name);
if(count($d) === 3){ if(count($d) === 3){
return new ItemBreakParticle($pos, ItemFactory::get((int) $d[1], (int) $d[2])); return new ItemBreakParticle(ItemFactory::get((int) $d[1], (int) $d[2]));
} }
}elseif(strpos($name, "blockcrack_") === 0){ }elseif(strpos($name, "blockcrack_") === 0){
$d = explode("_", $name); $d = explode("_", $name);
if(count($d) === 2){ if(count($d) === 2){
return new TerrainParticle($pos, BlockFactory::get($d[1] & 0xff, $d[1] >> 12)); return new TerrainParticle(BlockFactory::get($d[1] & 0xff, $d[1] >> 12));
} }
}elseif(strpos($name, "blockdust_") === 0){ }elseif(strpos($name, "blockdust_") === 0){
$d = explode("_", $name); $d = explode("_", $name);
if(count($d) >= 4){ if(count($d) >= 4){
return new DustParticle($pos, $d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255); return new DustParticle($d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255);
} }
} }

View File

@ -108,7 +108,7 @@ class Painting extends Entity{
//non-living entities don't have a way to create drops generically yet //non-living entities don't have a way to create drops generically yet
$this->level->dropItem($this, ItemFactory::get(Item::PAINTING)); $this->level->dropItem($this, ItemFactory::get(Item::PAINTING));
} }
$this->level->addParticle(new DestroyBlockParticle($this->add(0.5, 0.5, 0.5), BlockFactory::get(Block::PLANKS))); $this->level->addParticle($this->add(0.5, 0.5, 0.5), new DestroyBlockParticle(BlockFactory::get(Block::PLANKS)));
} }
protected function recalculateBoundingBox() : void{ protected function recalculateBoundingBox() : void{

View File

@ -35,7 +35,7 @@ class Egg extends Throwable{
protected function onHit(ProjectileHitEvent $event) : void{ protected function onHit(ProjectileHitEvent $event) : void{
for($i = 0; $i < 6; ++$i){ for($i = 0; $i < 6; ++$i){
$this->level->addParticle(new ItemBreakParticle($this, ItemFactory::get(Item::EGG))); $this->level->addParticle($this, new ItemBreakParticle(ItemFactory::get(Item::EGG)));
} }
} }
} }

View File

@ -31,7 +31,7 @@ class Snowball extends Throwable{
protected function onHit(ProjectileHitEvent $event) : void{ protected function onHit(ProjectileHitEvent $event) : void{
for($i = 0; $i < 6; ++$i){ for($i = 0; $i < 6; ++$i){
$this->level->addParticle(new SnowballPoofParticle($this)); $this->level->addParticle($this, new SnowballPoofParticle());
} }
} }
} }

View File

@ -256,7 +256,7 @@ class Explosion{
$pk->records = $send; $pk->records = $send;
$this->level->broadcastPacketToViewers($source, $pk); $this->level->broadcastPacketToViewers($source, $pk);
$this->level->addParticle(new HugeExplodeSeedParticle($source)); $this->level->addParticle($source, new HugeExplodeSeedParticle());
$this->level->broadcastLevelSoundEvent($source, LevelSoundEventPacket::SOUND_EXPLODE); $this->level->broadcastLevelSoundEvent($source, LevelSoundEventPacket::SOUND_EXPLODE);
return true; return true;

View File

@ -466,15 +466,15 @@ class Level implements ChunkManager, Metadatable{
} }
} }
public function addParticle(Particle $particle, array $players = null){ public function addParticle(Vector3 $pos, Particle $particle, array $players = null){
$pk = $particle->encode(); $pk = $particle->encode($pos);
if(!is_array($pk)){ if(!is_array($pk)){
$pk = [$pk]; $pk = [$pk];
} }
if(!empty($pk)){ if(!empty($pk)){
if($players === null){ if($players === null){
foreach($pk as $e){ foreach($pk as $e){
$this->broadcastPacketToViewers($particle, $e); $this->broadcastPacketToViewers($pos, $e);
} }
}else{ }else{
$this->server->broadcastPackets($players, $pk); $this->server->broadcastPackets($players, $pk);
@ -1761,7 +1761,7 @@ class Level implements ChunkManager, Metadatable{
private function destroyBlockInternal(Block $target, Item $item, ?Player $player = null, bool $createParticles = false) : void{ private function destroyBlockInternal(Block $target, Item $item, ?Player $player = null, bool $createParticles = false) : void{
if($createParticles){ if($createParticles){
$this->addParticle(new DestroyBlockParticle($target->add(0.5, 0.5, 0.5), $target)); $this->addParticle($target->add(0.5, 0.5, 0.5), new DestroyBlockParticle($target));
} }
$target->onBreak($item, $player); $target->onBreak($item, $player);

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class AngryVillagerParticle extends GenericParticle{ class AngryVillagerParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_VILLAGER_ANGRY); parent::__construct(Particle::TYPE_VILLAGER_ANGRY);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class BlockForceFieldParticle extends GenericParticle{ class BlockForceFieldParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $data = 0){ public function __construct(int $data = 0){
parent::__construct($pos, Particle::TYPE_BLOCK_FORCE_FIELD, $data); //TODO: proper encode/decode of data parent::__construct(Particle::TYPE_BLOCK_FORCE_FIELD, $data); //TODO: proper encode/decode of data
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class BubbleParticle extends GenericParticle{ class BubbleParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_BUBBLE); parent::__construct(Particle::TYPE_BUBBLE);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class CriticalParticle extends GenericParticle{ class CriticalParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $scale = 2){ public function __construct(int $scale = 2){
parent::__construct($pos, Particle::TYPE_CRITICAL, $scale); parent::__construct(Particle::TYPE_CRITICAL, $scale);
} }
} }

View File

@ -32,15 +32,14 @@ class DestroyBlockParticle extends Particle{
/** @var int */ /** @var int */
protected $data; protected $data;
public function __construct(Vector3 $pos, Block $b){ public function __construct(Block $b){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->data = $b->getRuntimeId(); $this->data = $b->getRuntimeId();
} }
public function encode(){ public function encode(Vector3 $pos){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_PARTICLE_DESTROY; $pk->evid = LevelEventPacket::EVENT_PARTICLE_DESTROY;
$pk->position = $this->asVector3(); $pk->position = $pos;
$pk->data = $this->data; $pk->data = $this->data;
return $pk; return $pk;

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class DustParticle extends GenericParticle{ class DustParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $r, int $g, int $b, int $a = 255){ public function __construct(int $r, int $g, int $b, int $a = 255){
parent::__construct($pos, Particle::TYPE_DUST, (($a & 0xff) << 24) | (($r & 0xff) << 16) | (($g & 0xff) << 8) | ($b & 0xff)); parent::__construct(Particle::TYPE_DUST, (($a & 0xff) << 24) | (($r & 0xff) << 16) | (($g & 0xff) << 8) | ($b & 0xff));
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class EnchantParticle extends GenericParticle{ class EnchantParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_MOB_SPELL); parent::__construct(Particle::TYPE_MOB_SPELL);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class EnchantmentTableParticle extends GenericParticle{ class EnchantmentTableParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_ENCHANTMENT_TABLE); parent::__construct(Particle::TYPE_ENCHANTMENT_TABLE);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class EntityFlameParticle extends GenericParticle{ class EntityFlameParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_MOB_FLAME); parent::__construct(Particle::TYPE_MOB_FLAME);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class ExplodeParticle extends GenericParticle{ class ExplodeParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_EXPLODE); parent::__construct(Particle::TYPE_EXPLODE);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class FlameParticle extends GenericParticle{ class FlameParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_FLAME); parent::__construct(Particle::TYPE_FLAME);
} }
} }

View File

@ -43,12 +43,10 @@ class FloatingTextParticle extends Particle{
protected $invisible = false; protected $invisible = false;
/** /**
* @param Vector3 $pos * @param string $text
* @param string $text * @param string $title
* @param string $title
*/ */
public function __construct(Vector3 $pos, string $text, string $title = ""){ public function __construct(string $text, string $title = ""){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->text = $text; $this->text = $text;
$this->title = $title; $this->title = $title;
} }
@ -77,7 +75,7 @@ class FloatingTextParticle extends Particle{
$this->invisible = $value; $this->invisible = $value;
} }
public function encode(){ public function encode(Vector3 $pos){
$p = []; $p = [];
if($this->entityId === null){ if($this->entityId === null){
@ -102,7 +100,7 @@ class FloatingTextParticle extends Particle{
$pk->uuid = $uuid; $pk->uuid = $uuid;
$pk->username = $name; $pk->username = $name;
$pk->entityRuntimeId = $this->entityId; $pk->entityRuntimeId = $this->entityId;
$pk->position = $this->asVector3(); //TODO: check offset $pk->position = $pos; //TODO: check offset
$pk->item = ItemFactory::get(Item::AIR, 0, 0); $pk->item = ItemFactory::get(Item::AIR, 0, 0);
$flags = ( $flags = (

View File

@ -32,16 +32,15 @@ class GenericParticle extends Particle{
/** @var int */ /** @var int */
protected $data; protected $data;
public function __construct(Vector3 $pos, int $id, int $data = 0){ public function __construct(int $id, int $data = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->id = $id & 0xFFF; $this->id = $id & 0xFFF;
$this->data = $data; $this->data = $data;
} }
public function encode(){ public function encode(Vector3 $pos){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_ADD_PARTICLE_MASK | $this->id; $pk->evid = LevelEventPacket::EVENT_ADD_PARTICLE_MASK | $this->id;
$pk->position = $this->asVector3(); $pk->position = $pos;
$pk->data = $this->data; $pk->data = $this->data;
return $pk; return $pk;

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class HappyVillagerParticle extends GenericParticle{ class HappyVillagerParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_VILLAGER_HAPPY); parent::__construct(Particle::TYPE_VILLAGER_HAPPY);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class HeartParticle extends GenericParticle{ class HeartParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $scale = 0){ public function __construct(int $scale = 0){
parent::__construct($pos, Particle::TYPE_HEART, $scale); parent::__construct(Particle::TYPE_HEART, $scale);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class HugeExplodeParticle extends GenericParticle{ class HugeExplodeParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_HUGE_EXPLODE); parent::__construct(Particle::TYPE_HUGE_EXPLODE);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class HugeExplodeSeedParticle extends GenericParticle{ class HugeExplodeSeedParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_HUGE_EXPLODE_SEED); parent::__construct(Particle::TYPE_HUGE_EXPLODE_SEED);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class InkParticle extends GenericParticle{ class InkParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $scale = 0){ public function __construct(int $scale = 0){
parent::__construct($pos, Particle::TYPE_INK, $scale); parent::__construct(Particle::TYPE_INK, $scale);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class InstantEnchantParticle extends GenericParticle{ class InstantEnchantParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_MOB_SPELL_INSTANTANEOUS); parent::__construct(Particle::TYPE_MOB_SPELL_INSTANTANEOUS);
} }
} }

View File

@ -24,10 +24,9 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3;
class ItemBreakParticle extends GenericParticle{ class ItemBreakParticle extends GenericParticle{
public function __construct(Vector3 $pos, Item $item){ public function __construct(Item $item){
parent::__construct($pos, Particle::TYPE_ITEM_BREAK, ($item->getId() << 16) | $item->getDamage()); parent::__construct(Particle::TYPE_ITEM_BREAK, ($item->getId() << 16) | $item->getDamage());
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class LavaDripParticle extends GenericParticle{ class LavaDripParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_DRIP_LAVA); parent::__construct(Particle::TYPE_DRIP_LAVA);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class LavaParticle extends GenericParticle{ class LavaParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_LAVA); parent::__construct(Particle::TYPE_LAVA);
} }
} }

View File

@ -32,16 +32,15 @@ class MobSpawnParticle extends Particle{
/** @var int */ /** @var int */
protected $height; protected $height;
public function __construct(Vector3 $pos, int $width = 0, int $height = 0){ public function __construct(int $width = 0, int $height = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->width = $width; $this->width = $width;
$this->height = $height; $this->height = $height;
} }
public function encode(){ public function encode(Vector3 $pos){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_PARTICLE_SPAWN; $pk->evid = LevelEventPacket::EVENT_PARTICLE_SPAWN;
$pk->position = $this->asVector3(); $pk->position = $pos;
$pk->data = ($this->width & 0xff) + (($this->height & 0xff) << 8); $pk->data = ($this->width & 0xff) + (($this->height & 0xff) << 8);
return $pk; return $pk;

View File

@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DataPacket;
abstract class Particle extends Vector3{ abstract class Particle{
public const TYPE_BUBBLE = 1; public const TYPE_BUBBLE = 1;
public const TYPE_CRITICAL = 2; public const TYPE_CRITICAL = 2;
@ -74,8 +74,10 @@ abstract class Particle extends Vector3{
public const TYPE_FOOD = 44; public const TYPE_FOOD = 44;
/** /**
* @param Vector3 $pos
*
* @return DataPacket|DataPacket[] * @return DataPacket|DataPacket[]
*/ */
abstract public function encode(); abstract public function encode(Vector3 $pos);
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class PortalParticle extends GenericParticle{ class PortalParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_PORTAL); parent::__construct(Particle::TYPE_PORTAL);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class RainSplashParticle extends GenericParticle{ class RainSplashParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_RAIN_SPLASH); parent::__construct(Particle::TYPE_RAIN_SPLASH);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class RedstoneParticle extends GenericParticle{ class RedstoneParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $lifetime = 1){ public function __construct(int $lifetime = 1){
parent::__construct($pos, Particle::TYPE_REDSTONE, $lifetime); parent::__construct(Particle::TYPE_REDSTONE, $lifetime);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class SmokeParticle extends GenericParticle{ class SmokeParticle extends GenericParticle{
public function __construct(Vector3 $pos, int $scale = 0){ public function __construct(int $scale = 0){
parent::__construct($pos, Particle::TYPE_SMOKE, $scale); parent::__construct(Particle::TYPE_SMOKE, $scale);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class SnowballPoofParticle extends GenericParticle{ class SnowballPoofParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, self::TYPE_SNOWBALL_POOF, 0); parent::__construct(self::TYPE_SNOWBALL_POOF, 0);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class SplashParticle extends GenericParticle{ class SplashParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_WATER_SPLASH); parent::__construct(Particle::TYPE_WATER_SPLASH);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class SporeParticle extends GenericParticle{ class SporeParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_TOWN_AURA); parent::__construct(Particle::TYPE_TOWN_AURA);
} }
} }

View File

@ -24,10 +24,9 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\math\Vector3;
class TerrainParticle extends GenericParticle{ class TerrainParticle extends GenericParticle{
public function __construct(Vector3 $pos, Block $b){ public function __construct(Block $b){
parent::__construct($pos, Particle::TYPE_TERRAIN, $b->getRuntimeId()); parent::__construct(Particle::TYPE_TERRAIN, $b->getRuntimeId());
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class WaterDripParticle extends GenericParticle{ class WaterDripParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_DRIP_WATER); parent::__construct(Particle::TYPE_DRIP_WATER);
} }
} }

View File

@ -23,10 +23,8 @@ declare(strict_types=1);
namespace pocketmine\level\particle; namespace pocketmine\level\particle;
use pocketmine\math\Vector3;
class WaterParticle extends GenericParticle{ class WaterParticle extends GenericParticle{
public function __construct(Vector3 $pos){ public function __construct(){
parent::__construct($pos, Particle::TYPE_WATER_WAKE); parent::__construct(Particle::TYPE_WATER_WAKE);
} }
} }