aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-03 22:44:11 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-03 22:44:11 +0200
commitdb51db7bfda2f660bb798aa39804c255c49f39d5 (patch)
treedf6ae8f4d5d78847f0863881dfba29ec5fd14b0d /src/main/java/at
parent30a225daffaabfa0457dbc8e182f575683a0cc95 (diff)
downloadskyhanni-db51db7bfda2f660bb798aa39804c255c49f39d5.tar.gz
skyhanni-db51db7bfda2f660bb798aa39804c255c49f39d5.tar.bz2
skyhanni-db51db7bfda2f660bb798aa39804c255c49f39d5.zip
changed lists to sequences in eneity utils, part 2
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt12
3 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
index 9998edca6..83a2abbec 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
@@ -300,7 +300,7 @@ class DamageIndicatorManager {
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
data = data.editCopy {
- EntityUtils.getEntitiesSequence<EntityLivingBase>().mapNotNull(::checkEntity).forEach { this put it }
+ EntityUtils.getEntities<EntityLivingBase>().mapNotNull(::checkEntity).forEach { this put it }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt
index d6ae27f3b..58ef50f08 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt
@@ -20,7 +20,7 @@ class EndermanSlayerHideParticles {
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
- endermanLocations = EntityUtils.getEntities<EntityEnderman>().map { it.getLorenzVec() }
+ endermanLocations = EntityUtils.getEntities<EntityEnderman>().map { it.getLorenzVec() }.toList()
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index 26860ccc2..a31e3e7c1 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -126,10 +126,10 @@ object EntityUtils {
?.value
}
- inline fun <reified T : Entity> getEntitiesNextToPlayer(radius: Double): List<T> =
+ inline fun <reified T : Entity> getEntitiesNextToPlayer(radius: Double): Sequence<T> =
getEntitiesNearby<T>(LocationUtils.playerLocation(), radius)
- inline fun <reified T : Entity> getEntitiesNearby(location: LorenzVec, radius: Double): List<T> =
+ inline fun <reified T : Entity> getEntitiesNearby(location: LorenzVec, radius: Double): Sequence<T> =
getEntities<T>().filter { it.distanceTo(location) < radius }
fun EntityLivingBase.isAtFullHealth() = baseMaxHealth == health.toInt()
@@ -156,9 +156,9 @@ object EntityUtils {
fun EntityEnderman.getBlockInHand(): IBlockState? = heldBlockState
- inline fun <reified R : Entity> getEntities(): List<R> = getAllEntities().filterIsInstance<R>()
- inline fun <reified R : Entity> getEntitiesSequence(): Sequence<R> =
- Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.asSequence()?.filterIsInstance<R>() ?: emptySequence()
+ inline fun <reified R : Entity> getEntities(): Sequence<R> = getAllEntities().filterIsInstance<R>()
- fun getAllEntities(): List<Entity> = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.toMutableList() ?: emptyList()
+ fun getAllEntities(): Sequence<Entity> = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.let {
+ if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList()
+ }?.asSequence() ?: emptySequence<Entity>()
} \ No newline at end of file