Chunk: do not close preexisting tiles in addTile()

if it's desired to actually replace a tile, the old tile should be explicitly removed and closed first.
This commit is contained in:
Dylan K. Taylor 2021-05-12 12:32:36 +01:00
parent b2e806e2fa
commit bdce781c6d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -229,7 +229,7 @@ class Chunk{
$pos = $tile->getPos();
if(isset($this->tiles[$index = Chunk::blockHash($pos->x, $pos->y, $pos->z)]) and $this->tiles[$index] !== $tile){
$this->tiles[$index]->close();
throw new \InvalidArgumentException("Another tile is already at this location");
}
$this->tiles[$index] = $tile;
$this->dirtyFlags |= self::DIRTY_FLAG_TILES;