Gistrec

Fix loading chunk

Nov 19th, 2017
254
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. publiс function onChunkLoad(ChunkLoadEvent $event){
  2.     $chunk = $event->getChunk()
  3.     $this->getServer()->getScheduler()->scheduleDelayedTask(new sendPacket($this, $chunk->getX(), $chunk->getY()), 2);
  4. }
  5.  
  6.  
  7. =================================================================================
  8.  
  9. class sendPacket extends PluginTask{
  10.  
  11.     public $chunkX;
  12.     public $chunkY;
  13.  
  14.     public function __construct(Main $plugin, $chunkX, $chunkY){
  15.         parent::__construct($plugin);
  16.         $this->chunkX = $chunkX;
  17.         $this->chunkY = $chunkY;
  18.     }
  19.  
  20.     public function onRun($currentTick){
  21.         $pk = new \pocketmine\network\mcpe\protocol\UpdateBlockPacket;
  22.         $pk->x = $this->chunkX * 16 + 8;
  23.         $pk->y = 128;
  24.         $pk->z = $this->chunkY * 16 + 8;
  25.         $pk->blockId = 20;
  26.         $pk->blockData = 0;
  27.         $this->getOwner()->getServer()->broadcastPacket($this->getOwner()->getServer()->getOnlinePlayers(), $pk);
  28.     }
  29. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment