aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt12
1 files changed, 6 insertions, 6 deletions
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