mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Particle no longer extends Vector3
This commit is contained in:
@ -256,7 +256,7 @@ class Explosion{
|
||||
$pk->records = $send;
|
||||
$this->level->broadcastPacketToViewers($source, $pk);
|
||||
|
||||
$this->level->addParticle(new HugeExplodeSeedParticle($source));
|
||||
$this->level->addParticle($source, new HugeExplodeSeedParticle());
|
||||
$this->level->broadcastLevelSoundEvent($source, LevelSoundEventPacket::SOUND_EXPLODE);
|
||||
|
||||
return true;
|
||||
|
@ -466,15 +466,15 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function addParticle(Particle $particle, array $players = null){
|
||||
$pk = $particle->encode();
|
||||
public function addParticle(Vector3 $pos, Particle $particle, array $players = null){
|
||||
$pk = $particle->encode($pos);
|
||||
if(!is_array($pk)){
|
||||
$pk = [$pk];
|
||||
}
|
||||
if(!empty($pk)){
|
||||
if($players === null){
|
||||
foreach($pk as $e){
|
||||
$this->broadcastPacketToViewers($particle, $e);
|
||||
$this->broadcastPacketToViewers($pos, $e);
|
||||
}
|
||||
}else{
|
||||
$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{
|
||||
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);
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class AngryVillagerParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_VILLAGER_ANGRY);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_VILLAGER_ANGRY);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class BlockForceFieldParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, int $data = 0){
|
||||
parent::__construct($pos, Particle::TYPE_BLOCK_FORCE_FIELD, $data); //TODO: proper encode/decode of data
|
||||
public function __construct(int $data = 0){
|
||||
parent::__construct(Particle::TYPE_BLOCK_FORCE_FIELD, $data); //TODO: proper encode/decode of data
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class BubbleParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_BUBBLE);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_BUBBLE);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class CriticalParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, int $scale = 2){
|
||||
parent::__construct($pos, Particle::TYPE_CRITICAL, $scale);
|
||||
public function __construct(int $scale = 2){
|
||||
parent::__construct(Particle::TYPE_CRITICAL, $scale);
|
||||
}
|
||||
}
|
||||
|
@ -32,15 +32,14 @@ class DestroyBlockParticle extends Particle{
|
||||
/** @var int */
|
||||
protected $data;
|
||||
|
||||
public function __construct(Vector3 $pos, Block $b){
|
||||
parent::__construct($pos->x, $pos->y, $pos->z);
|
||||
public function __construct(Block $b){
|
||||
$this->data = $b->getRuntimeId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
public function encode(Vector3 $pos){
|
||||
$pk = new LevelEventPacket;
|
||||
$pk->evid = LevelEventPacket::EVENT_PARTICLE_DESTROY;
|
||||
$pk->position = $this->asVector3();
|
||||
$pk->position = $pos;
|
||||
$pk->data = $this->data;
|
||||
|
||||
return $pk;
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class DustParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, 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));
|
||||
public function __construct(int $r, int $g, int $b, int $a = 255){
|
||||
parent::__construct(Particle::TYPE_DUST, (($a & 0xff) << 24) | (($r & 0xff) << 16) | (($g & 0xff) << 8) | ($b & 0xff));
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class EnchantParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_MOB_SPELL);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_MOB_SPELL);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class EnchantmentTableParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_ENCHANTMENT_TABLE);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_ENCHANTMENT_TABLE);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class EntityFlameParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_MOB_FLAME);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_MOB_FLAME);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class ExplodeParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_EXPLODE);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_EXPLODE);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class FlameParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_FLAME);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_FLAME);
|
||||
}
|
||||
}
|
||||
|
@ -43,12 +43,10 @@ class FloatingTextParticle extends Particle{
|
||||
protected $invisible = false;
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
* @param string $text
|
||||
* @param string $title
|
||||
* @param string $text
|
||||
* @param string $title
|
||||
*/
|
||||
public function __construct(Vector3 $pos, string $text, string $title = ""){
|
||||
parent::__construct($pos->x, $pos->y, $pos->z);
|
||||
public function __construct(string $text, string $title = ""){
|
||||
$this->text = $text;
|
||||
$this->title = $title;
|
||||
}
|
||||
@ -77,7 +75,7 @@ class FloatingTextParticle extends Particle{
|
||||
$this->invisible = $value;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
public function encode(Vector3 $pos){
|
||||
$p = [];
|
||||
|
||||
if($this->entityId === null){
|
||||
@ -102,7 +100,7 @@ class FloatingTextParticle extends Particle{
|
||||
$pk->uuid = $uuid;
|
||||
$pk->username = $name;
|
||||
$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);
|
||||
|
||||
$flags = (
|
||||
|
@ -32,16 +32,15 @@ class GenericParticle extends Particle{
|
||||
/** @var int */
|
||||
protected $data;
|
||||
|
||||
public function __construct(Vector3 $pos, int $id, int $data = 0){
|
||||
parent::__construct($pos->x, $pos->y, $pos->z);
|
||||
public function __construct(int $id, int $data = 0){
|
||||
$this->id = $id & 0xFFF;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
public function encode(Vector3 $pos){
|
||||
$pk = new LevelEventPacket;
|
||||
$pk->evid = LevelEventPacket::EVENT_ADD_PARTICLE_MASK | $this->id;
|
||||
$pk->position = $this->asVector3();
|
||||
$pk->position = $pos;
|
||||
$pk->data = $this->data;
|
||||
|
||||
return $pk;
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class HappyVillagerParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_VILLAGER_HAPPY);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_VILLAGER_HAPPY);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class HeartParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, int $scale = 0){
|
||||
parent::__construct($pos, Particle::TYPE_HEART, $scale);
|
||||
public function __construct(int $scale = 0){
|
||||
parent::__construct(Particle::TYPE_HEART, $scale);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class HugeExplodeParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_HUGE_EXPLODE);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_HUGE_EXPLODE);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class HugeExplodeSeedParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_HUGE_EXPLODE_SEED);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_HUGE_EXPLODE_SEED);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class InkParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, int $scale = 0){
|
||||
parent::__construct($pos, Particle::TYPE_INK, $scale);
|
||||
public function __construct(int $scale = 0){
|
||||
parent::__construct(Particle::TYPE_INK, $scale);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class InstantEnchantParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_MOB_SPELL_INSTANTANEOUS);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_MOB_SPELL_INSTANTANEOUS);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,9 @@ declare(strict_types=1);
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class ItemBreakParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, Item $item){
|
||||
parent::__construct($pos, Particle::TYPE_ITEM_BREAK, ($item->getId() << 16) | $item->getDamage());
|
||||
public function __construct(Item $item){
|
||||
parent::__construct(Particle::TYPE_ITEM_BREAK, ($item->getId() << 16) | $item->getDamage());
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class LavaDripParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_DRIP_LAVA);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_DRIP_LAVA);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class LavaParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_LAVA);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_LAVA);
|
||||
}
|
||||
}
|
||||
|
@ -32,16 +32,15 @@ class MobSpawnParticle extends Particle{
|
||||
/** @var int */
|
||||
protected $height;
|
||||
|
||||
public function __construct(Vector3 $pos, int $width = 0, int $height = 0){
|
||||
parent::__construct($pos->x, $pos->y, $pos->z);
|
||||
public function __construct(int $width = 0, int $height = 0){
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
public function encode(Vector3 $pos){
|
||||
$pk = new LevelEventPacket;
|
||||
$pk->evid = LevelEventPacket::EVENT_PARTICLE_SPAWN;
|
||||
$pk->position = $this->asVector3();
|
||||
$pk->position = $pos;
|
||||
$pk->data = ($this->width & 0xff) + (($this->height & 0xff) << 8);
|
||||
|
||||
return $pk;
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\level\particle;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
|
||||
abstract class Particle extends Vector3{
|
||||
abstract class Particle{
|
||||
|
||||
public const TYPE_BUBBLE = 1;
|
||||
public const TYPE_CRITICAL = 2;
|
||||
@ -74,8 +74,10 @@ abstract class Particle extends Vector3{
|
||||
public const TYPE_FOOD = 44;
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return DataPacket|DataPacket[]
|
||||
*/
|
||||
abstract public function encode();
|
||||
abstract public function encode(Vector3 $pos);
|
||||
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class PortalParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_PORTAL);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_PORTAL);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class RainSplashParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_RAIN_SPLASH);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_RAIN_SPLASH);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class RedstoneParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, int $lifetime = 1){
|
||||
parent::__construct($pos, Particle::TYPE_REDSTONE, $lifetime);
|
||||
public function __construct(int $lifetime = 1){
|
||||
parent::__construct(Particle::TYPE_REDSTONE, $lifetime);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class SmokeParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, int $scale = 0){
|
||||
parent::__construct($pos, Particle::TYPE_SMOKE, $scale);
|
||||
public function __construct(int $scale = 0){
|
||||
parent::__construct(Particle::TYPE_SMOKE, $scale);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class SnowballPoofParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, self::TYPE_SNOWBALL_POOF, 0);
|
||||
public function __construct(){
|
||||
parent::__construct(self::TYPE_SNOWBALL_POOF, 0);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class SplashParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_WATER_SPLASH);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_WATER_SPLASH);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class SporeParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_TOWN_AURA);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_TOWN_AURA);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,9 @@ declare(strict_types=1);
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class TerrainParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos, Block $b){
|
||||
parent::__construct($pos, Particle::TYPE_TERRAIN, $b->getRuntimeId());
|
||||
public function __construct(Block $b){
|
||||
parent::__construct(Particle::TYPE_TERRAIN, $b->getRuntimeId());
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class WaterDripParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_DRIP_WATER);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_DRIP_WATER);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\particle;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class WaterParticle extends GenericParticle{
|
||||
public function __construct(Vector3 $pos){
|
||||
parent::__construct($pos, Particle::TYPE_WATER_WAKE);
|
||||
public function __construct(){
|
||||
parent::__construct(Particle::TYPE_WATER_WAKE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user