Skip to content

Commit

Permalink
fix game crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
brokiem committed Aug 22, 2022
1 parent 9759f5d commit 099bc3d
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/ColinHDev/ActualAntiXRay/listener/DataPacketSendListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
}
Expand Down

0 comments on commit 099bc3d

Please sign in to comment.