From db51db7bfda2f660bb798aa39804c255c49f39d5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 3 Aug 2023 22:44:11 +0200 Subject: changed lists to sequences in eneity utils, part 2 --- src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') 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 getEntitiesNextToPlayer(radius: Double): List = + inline fun getEntitiesNextToPlayer(radius: Double): Sequence = getEntitiesNearby(LocationUtils.playerLocation(), radius) - inline fun getEntitiesNearby(location: LorenzVec, radius: Double): List = + inline fun getEntitiesNearby(location: LorenzVec, radius: Double): Sequence = getEntities().filter { it.distanceTo(location) < radius } fun EntityLivingBase.isAtFullHealth() = baseMaxHealth == health.toInt() @@ -156,9 +156,9 @@ object EntityUtils { fun EntityEnderman.getBlockInHand(): IBlockState? = heldBlockState - inline fun getEntities(): List = getAllEntities().filterIsInstance() - inline fun getEntitiesSequence(): Sequence = - Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.asSequence()?.filterIsInstance() ?: emptySequence() + inline fun getEntities(): Sequence = getAllEntities().filterIsInstance() - fun getAllEntities(): List = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.toMutableList() ?: emptyList() + fun getAllEntities(): Sequence = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.let { + if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList() + }?.asSequence() ?: emptySequence() } \ No newline at end of file -- cgit