|
44 | 44 | use pocketmine\math\Vector3; |
45 | 45 | use pocketmine\nbt\tag\CompoundTag; |
46 | 46 | use pocketmine\nbt\tag\StringTag; |
| 47 | +use pocketmine\network\mcpe\convert\TypeConverter; |
47 | 48 | use pocketmine\network\mcpe\InventoryManager; |
48 | 49 | use pocketmine\network\mcpe\NetworkSession; |
49 | 50 | use pocketmine\network\mcpe\protocol\ActorEventPacket; |
@@ -498,13 +499,27 @@ private function handleUseItemTransaction(UseItemTransactionData $data) : bool{ |
498 | 499 |
|
499 | 500 | $blockPos = $data->getBlockPosition(); |
500 | 501 | $vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ()); |
501 | | - $this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos, $data->getBlockRuntimeId()); |
502 | | - if($data->getClientInteractPrediction() === PredictedResult::SUCCESS){ |
503 | | - //always sync this in case plugins caused a different result than the client expected |
504 | | - //we *could* try to enhance detection of plugin-altered behaviour, but this would require propagating |
505 | | - //more information up the stack. For now I think this is good enough. |
506 | | - //if only the client would tell us what blocks it thinks changed... |
507 | | - $this->syncBlocksNearby($vBlockPos, $data->getFace()); |
| 502 | + if($this->player->canInteract($vBlockPos->add(0.5, 0.5, 0.5), 15)){ |
| 503 | + $block = $this->player->getWorld()->getBlock($vBlockPos); |
| 504 | + $blockTranslator = TypeConverter::getInstance()->getBlockTranslator(); |
| 505 | + $clientRuntimeId = $data->getBlockRuntimeId(); |
| 506 | + $interactContainedBlock = false; |
| 507 | + |
| 508 | + if(($displaced = $block->getDisplacedBlock()) !== null && $blockTranslator->internalIdToNetworkId($displaced->getStateId()) === $clientRuntimeId){ |
| 509 | + $interactContainedBlock = true; |
| 510 | + }elseif($blockTranslator->internalIdToNetworkId($block->getStateId()) !== $clientRuntimeId){ |
| 511 | + $this->syncBlocksNearby($vBlockPos, $data->getFace()); |
| 512 | + return true; |
| 513 | + } |
| 514 | + |
| 515 | + $this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos, $interactContainedBlock); |
| 516 | + if($data->getClientInteractPrediction() === PredictedResult::SUCCESS){ |
| 517 | + //always sync this in case plugins caused a different result than the client expected |
| 518 | + //we *could* try to enhance detection of plugin-altered behaviour, but this would require propagating |
| 519 | + //more information up the stack. For now I think this is good enough. |
| 520 | + //if only the client would tell us what blocks it thinks changed... |
| 521 | + $this->syncBlocksNearby($vBlockPos, $data->getFace()); |
| 522 | + } |
508 | 523 | } |
509 | 524 | return true; |
510 | 525 | case UseItemTransactionData::ACTION_CLICK_AIR: |
|
0 commit comments