From 1ee1c7215d643591c66efce7f4749a66f952122c Mon Sep 17 00:00:00 2001 From: xtex Date: Fri, 18 Aug 2023 09:34:07 +0800 Subject: [PATCH] fix: container focus again --- .../quaedam/projection/swarm/ai/NearestVisibleContainer.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 1a63b0b..ceb5b45 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt @@ -34,8 +34,9 @@ class NearestVisibleContainer : Sensor() { if (entity.tickCount and 0b11111 == 0) { // 32gt val pos = level.getChunksNearby(entity.blockPosition(), 1) .flatMap { it.blockEntities.filterValues { be -> be is BaseContainerBlockEntity }.keys } - .shuffled(Random(entity.random.nextLong())) - .minByOrNull { it.distManhattan(entity.blockPosition()) / 5 } + .sortedBy { it.distManhattan(entity.blockPosition()) / 5 } + .shuffled(Random(System.currentTimeMillis() / 10000)) + .first() entity.brain.setMemory(memory.get(), pos) } }