summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt14
1 files changed, 8 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 42a5b5583..818f70219 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): Sequence<T> =
+ inline fun <reified T : Entity> getEntitiesNextToPlayer(radius: Double): List<T> =
getEntitiesNearby<T>(LocationUtils.playerLocation(), radius)
- inline fun <reified T : Entity> getEntitiesNearby(location: LorenzVec, radius: Double): Sequence<T> =
+ inline fun <reified T : Entity> getEntitiesNearby(location: LorenzVec, radius: Double): List<T> =
getEntities<T>().filter { it.distanceTo(location) < radius }
fun EntityLivingBase.isAtFullHealth() = baseMaxHealth == health.toInt()
@@ -156,11 +156,13 @@ object EntityUtils {
fun EntityEnderman.getBlockInHand(): IBlockState? = heldBlockState
- inline fun <reified R : Entity> getEntities(): Sequence<R> = getAllEntities().filterIsInstance<R>()
+ 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> getEntitiesOrNull(): Sequence<R>? = getAllEntitiesOrNull()?.filterIsInstance<R>()
+ inline fun <reified R : Entity> getEntitiesOrNull(): List<R>? = getAllEntitiesOrNull()?.filterIsInstance<R>()
- fun getAllEntities(): Sequence<Entity> = getAllEntitiesOrNull() ?: emptySequence()
+ fun getAllEntities(): List<Entity> = getAllEntitiesOrNull() ?: emptyList()
- fun getAllEntitiesOrNull(): Sequence<Entity>? = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.asSequence()
+ fun getAllEntitiesOrNull(): List<Entity>? = Minecraft.getMinecraft()?.theWorld?.loadedEntityList
} \ No newline at end of file