From 4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 13 May 2024 12:40:21 +0200 Subject: Improvement: performance in various ways (#1782) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing') diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt index d4b741472..4ba88f1cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt @@ -7,16 +7,18 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.TimeLimitedSet import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds class ChumBucketHider { private val config get() = SkyHanniMod.feature.fishing.chumBucketHider - private val titleEntity = mutableListOf() - private val hiddenEntities = mutableListOf() + private val titleEntity = TimeLimitedSet(5.seconds) + private val hiddenEntities = TimeLimitedSet(5.seconds) @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { @@ -50,7 +52,7 @@ class ChumBucketHider { // Second text line if (name.contains("/10 §aChums")) { val entityLocation = entity.getLorenzVec() - for (title in titleEntity) { + for (title in titleEntity.toSet()) { if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { hiddenEntities.add(entity) event.isCanceled = true @@ -62,7 +64,7 @@ class ChumBucketHider { // Chum Bucket if (config.hideBucket.get() && entity.inventory.any { it != null && (it.name == "§fEmpty Chum Bucket" || it.name == "§aEmpty Chumcap Bucket") }) { val entityLocation = entity.getLorenzVec() - for (title in titleEntity) { + for (title in titleEntity.toSet()) { if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { hiddenEntities.add(entity) event.isCanceled = true -- cgit