From 9d0d60afd1312e4bf83b173d3964165590b41723 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 21 Jun 2023 15:36:48 +0100 Subject: [PATCH] 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. --- src/event/block/BlockPlaceEvent.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/event/block/BlockPlaceEvent.php b/src/event/block/BlockPlaceEvent.php index b92569fc16..3572cb5e09 100644 --- a/src/event/block/BlockPlaceEvent.php +++ b/src/event/block/BlockPlaceEvent.php @@ -43,7 +43,12 @@ class BlockPlaceEvent extends Event implements Cancellable{ protected BlockTransaction $transaction, protected Block $blockAgainst, 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.