mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
World: Check placed block collision boxes after place()
since we write these into a transaction instead of actually modifying the world directly, we can use the transaction to verify that the placement location is OK before setting the blocks. closes #4248
This commit is contained in:
parent
735c656f9d
commit
d96fc17339
@ -1795,9 +1795,17 @@ class World implements ChunkManager{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($hand->getCollisionBoxes() as $collisionBox){
|
||||
if(count($this->getCollidingEntities($collisionBox)) > 0){
|
||||
return false; //Entity in block
|
||||
$tx = new BlockTransaction($this);
|
||||
if(!$hand->place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($tx->getBlocks() as [$x, $y, $z, $block]){
|
||||
$block->position($this, $x, $y, $z);
|
||||
foreach($block->getCollisionBoxes() as $collisionBox){
|
||||
if(count($entities = $this->getCollidingEntities($collisionBox)) > 0){
|
||||
return false; //Entity in block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1829,8 +1837,7 @@ class World implements ChunkManager{
|
||||
}
|
||||
}
|
||||
|
||||
$tx = new BlockTransaction($this);
|
||||
if(!$hand->place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player) or !$tx->apply()){
|
||||
if(!$tx->apply()){
|
||||
return false;
|
||||
}
|
||||
foreach($tx->getBlocks() as [$x, $y, $z, $_]){
|
||||
|
Loading…
x
Reference in New Issue
Block a user