mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-25 12:54:03 +00:00
BlockPlaceEvent: ensure that getPosition() is always correct
since BlockTransaction was designed to be World-agnostic, it can't position() any blocks, since Position requires a World. This workaround is the best we can do for now; however, it would probably be wise to deprecate getTransaction() in favour of a dedicated getBlocks() method which takes care of this, as BlockPlaceEvent is currently quite obnoxious to use.
This commit is contained in:
parent
391732f00c
commit
9d0d60afd1
@ -43,7 +43,12 @@ class BlockPlaceEvent extends Event implements Cancellable{
|
|||||||
protected BlockTransaction $transaction,
|
protected BlockTransaction $transaction,
|
||||||
protected Block $blockAgainst,
|
protected Block $blockAgainst,
|
||||||
protected Item $item
|
protected Item $item
|
||||||
){}
|
){
|
||||||
|
$world = $this->blockAgainst->getPosition()->getWorld();
|
||||||
|
foreach($this->transaction->getBlocks() as [$x, $y, $z, $block]){
|
||||||
|
$block->position($world, $x, $y, $z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player who is placing the block.
|
* Returns the player who is placing the block.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user