mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 08:35:20 +00:00
First look at 3D biome support
This commit is contained in:
@ -2241,23 +2241,23 @@ class World implements ChunkManager{
|
||||
return ($chunk = $this->loadChunk($x >> Chunk::COORD_BIT_SIZE, $z >> Chunk::COORD_BIT_SIZE)) !== null ? $chunk->getTile($x & Chunk::COORD_MASK, $y, $z & Chunk::COORD_MASK) : null;
|
||||
}
|
||||
|
||||
public function getBiomeId(int $x, int $z) : int{
|
||||
public function getBiomeId(int $x, int $y, int $z) : int{
|
||||
if(($chunk = $this->loadChunk($x >> Chunk::COORD_BIT_SIZE, $z >> Chunk::COORD_BIT_SIZE)) !== null){
|
||||
return $chunk->getBiomeId($x & Chunk::COORD_MASK, $z & Chunk::COORD_MASK);
|
||||
return $chunk->getBiomeId($x & Chunk::COORD_MASK, $y & Chunk::COORD_MASK, $z & Chunk::COORD_MASK);
|
||||
}
|
||||
return BiomeIds::OCEAN; //TODO: this should probably throw instead (terrain not generated yet)
|
||||
}
|
||||
|
||||
public function getBiome(int $x, int $z) : Biome{
|
||||
return BiomeRegistry::getInstance()->getBiome($this->getBiomeId($x, $z));
|
||||
public function getBiome(int $x, int $y, int $z) : Biome{
|
||||
return BiomeRegistry::getInstance()->getBiome($this->getBiomeId($x, $y, $z));
|
||||
}
|
||||
|
||||
public function setBiomeId(int $x, int $z, int $biomeId) : void{
|
||||
public function setBiomeId(int $x, int $y, int $z, int $biomeId) : void{
|
||||
$chunkX = $x >> Chunk::COORD_BIT_SIZE;
|
||||
$chunkZ = $z >> Chunk::COORD_BIT_SIZE;
|
||||
$this->unlockChunk($chunkX, $chunkZ, null);
|
||||
if(($chunk = $this->loadChunk($chunkX, $chunkZ)) !== null){
|
||||
$chunk->setBiomeId($x & Chunk::COORD_MASK, $z & Chunk::COORD_MASK, $biomeId);
|
||||
$chunk->setBiomeId($x & Chunk::COORD_MASK, $y & Chunk::COORD_MASK, $z & Chunk::COORD_MASK, $biomeId);
|
||||
}else{
|
||||
//if we allowed this, the modifications would be lost when the chunk is created
|
||||
throw new WorldException("Cannot set biome in a non-generated chunk");
|
||||
|
Reference in New Issue
Block a user