aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/summonings
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-23 23:45:24 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-23 23:45:24 +0200
commitf43bac23acf79325f9f4de060b69c5c0b1d870eb (patch)
treef05971f36500a18091762a4b29f0b0415c25558f /src/main/java/at/hannibal2/skyhanni/features/summonings
parenta21c3298d2ae7790b3d3770ee4a135c1817f3018 (diff)
downloadskyhanni-f43bac23acf79325f9f4de060b69c5c0b1d870eb.tar.gz
skyhanni-f43bac23acf79325f9f4de060b69c5c0b1d870eb.tar.bz2
skyhanni-f43bac23acf79325f9f4de060b69c5c0b1d870eb.zip
Using EntityUtils.getEntities everywhere
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/summonings')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt46
2 files changed, 25 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
index 9aa9b2cf2..cf69f0245 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
-import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
@@ -76,7 +75,7 @@ class SummoningMobManager {
}
if (searchArmorStands) {
- Minecraft.getMinecraft().theWorld.loadedEntityList.filter { it is EntityArmorStand && it !in summoningMobNametags }
+ EntityUtils.getAllEntities<EntityArmorStand>().filter { it !in summoningMobNametags }
.forEach {
val name = it.displayName.unformattedText
healthPattern.matchMatcher(name) {
@@ -93,11 +92,11 @@ class SummoningMobManager {
if (searchMobs) {
val playerLocation = LocationUtils.playerLocation()
- Minecraft.getMinecraft().theWorld.loadedEntityList.filter {
- it is EntityLiving && it !in summoningMobs.keys && it.getLorenzVec()
+ EntityUtils.getAllEntities<EntityLiving>().filter {
+ it !in summoningMobs.keys && it.getLorenzVec()
.distance(playerLocation) < 10 && it.ticksExisted < 2
}.forEach {
- summoningMobs[it as EntityLiving] = SummoningMob(System.currentTimeMillis(), name = "Mob")
+ summoningMobs[it] = SummoningMob(System.currentTimeMillis(), name = "Mob")
updateData()
if (summoningMobs.size == summoningsSpawned) {
searchMobs = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt
index cb2c3def5..ad554d251 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.summonings
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -34,47 +35,42 @@ class SummoningSoulsName {
if (!isEnabled()) return
//TODO use packets instead of this
- check()
+ check()
}
private fun check() {
val minecraft = Minecraft.getMinecraft()
- val world = minecraft.theWorld
- for (entity in world.loadedEntityList) {
+ for (entity in EntityUtils.getAllEntities<EntityArmorStand>()) {
if (souls.contains(entity)) continue
- if (entity is EntityArmorStand) {
- if (entity.hasSkullTexture(texture)) {
- val soulLocation = entity.getLorenzVec()
+ if (entity.hasSkullTexture(texture)) {
+ val soulLocation = entity.getLorenzVec()
- val map = mutableMapOf<EntityLiving, Double>()
- for ((mob, loc) in mobsLastLocation) {
- val distance = loc.distance(soulLocation)
- map[mob] = distance
- }
-
- val nearestMob = map.sorted().firstNotNullOfOrNull { it.key }
- if (nearestMob != null) {
- souls[entity] = mobsName[nearestMob]!!
- }
+ val map = mutableMapOf<EntityLiving, Double>()
+ for ((mob, loc) in mobsLastLocation) {
+ val distance = loc.distance(soulLocation)
+ map[mob] = distance
+ }
+ val nearestMob = map.sorted().firstNotNullOfOrNull { it.key }
+ if (nearestMob != null) {
+ souls[entity] = mobsName[nearestMob]!!
}
}
}
- for (entity in world.loadedEntityList) {
- if (entity is EntityLiving) {
- val consumer = entity.getNameTagWith(2, "§c❤")
- if (consumer != null) {
- if (!consumer.name.contains("§e0")) {
- mobsLastLocation[entity] = entity.getLorenzVec()
- mobsName[entity] = consumer.name
- }
+ for (entity in EntityUtils.getAllEntities<EntityLiving>()) {
+ val consumer = entity.getNameTagWith(2, "§c❤")
+ if (consumer != null) {
+ if (!consumer.name.contains("§e0")) {
+ mobsLastLocation[entity] = entity.getLorenzVec()
+ mobsName[entity] = consumer.name
}
}
}
- souls.keys.removeIf { it !in world.loadedEntityList }
+ val entityList = EntityUtils.getAllEntities<EntityArmorStand>()
+ souls.keys.removeIf { it !in entityList }
//TODO fix overhead!
// mobs.keys.removeIf { it !in world.loadedEntityList }
}