summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fishing
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-13 12:40:21 +0200
committerGitHub <noreply@github.com>2024-05-13 12:40:21 +0200
commit4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704 (patch)
tree2fa38db1c75150d3a5f69b14f4654796cbed577b /src/main/java/at/hannibal2/skyhanni/features/fishing
parent253d92a20b93a46d308cc94b73130e87e82f2da1 (diff)
downloadskyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.tar.gz
skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.tar.bz2
skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.zip
Improvement: performance in various ways (#1782)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt10
1 files changed, 6 insertions, 4 deletions
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<Entity>()
- private val hiddenEntities = mutableListOf<Entity>()
+ private val titleEntity = TimeLimitedSet<Entity>(5.seconds)
+ private val hiddenEntities = TimeLimitedSet<Entity>(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