mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Merge branch 'release/3.4'
This commit is contained in:
commit
831a35ec69
@ -1966,9 +1966,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
|
|
||||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
||||||
//TODO: add events so plugins can change this
|
//TODO: add events so plugins can change this
|
||||||
if($this->chunk !== null){
|
$this->getLevel()->broadcastPacketToViewers($this, $packet);
|
||||||
$this->getLevel()->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $packet);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,7 +1134,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function broadcastMovement(bool $teleport = false) : void{
|
protected function broadcastMovement(bool $teleport = false) : void{
|
||||||
if($this->chunk !== null){
|
|
||||||
$pk = new MoveEntityAbsolutePacket();
|
$pk = new MoveEntityAbsolutePacket();
|
||||||
$pk->entityRuntimeId = $this->id;
|
$pk->entityRuntimeId = $this->id;
|
||||||
$pk->position = $this->getOffsetPosition($this);
|
$pk->position = $this->getOffsetPosition($this);
|
||||||
@ -1150,18 +1149,15 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
$pk->flags |= MoveEntityAbsolutePacket::FLAG_TELEPORT;
|
$pk->flags |= MoveEntityAbsolutePacket::FLAG_TELEPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
|
$this->level->broadcastPacketToViewers($this, $pk);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function broadcastMotion() : void{
|
protected function broadcastMotion() : void{
|
||||||
if($this->chunk !== null){
|
|
||||||
$pk = new SetEntityMotionPacket();
|
$pk = new SetEntityMotionPacket();
|
||||||
$pk->entityRuntimeId = $this->id;
|
$pk->entityRuntimeId = $this->id;
|
||||||
$pk->motion = $this->getMotion();
|
$pk->motion = $this->getMotion();
|
||||||
|
|
||||||
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
|
$this->level->broadcastPacketToViewers($this, $pk);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function applyDragBeforeGravity() : bool{
|
protected function applyDragBeforeGravity() : bool{
|
||||||
|
@ -87,6 +87,6 @@ class ChestInventory extends ContainerInventory{
|
|||||||
$pk->z = (int) $holder->z;
|
$pk->z = (int) $holder->z;
|
||||||
$pk->eventType = 1; //it's always 1 for a chest
|
$pk->eventType = 1; //it's always 1 for a chest
|
||||||
$pk->eventData = $isOpen ? 1 : 0;
|
$pk->eventData = $isOpen ? 1 : 0;
|
||||||
$holder->getLevel()->addChunkPacket($holder->getFloorX() >> 4, $holder->getFloorZ() >> 4, $pk);
|
$holder->getLevel()->broadcastPacketToViewers($holder, $pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ class Explosion{
|
|||||||
$pk->position = $this->source->asVector3();
|
$pk->position = $this->source->asVector3();
|
||||||
$pk->radius = $this->size;
|
$pk->radius = $this->size;
|
||||||
$pk->records = $send;
|
$pk->records = $send;
|
||||||
$this->level->addChunkPacket($source->getFloorX() >> 4, $source->getFloorZ() >> 4, $pk);
|
$this->level->broadcastPacketToViewers($source, $pk);
|
||||||
|
|
||||||
$this->level->addParticle(new HugeExplodeSeedParticle($source));
|
$this->level->addParticle(new HugeExplodeSeedParticle($source));
|
||||||
$this->level->broadcastLevelSoundEvent($source, LevelSoundEventPacket::SOUND_EXPLODE);
|
$this->level->broadcastLevelSoundEvent($source, LevelSoundEventPacket::SOUND_EXPLODE);
|
||||||
|
@ -455,7 +455,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
if($players === null){
|
if($players === null){
|
||||||
foreach($pk as $e){
|
foreach($pk as $e){
|
||||||
$this->addChunkPacket($sound->getFloorX() >> 4, $sound->getFloorZ() >> 4, $e);
|
$this->broadcastPacketToViewers($sound, $e);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->server->broadcastPackets($players, $pk);
|
$this->server->broadcastPackets($players, $pk);
|
||||||
@ -470,7 +470,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
if($players === null){
|
if($players === null){
|
||||||
foreach($pk as $e){
|
foreach($pk as $e){
|
||||||
$this->addChunkPacket($particle->getFloorX() >> 4, $particle->getFloorZ() >> 4, $e);
|
$this->broadcastPacketToViewers($particle, $e);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->server->broadcastPackets($players, $pk);
|
$this->server->broadcastPackets($players, $pk);
|
||||||
@ -490,10 +490,10 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$pk->data = $data;
|
$pk->data = $data;
|
||||||
if($pos !== null){
|
if($pos !== null){
|
||||||
$pk->position = $pos->asVector3();
|
$pk->position = $pos->asVector3();
|
||||||
$this->addChunkPacket($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $pk);
|
$this->broadcastPacketToViewers($pos, $pk);
|
||||||
}else{
|
}else{
|
||||||
$pk->position = null;
|
$pk->position = null;
|
||||||
$this->addGlobalPacket($pk);
|
$this->broadcastGlobalPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +515,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$pk->isBabyMob = $isBabyMob;
|
$pk->isBabyMob = $isBabyMob;
|
||||||
$pk->disableRelativeVolume = $disableRelativeVolume;
|
$pk->disableRelativeVolume = $disableRelativeVolume;
|
||||||
$pk->position = $pos->asVector3();
|
$pk->position = $pos->asVector3();
|
||||||
$this->addChunkPacket($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $pk);
|
$this->broadcastPacketToViewers($pos, $pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAutoSave() : bool{
|
public function getAutoSave() : bool{
|
||||||
@ -613,7 +613,27 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues a DataPacket to be sent to everyone in the Level at the end of the current tick.
|
* Broadcasts a packet to every player who has the target position within their view distance.
|
||||||
|
*
|
||||||
|
* @param Vector3 $pos
|
||||||
|
* @param DataPacket $packet
|
||||||
|
*/
|
||||||
|
public function broadcastPacketToViewers(Vector3 $pos, DataPacket $packet) : void{
|
||||||
|
$this->addChunkPacket($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts a packet to every player in the level.
|
||||||
|
*
|
||||||
|
* @param DataPacket $packet
|
||||||
|
*/
|
||||||
|
public function broadcastGlobalPacket(DataPacket $packet) : void{
|
||||||
|
$this->globalPackets[] = $packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see Level::broadcastGlobalPacket()
|
||||||
*
|
*
|
||||||
* @param DataPacket $packet
|
* @param DataPacket $packet
|
||||||
*/
|
*/
|
||||||
|
@ -67,8 +67,7 @@ abstract class Spawnable extends Tile{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pk = $this->createSpawnPacket();
|
$this->level->broadcastPacketToViewers($this, $this->createSpawnPacket());
|
||||||
$this->level->addChunkPacket($this->getFloorX() >> 4, $this->getFloorZ() >> 4, $pk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user