From db74d07155b8aafb2306ca9679842437798a75de Mon Sep 17 00:00:00 2001 From: xtex Date: Thu, 10 Aug 2023 11:48:16 +0800 Subject: [PATCH] fix: mitigation for container tracker --- .../quaedam/projection/swarm/ai/NearestVisibleContainer.kt | 4 +++- 1 file changed, 3 insertions(+), 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 eb0e6c3..1a63b0b 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ai/NearestVisibleContainer.kt @@ -10,6 +10,7 @@ import net.minecraft.world.level.block.entity.BaseContainerBlockEntity import quaedam.Quaedam import quaedam.utils.getChunksNearby import java.util.* +import kotlin.random.Random class NearestVisibleContainer : Sensor() { @@ -33,7 +34,8 @@ 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 } - .minByOrNull { it.distManhattan(entity.blockPosition()) } + .shuffled(Random(entity.random.nextLong())) + .minByOrNull { it.distManhattan(entity.blockPosition()) / 5 } entity.brain.setMemory(memory.get(), pos) } }