From ce99e30e579b02382e0e484c5528abbc260a1f83 Mon Sep 17 00:00:00 2001 From: hhhxiao <1417599491@qq.com> Date: Wed, 27 Apr 2022 11:13:21 +0800 Subject: [PATCH] Fix a crash when use hopper counter --- mod/function/HopperCounter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mod/function/HopperCounter.cpp b/mod/function/HopperCounter.cpp index fdfa0b8..4fb1f99 100644 --- a/mod/function/HopperCounter.cpp +++ b/mod/function/HopperCounter.cpp @@ -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; @@ -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 =