GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
ChunkRequestTask Class Reference

Public Member Functions

 __construct (Level $level, Chunk $chunk)
 
 onRun ()
 
 onCompletion (Server $server)
 
- Public Member Functions inherited from AsyncTask
 isGarbage ()
 
 setGarbage ()
 
 isFinished ()
 
 run ()
 
 isCrashed ()
 
 getResult ()
 
 cancelRun ()
 
 hasCancelledRun ()
 
 hasResult ()
 
 setResult ($result, $serialize=true)
 
 setTaskId ($taskId)
 
 getTaskId ()
 
 getFromThreadStore ($identifier)
 
 saveToThreadStore ($identifier, $value)
 
 onRun ()
 
 onCompletion (Server $server)
 
 cleanObject ()
 
- Public Member Functions inherited from Threaded
 chunk ($size, bool $preserve=false)
 
 count ()
 
 isRunning ()
 
 isTerminated ()
 
 merge ($from, $overwrite=true)
 
 notify ()
 
 notifyOne ()
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 pop ()
 
 run ()
 
 shift ()
 
 synchronized (\Closure $function, $args=null)
 
 wait ($timeout)
 
 getRefCount ()
 
 addRef ()
 
 delRef ()
 
 isGarbage ()
 

Protected Attributes

 $levelId
 
 $chunk
 
 $chunkX
 
 $chunkZ
 
 $tiles
 

Additional Inherited Members

- Static Public Member Functions inherited from Threaded
static extend ($obj)
 
- Data Fields inherited from AsyncTask
 $worker = null
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Level  $level,
Chunk  $chunk 
)

ChunkRequestTask constructor.

Parameters
Level$level
Chunk$chunk
47  {
48  $this->levelId = $level->getId();
49 
50  $this->chunk = $chunk->fastSerialize();
51  $this->chunkX = $chunk->getX();
52  $this->chunkZ = $chunk->getZ();
53 
54  //TODO: serialize tiles with chunks
55  $tiles = "";
56  $nbt = new NBT(NBT::LITTLE_ENDIAN);
57  foreach($chunk->getTiles() as $tile){
58  if($tile instanceof Spawnable){
59  $nbt->setData($tile->getSpawnCompound());
60  $tiles .= $nbt->write(true);
61  }
62  }
63 
64  $this->tiles = $tiles;
65  }

Member Function Documentation

◆ onCompletion()

onCompletion ( Server  $server)
Parameters
Server$server
78  {
79  $level = $server->getLevel($this->levelId);
80  if($level instanceof Level and $this->hasResult()){
81  $level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult());
82  }
83  }

◆ onRun()

onRun ( )
67  {
69 
70  $ordered = $chunk->networkSerialize() . $this->tiles;
71 
72  $this->setResult($ordered, false);
73  }

Field Documentation

◆ $chunk

$chunk
protected

◆ $chunkX

$chunkX
protected

◆ $chunkZ

$chunkZ
protected

◆ $levelId

$levelId
protected

◆ $tiles

$tiles
protected

The documentation for this class was generated from the following file: