diff options
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 |