Added PlayerPostChunkSendEvent (#4937)

this is primarily useful for debugging plugins, but could also be useful for other things, such as spawning fake blocks, particles, etc.
This commit is contained in:
Dylan T 2022-05-17 15:40:01 +01:00 committed by GitHub
parent 8b1bd5b7ff
commit 8b8560a701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<?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\event\player;
use pocketmine\player\Player;
/**
* Called after a player is sent a chunk as part of their view radius.
*/
final class PlayerPostChunkSendEvent extends PlayerEvent{
public function __construct(
Player $player,
private int $chunkX,
private int $chunkZ
){
$this->player = $player;
}
public function getChunkX() : int{ return $this->chunkX; }
public function getChunkZ() : int{ return $this->chunkZ; }
}

View File

@ -65,6 +65,7 @@ use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerJumpEvent;
use pocketmine\event\player\PlayerKickEvent;
use pocketmine\event\player\PlayerMoveEvent;
use pocketmine\event\player\PlayerPostChunkSendEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\event\player\PlayerToggleFlightEvent;
@ -785,6 +786,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->getNetworkSession()->notifyTerrainReady();
}
(new PlayerPostChunkSendEvent($this, $X, $Z))->call();
});
},
static function() : void{