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
$caches
private
array<string|int, CompressBatchPromise>
$caches
= []
$compressor
private
Compressor
$compressor
$hits
private
int
$hits
= 0
$instances
private
static array<string|int, array<string|int, self>>
$instances
= []
$misses
private
int
$misses
= 0
$world
private
World
$world
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 —getInstance()
Fetches the ChunkCache instance for the given world. This lazily creates cache systems as needed.
public
static getInstance(World $world, Compressor $compressor) : ChunkCache
Parameters
- $world : World
- $compressor : Compressor
Return values
ChunkCache —onBlockChanged()
This method will be called when a block changes in a registered chunk
public
onBlockChanged(Vector3 $block) : void
Parameters
- $block : Vector3
Tags
Return values
void —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
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
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.
__construct()
private
__construct(World $world, Compressor $compressor) : mixed
Parameters
- $world : World
- $compressor : Compressor
Return values
mixed —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
Return values
void —restartPendingRequest()
Restarts an async request for an unresolved chunk.
private
restartPendingRequest(int $chunkX, int $chunkZ) : void
Parameters
- $chunkX : int
- $chunkZ : int