diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 22:29:50 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 22:29:50 +0200 |
commit | 30a225daffaabfa0457dbc8e182f575683a0cc95 (patch) | |
tree | df9c5abc4930f5844be65d7fa0b4e3fba6a56115 /src/main/java | |
parent | 5dee3f298497dae472e80235091b659e4042fd49 (diff) | |
download | skyhanni-30a225daffaabfa0457dbc8e182f575683a0cc95.tar.gz skyhanni-30a225daffaabfa0457dbc8e182f575683a0cc95.tar.bz2 skyhanni-30a225daffaabfa0457dbc8e182f575683a0cc95.zip |
added toMutableList back to all entity utils methods, removed OrNull methods
Diffstat (limited to 'src/main/java')
7 files changed, 15 insertions, 19 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/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/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index 818f70219..26860ccc2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -160,9 +160,5 @@ object EntityUtils { inline fun <reified R : Entity> getEntitiesSequence(): Sequence<R> = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.asSequence()?.filterIsInstance<R>() ?: emptySequence() - 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(): List<Entity> = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.toMutableList() ?: emptyList() }
\ No newline at end of file |