aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EntityData.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/RiftLarva.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt3
-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.kt16
9 files changed, 22 insertions, 26 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
index 0bc742198..dad4a1bf3 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
@@ -21,8 +21,7 @@ class EntityData {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
- val entities = EntityUtils.getEntitiesOrNull<EntityLivingBase>() ?: return
- for (entity in entities) {
+ for (entity in EntityUtils.getEntities<EntityLivingBase>()) {
val maxHealth = entity.baseMaxHealth
val oldMaxHealth = maxHealthMap.getOrDefault(entity, -1)
if (oldMaxHealth != maxHealth) {
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/misc/trevor/TrevorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt
index d0363480b..ef861211e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt
@@ -45,7 +45,8 @@ object TrevorSolver {
fun findMob() {
var canSee = false
- val entities = EntityUtils.getAllEntitiesOrNull() ?: return
+ val entities = EntityUtils.getAllEntities()
+ if (entities.isEmpty()) return
for (entity in entities) {
if (entity is EntityOtherPlayerMP) continue
val name = entity.name
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/RiftLarva.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/RiftLarva.kt
index 0b2b868d9..29ef4447c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/RiftLarva.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/RiftLarva.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
-import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.EntityUtils.getEntities
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -35,8 +35,7 @@ class RiftLarva {
}
private fun findLarvas() {
- val list = EntityUtils.getEntitiesOrNull<EntityArmorStand>() ?: return
- for (stand in list) {
+ for (stand in getEntities<EntityArmorStand>()) {
if (stand.hasSkullTexture(larvaSkullTexture)) {
RenderLivingEntityHelper.setEntityColor(
stand,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt
index a54e8f7da..e53e2b339 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt
@@ -3,11 +3,15 @@ package at.hannibal2.skyhanni.features.rift.area.dreadfarm
import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent
import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
-import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.EntityUtils.getEntities
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
+import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.SpecialColour
+import at.hannibal2.skyhanni.utils.TimeUtils
import net.minecraft.client.Minecraft
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
@@ -44,8 +48,7 @@ class VoltHighlighter {
@SubscribeEvent
fun onRender(event: RenderWorldLastEvent) {
if (!RiftAPI.inRift() || !(config.voltRange || config.voltMoodMeter)) return
- val list = EntityUtils.getEntitiesOrNull<EntityLivingBase>() ?: return
- for (entity in list) {
+ for (entity in getEntities<EntityLivingBase>()) {
val state = getVoltState(entity)
if (state == VoltState.NO_VOLT) continue
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt
index 591476665..b8dd715f1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
-import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.EntityUtils.getEntities
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -35,8 +35,7 @@ class RiftOdonata {
}
private fun findOdonatas() {
- val list = EntityUtils.getEntitiesOrNull<EntityArmorStand>() ?: return
- for (stand in list) {
+ for (stand in getEntities<EntityArmorStand>()) {
if (stand.hasSkullTexture(odonataSkullTexture)) {
RenderLivingEntityHelper.setEntityColor(
stand,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt
index da34eeda4..f4a37b8a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt
@@ -20,8 +20,7 @@ class ShyCruxWarnings {
}
private fun checkForShy() {
- val list = EntityUtils.getAllEntitiesOrNull() ?: return
- if (list.any { it.name in shyNames && it.distanceToPlayer() < 8 }) {
+ if (EntityUtils.getAllEntities().any { it.name in shyNames && it.distanceToPlayer() < 8 }) {
TitleUtils.sendTitle("§eLook away!", 150)
}
}
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 818f70219..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,13 +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>()
- inline fun <reified R : Entity> getEntitiesOrNull(): List<R>? = getAllEntitiesOrNull()?.filterIsInstance<R>()
-
- fun getAllEntities(): List<Entity> = getAllEntitiesOrNull() ?: emptyList()
-
- fun getAllEntitiesOrNull(): List<Entity>? = Minecraft.getMinecraft()?.theWorld?.loadedEntityList
+ 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