diff --git a/src/Chunk/AnvilChunk.php b/src/Chunk/AnvilChunk.php index 6495d2e..8f8293c 100644 --- a/src/Chunk/AnvilChunk.php +++ b/src/Chunk/AnvilChunk.php @@ -340,4 +340,12 @@ public function getGlobalYPos(): int { return $this->regionPosition[1] * 32 + $this->yPos; } + + /** + * @return void + */ + public function close(): void + { + $this->zlibReader->reset(); + } } diff --git a/src/Chunk/ChunkInterface.php b/src/Chunk/ChunkInterface.php index 703a487..62518b2 100644 --- a/src/Chunk/ChunkInterface.php +++ b/src/Chunk/ChunkInterface.php @@ -71,4 +71,9 @@ public function save(): void; * @return bool */ public function isSaved(): bool; + + /** + * @return void + */ + public function close(): void; } diff --git a/src/Reader/ReaderInterface.php b/src/Reader/ReaderInterface.php index ea9e4b4..a3d63e1 100644 --- a/src/Reader/ReaderInterface.php +++ b/src/Reader/ReaderInterface.php @@ -43,4 +43,9 @@ public function tell(): int; * @return bool */ public function eof(): bool; + + /** + * @return void + */ + public function reset(): void; } diff --git a/src/Reader/ZlibReader.php b/src/Reader/ZlibReader.php index 20d6c21..cd2f433 100644 --- a/src/Reader/ZlibReader.php +++ b/src/Reader/ZlibReader.php @@ -141,6 +141,17 @@ public function rewind(): void $this->pointer = 0; } + /** + * @inheritDoc + */ + public function reset(): void + { + $this->data = ''; + $this->pointer = 0; + $this->resourcePointer = $this->offset; + $this->inflateContext = inflate_init($this->compression); + } + public function eof(): bool { return ($this->resourcePointer >= $this->offset + $this->length || feof($this->resource)) diff --git a/src/Task/RegionTask.php b/src/Task/RegionTask.php index 4cfa0ff..528b242 100644 --- a/src/Task/RegionTask.php +++ b/src/Task/RegionTask.php @@ -42,6 +42,7 @@ public function __construct( } else { $removedChunks++; } + $chunk->close(); } $region->save(); return $removedChunks;