|
36 | 36 | use pocketmine\block\UnknownBlock; |
37 | 37 | use pocketmine\block\utils\Waterloggable; |
38 | 38 | use pocketmine\block\VanillaBlocks; |
39 | | -use pocketmine\block\Water; |
40 | 39 | use pocketmine\data\bedrock\BiomeIds; |
41 | 40 | use pocketmine\data\bedrock\block\BlockStateData; |
42 | 41 | use pocketmine\data\bedrock\block\BlockStateDeserializeException; |
@@ -2029,21 +2028,14 @@ public function getBlockAt(int $x, int $y, int $z, bool $cached = true, bool $ad |
2029 | 2028 | $chunk = $this->chunks[$chunkHash] ?? null; |
2030 | 2029 | if($chunk !== null){ |
2031 | 2030 | $block = $this->blockStateRegistry->fromStateId($chunk->getBlockStateId($x & Chunk::COORD_MASK, $y, $z & Chunk::COORD_MASK)); |
2032 | | - $displacedBlockStateId = $chunk->getDisplacedBlockStateId($x & Chunk::COORD_MASK, $y, $z & Chunk::COORD_MASK); |
2033 | 2031 | }else{ |
2034 | 2032 | $addToCache = false; |
2035 | 2033 | $block = VanillaBlocks::AIR(); |
2036 | | - $displacedBlockStateId = Block::EMPTY_STATE_ID; |
2037 | 2034 | } |
2038 | 2035 | }else{ |
2039 | 2036 | $block = VanillaBlocks::AIR(); |
2040 | | - $displacedBlockStateId = Block::EMPTY_STATE_ID; |
2041 | 2037 | } |
2042 | 2038 |
|
2043 | | - if($block instanceof Waterloggable && $displacedBlockStateId !== Block::EMPTY_STATE_ID){ |
2044 | | - $displacedBlockStateId = $this->blockStateRegistry->fromStateId($displacedBlockStateId); |
2045 | | - $block->setContainedWater($displacedBlockStateId instanceof Water ? $displacedBlockStateId : null); |
2046 | | - } |
2047 | 2039 | $block->position($this, $x, $y, $z); |
2048 | 2040 |
|
2049 | 2041 | if($this->inDynamicStateRecalculation){ |
@@ -2300,6 +2292,9 @@ private function destroyBlockInternal(Block $target, Item $item, ?Player $player |
2300 | 2292 | */ |
2301 | 2293 | public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $clickVector = null, ?Player $player = null, bool $playSound = false, array &$returnedItems = [], bool $interactDisplacedBlock = false) : bool{ |
2302 | 2294 | $blockClicked = $this->getBlock($vector); |
| 2295 | + if($interactDisplacedBlock){ |
| 2296 | + $blockClicked = $blockClicked->getDisplacedBlock() ?? $blockClicked; |
| 2297 | + } |
2303 | 2298 | $blockReplace = $blockClicked->getSide($face); |
2304 | 2299 |
|
2305 | 2300 | if($clickVector === null){ |
@@ -2331,8 +2326,6 @@ public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $cli |
2331 | 2326 | if($player->isSneakPressed()){ |
2332 | 2327 | $ev->setUseItem(false); |
2333 | 2328 | $ev->setUseBlock($item->isNull()); //opening doors is still possible when sneaking if using an empty hand |
2334 | | - }else{ |
2335 | | - $ev->setUseBlock(!$interactDisplacedBlock); |
2336 | 2329 | } |
2337 | 2330 | if($player->isSpectator()){ |
2338 | 2331 | $ev->cancel(); //set it to cancelled so plugins can bypass this |
|
0 commit comments