summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2016-12-06 23:48:32 +0100
committerGitHub <noreply@github.com>2016-12-06 23:48:32 +0100
commite8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45 (patch)
tree34f7304f225f501df8028e09110416992470d895 /src
parentAPIDesc: Fixed wrong cBlockArea parameter descriptions. (diff)
parentFix comparator segfaults (diff)
downloadcuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.tar
cuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.tar.gz
cuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.tar.bz2
cuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.tar.lz
cuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.tar.xz
cuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.tar.zst
cuberite-e8ea1f8cc32f22a3d1b3f7ea6fa399749671cf45.zip
Diffstat (limited to 'src')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h
index debfd6330..34af3ccbc 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneComparatorHandler.h
@@ -54,7 +54,14 @@ public:
virtual bool Item(cBlockEntity * a_BlockEntity) override
{
- auto & Contents = static_cast<cBlockEntityWithItems *>(a_BlockEntity)->GetContents();
+ // Skip BlockEntities that don't have slots
+ auto BlockEntityWithItems = dynamic_cast<cBlockEntityWithItems *>(a_BlockEntity);
+ if (BlockEntityWithItems == nullptr)
+ {
+ return false;
+ }
+
+ auto & Contents = BlockEntityWithItems->GetContents();
float Fullness = 0; // Is a floating-point type to allow later calculation to produce a non-truncated value
for (int Slot = 0; Slot != Contents.GetNumSlots(); ++Slot)