mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-10 15:59:39 +00:00
Fixed tree trunk generation bug introduced by ac87319aed4d556d85a8aeba0ea6da6667a5408f
Blocks were being overwritten in the writebatch which hadn't yet been set, so reading them from the world yielded air blocks instead of trunk, allowing the generation to overwrite blocks which should have been logs.
This commit is contained in:
parent
6b7710e62b
commit
179fb9c7cb
@ -67,6 +67,33 @@ class BlockWriteBatch{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a block from the given world, masked by the blocks in this writebatch. This can be useful if you want to
|
||||
* add blocks to the batch that depend on previous blocks should they exist.
|
||||
*
|
||||
* @param ChunkManager $world
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public function fetchBlock(ChunkManager $world, Vector3 $pos) : Block{
|
||||
return $this->fetchBlockAt($world, $pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see BlockWriteBatch::fetchBlock()
|
||||
*
|
||||
* @param ChunkManager $world
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public function fetchBlockAt(ChunkManager $world, int $x, int $y, int $z) : Block{
|
||||
return $this->blocks[$x][$y][$z] ?? $world->getBlockAt($x, $y, $z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and attempts to apply the batch to the given world. If any part of the batch fails to validate, no
|
||||
* changes will be made to the world.
|
||||
|
@ -117,7 +117,7 @@ abstract class Tree{
|
||||
$write->addBlockAt($x, $y - 1, $z, BlockFactory::get(Block::DIRT));
|
||||
|
||||
for($yy = 0; $yy < $trunkHeight; ++$yy){
|
||||
if($this->canOverride($level->getBlockAt($x, $y + $yy, $z))){
|
||||
if($this->canOverride($write->fetchBlockAt($level, $x, $y + $yy, $z))){
|
||||
$write->addBlockAt($x, $y + $yy, $z, $this->trunkBlock);
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ abstract class Tree{
|
||||
if($xOff === $mid and $zOff === $mid and ($yOff === 0 or $random->nextBoundedInt(2) === 0)){
|
||||
continue;
|
||||
}
|
||||
if(!$level->getBlockAt($xx, $yy, $zz)->isSolid()){
|
||||
if(!$write->fetchBlockAt($level, $xx, $yy, $zz)->isSolid()){
|
||||
$write->addBlockAt($xx, $yy, $zz, $this->leafBlock);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user