From abb564695963bc73dc3f42092d5b7abf1b858472 Mon Sep 17 00:00:00 2001 From: xtex Date: Mon, 21 Aug 2023 09:10:13 +0800 Subject: [PATCH] fix: game crash when no container available --- .../quaedam/projection/swarm/ai/NearestVisibleContainer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt b/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt index ceb5b45..b83718b 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt @@ -36,7 +36,7 @@ class NearestVisibleContainer : Sensor() { .flatMap { it.blockEntities.filterValues { be -> be is BaseContainerBlockEntity }.keys } .sortedBy { it.distManhattan(entity.blockPosition()) / 5 } .shuffled(Random(System.currentTimeMillis() / 10000)) - .first() + .firstOrNull() entity.brain.setMemory(memory.get(), pos) } }