/** * Update the block entity list for this chunk. * * @param Coords\BlockCoords $blockCoords * @param \Nbt\Node|null $blockEntity */ public function updateBlockEntity(Coords\BlockCoords $blockCoords, $blockEntity) { if ($blockEntity === null) { if (isset($this->blockEntities[$blockCoords->toKey()])) { unset($this->blockEntities[$blockCoords->toKey()]); $this->setChanged($blockCoords); } } else { $this->setChanged($blockCoords); // Add the co-ordinates to the block entity $this->updateChildOrCreateInt($blockEntity, 'x', $blockCoords->x); $this->updateChildOrCreateInt($blockEntity, 'y', $blockCoords->y); $this->updateChildOrCreateInt($blockEntity, 'z', $blockCoords->z); $this->blockEntities[$blockCoords->toKey()] = $blockEntity; } }
/** * Get information about the block at the given co-ordinates. * * @param Coords\BlockCoords $coords Co-ordinates of the block * * @return Block Information about the block */ public function getBlock(Coords\BlockCoords $coords) { $chunkRef = $coords->toChunkRef(); $this->initChunk($chunkRef); return $this->chunks[$chunkRef->toKey()]->getBlock($coords); }
/** * Get information about the block at the given co-ordinates. * * @param Coords\BlockCoords $coords Co-ordinates of the block * * @return Block Information about the block */ public function getBlock(Coords\BlockCoords $coords) { $regionRef = $coords->toRegionRef(); $this->initRegion($regionRef); return $this->regions[$regionRef->toKey()]->getBlock($coords); }