Fix remaining usage of deprecated getBlockLayers() in World.php

- Replace getBlockLayers() with getBlockLayer() and getLiquidLayer()
- Ensures all block layers are validated when setting chunks
- Completes the migration away from the deprecated method
This commit is contained in:
Dylan T. 2025-06-27 16:30:40 +00:00
parent 0f932f7cc0
commit a0f5ad1669

View File

@ -2607,7 +2607,7 @@ class World implements ChunkManager{
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk) : void{ public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk) : void{
foreach($chunk->getSubChunks() as $subChunk){ foreach($chunk->getSubChunks() as $subChunk){
foreach($subChunk->getBlockLayers() as $blockLayer){ foreach([$subChunk->getBlockLayer(), $subChunk->getLiquidLayer()] as $blockLayer){
foreach($blockLayer->getPalette() as $blockStateId){ foreach($blockLayer->getPalette() as $blockStateId){
if(!$this->blockStateRegistry->hasStateId($blockStateId)){ if(!$this->blockStateRegistry->hasStateId($blockStateId)){
throw new \InvalidArgumentException("Provided chunk contains unknown/unregistered blocks (found unknown state ID $blockStateId)"); throw new \InvalidArgumentException("Provided chunk contains unknown/unregistered blocks (found unknown state ID $blockStateId)");