Skip to content

Commit

Permalink
Fix a crash when use hopper counter
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhxiao committed Apr 27, 2022
1 parent 32143e1 commit ce99e30
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mod/function/HopperCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ THook(
trapdoor::Actor *nearestPlayer = nullptr;

auto *hopper_block = real_this->getBlock();
if (!hopper_block) {
// original(hopperActor, index, itemStack);
return;
}
trapdoor::bdsMod->getLevel()->forEachPlayer([&](trapdoor::Actor *player) {
if (!player)
return;
Expand All @@ -135,7 +139,13 @@ THook(
}
});

if (!nearestPlayer) {
// original(hopperActor, index, itemStack);
return;
}

auto bs = nearestPlayer->getBlockSource();

auto hopperBlockVariant =
(trapdoor::FACING)bs->getBlock(*position)->getVariant();
auto attachBlockPos =
Expand Down

0 comments on commit ce99e30

Please sign in to comment.