From 099bc3d09f11712e94d8e9362536dca40fe649e4 Mon Sep 17 00:00:00 2001 From: brokiem Date: Tue, 23 Aug 2022 01:05:52 +0800 Subject: [PATCH] fix game crashes --- .../listener/DataPacketSendListener.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ColinHDev/ActualAntiXRay/listener/DataPacketSendListener.php b/src/ColinHDev/ActualAntiXRay/listener/DataPacketSendListener.php index 08db0dd..be020f1 100644 --- a/src/ColinHDev/ActualAntiXRay/listener/DataPacketSendListener.php +++ b/src/ColinHDev/ActualAntiXRay/listener/DataPacketSendListener.php @@ -49,19 +49,20 @@ public function onDataPacketSend(DataPacketSendEvent $event) : void { // If the send block does not match the existing block at that position, then someone uses this packet // to send fake blocks to the client, for example through the InvMenu virion. // Since we don't want to undermine his efforts, we will ignore this and don't send any block updates. - if ($blockMapping->toRuntimeId($world->getBlockAt($x, $y, $z)->getFullId()) !== $packet->blockRuntimeId) { - continue; - } - $worldName = $world->getFolderName(); - if (!isset($positionsToUpdatePerWorld[$worldName])) { - $positionsToUpdatePerWorld[$worldName] = []; - } - $positionsToUpdatePerWorld[$worldName][World::blockHash($x, $y, $z)] = null; - foreach((new Vector3($x, $y, $z))->sides() as $point) { - foreach(array_merge([$point], $point->sidesArray()) as $point2) { - $hash = World::blockHash($point2->getFloorX(), $point2->getFloorY(), $point2->getFloorZ()); - if (!array_key_exists($hash, $positionsToUpdatePerWorld[$worldName])) { - $positionsToUpdatePerWorld[$worldName][$hash] = $point2; + foreach ($applyableTargets as $networkSession) { + if ($blockMapping->toRuntimeId($world->getBlockAt($x, $y, $z)->getFullId(), RuntimeBlockMapping::getMappingProtocol($networkSession->getProtocolId())) === $packet->blockRuntimeId) { + $worldName = $world->getFolderName(); + if (!isset($positionsToUpdatePerWorld[$worldName])) { + $positionsToUpdatePerWorld[$worldName] = []; + } + $positionsToUpdatePerWorld[$worldName][World::blockHash($x, $y, $z)] = null; + foreach((new Vector3($x, $y, $z))->sides() as $point) { + foreach(array_merge([$point], $point->sidesArray()) as $point2) { + $hash = World::blockHash($point2->getFloorX(), $point2->getFloorY(), $point2->getFloorZ()); + if (!array_key_exists($hash, $positionsToUpdatePerWorld[$worldName])) { + $positionsToUpdatePerWorld[$worldName][$hash] = $point2; + } + } } } }