World: disallow block placement and breaking in unloaded, ungenerated and locked chunks

This commit is contained in:
Dylan K. Taylor 2020-12-04 15:49:35 +00:00
parent bacdb7bde5
commit 1c49cedc8c

View File

@ -1509,6 +1509,13 @@ class World implements ChunkManager{
*/
public function useBreakOn(Vector3 $vector, Item &$item = null, ?Player $player = null, bool $createParticles = false) : bool{
$vector = $vector->floor();
$chunkX = $vector->getFloorX() >> 4;
$chunkZ = $vector->getFloorZ() >> 4;
if(!$this->isChunkLoaded($chunkX, $chunkZ) || !$this->isChunkGenerated($chunkX, $chunkZ) || $this->isChunkLocked($chunkX, $chunkZ)){
return false;
}
$target = $this->getBlock($vector);
$affectedBlocks = $target->getAffectedBlocks();
@ -1614,6 +1621,11 @@ class World implements ChunkManager{
//TODO: build height limit messages for custom world heights and mcregion cap
return false;
}
$chunkX = $blockReplace->getPos()->getFloorX() >> 4;
$chunkZ = $blockReplace->getPos()->getFloorZ() >> 4;
if(!$this->isChunkLoaded($chunkX, $chunkZ) || !$this->isChunkGenerated($chunkX, $chunkZ) || $this->isChunkLocked($chunkX, $chunkZ)){
return false;
}
if($blockClicked->getId() === BlockLegacyIds::AIR){
return false;