Documentation

ChunkCache
in package
implements ChunkListener Uses ChunkListenerNoOpTrait

This class is used by the current MCPE protocol system to store cached chunk packets for fast resending.

Interfaces, Classes, Traits and Enums

ChunkListener
This interface allows you to listen for events occurring on or in specific chunks. This will receive events for any chunks which it is registered to listen to.

Table of Contents

$caches  : array<string|int, CompressBatchPromise>
$compressor  : Compressor
$hits  : int
$instances  : array<string|int, array<string|int, self>>
$misses  : int
$world  : World
calculateCacheSize()  : int
Returns the number of bytes occupied by the cache data in this cache. This does not include the size of any promises referenced by the cache.
getHitPercentage()  : float
Returns the percentage of requests to the cache which resulted in a cache hit.
getInstance()  : ChunkCache
Fetches the ChunkCache instance for the given world. This lazily creates cache systems as needed.
onBlockChanged()  : void
This method will be called when a block changes in a registered chunk
onChunkChanged()  : void
This method will be called when a Chunk is replaced by a new one
onChunkLoaded()  : void
onChunkPopulated()  : void
onChunkUnloaded()  : void
This method will be called when a registered chunk is unloaded
pruneCaches()  : void
request()  : CompressBatchPromise
Requests asynchronous preparation of the chunk at the given coordinates.
__construct()  : mixed
destroy()  : bool
destroyOrRestart()  : void
restartPendingRequest()  : void
Restarts an async request for an unresolved chunk.

Properties

$instances

private static array<string|int, array<string|int, self>> $instances = []

Methods

calculateCacheSize()

Returns the number of bytes occupied by the cache data in this cache. This does not include the size of any promises referenced by the cache.

public calculateCacheSize() : int
Return values
int

getHitPercentage()

Returns the percentage of requests to the cache which resulted in a cache hit.

public getHitPercentage() : float
Return values
float

onChunkChanged()

This method will be called when a Chunk is replaced by a new one

public onChunkChanged(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Tags
see
ChunkListener::onChunkChanged()
Return values
void

onChunkLoaded()

public onChunkLoaded(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Return values
void

onChunkPopulated()

public onChunkPopulated(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Return values
void

onChunkUnloaded()

This method will be called when a registered chunk is unloaded

public onChunkUnloaded(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Tags
see
ChunkListener::onChunkUnloaded()
Return values
void

pruneCaches()

public static pruneCaches() : void
Return values
void

request()

Requests asynchronous preparation of the chunk at the given coordinates.

public request(int $chunkX, int $chunkZ) : CompressBatchPromise
Parameters
$chunkX : int
$chunkZ : int
Return values
CompressBatchPromise

a promise of resolution which will contain a compressed chunk packet.

destroy()

private destroy(int $chunkX, int $chunkZ) : bool
Parameters
$chunkX : int
$chunkZ : int
Return values
bool

destroyOrRestart()

private destroyOrRestart(int $chunkX, int $chunkZ) : void
Parameters
$chunkX : int
$chunkZ : int
Tags
throws
InvalidArgumentException
Return values
void

restartPendingRequest()

Restarts an async request for an unresolved chunk.

private restartPendingRequest(int $chunkX, int $chunkZ) : void
Parameters
$chunkX : int
$chunkZ : int
Tags
throws
InvalidArgumentException
Return values
void

Search results