mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Level: Allow broadcastLevelEvent() to accept a null position to broadcast to everyone in the Level
This commit is contained in:
parent
f0696f77ef
commit
ecb3f9aeac
@ -503,16 +503,21 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
/**
|
/**
|
||||||
* Broadcasts a LevelEvent to players in the area. This could be sound, particles, weather changes, etc.
|
* Broadcasts a LevelEvent to players in the area. This could be sound, particles, weather changes, etc.
|
||||||
*
|
*
|
||||||
* @param Vector3 $pos
|
* @param Vector3|null $pos If null, broadcasts to every player in the Level
|
||||||
* @param int $evid
|
* @param int $evid
|
||||||
* @param int $data
|
* @param int $data
|
||||||
*/
|
*/
|
||||||
public function broadcastLevelEvent(Vector3 $pos, int $evid, int $data = 0){
|
public function broadcastLevelEvent(?Vector3 $pos, int $evid, int $data = 0){
|
||||||
$pk = new LevelEventPacket();
|
$pk = new LevelEventPacket();
|
||||||
$pk->evid = $evid;
|
$pk->evid = $evid;
|
||||||
$pk->data = $data;
|
$pk->data = $data;
|
||||||
|
if($pos !== null){
|
||||||
$pk->position = $pos->asVector3();
|
$pk->position = $pos->asVector3();
|
||||||
$this->addChunkPacket($pos->x >> 4, $pos->z >> 4, $pk);
|
$this->addChunkPacket($pos->x >> 4, $pos->z >> 4, $pk);
|
||||||
|
}else{
|
||||||
|
$pk->position = null;
|
||||||
|
$this->addGlobalPacket($pk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user