aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EntityData.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/RiftLarva.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt2
-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
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt13
29 files changed, 118 insertions, 167 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
index c57119818..e64f09403 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
@@ -26,11 +27,8 @@ class EntityData {
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START) return
- val minecraft = Minecraft.getMinecraft() ?: return
- val theWorld = minecraft.theWorld ?: return
- for (entity in theWorld.loadedEntityList) {
- if (entity !is EntityLivingBase) continue
-
+ val entities = EntityUtils.getEntitiesOrNull<EntityLivingBase>() ?: return
+ for (entity in entities) {
val maxHealth = entity.baseMaxHealth
val oldMaxHealth = maxHealthMap.getOrDefault(entity, -1)
if (oldMaxHealth != maxHealth) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
index 2bfb0c9cf..33e6fdd25 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
@@ -3,12 +3,12 @@ package at.hannibal2.skyhanni.features.chat
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.getLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -57,8 +57,7 @@ class PlayerDeathMessages {
private fun checkOtherPlayers() {
val location = LocationUtils.playerLocation()
- for (otherPlayer in Minecraft.getMinecraft().theWorld.loadedEntityList
- .filterIsInstance<EntityOtherPlayerMP>()
+ for (otherPlayer in EntityUtils.getAllEntities<EntityOtherPlayerMP>()
.filter { it.getLorenzVec().distance(location) < 25 }) {
lastTimePlayerSeen[otherPlayer.name] = System.currentTimeMillis()
}
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 0e8d653b6..227790c3e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt
@@ -300,10 +300,8 @@ class DamageIndicatorManager {
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (!LorenzUtils.inSkyBlock) return
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if (entity is EntityLivingBase) {
- checkEntity(entity)
- }
+ for (entity in EntityUtils.getAllEntities<EntityLivingBase>()) {
+ checkEntity(entity)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt
index 1cf80af5d..ad03f6c27 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt
@@ -6,17 +6,13 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonData
import at.hannibal2.skyhanni.features.dungeon.DungeonLividFinder
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.hasBossHealth
import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth
import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
-import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.StringUtils.matchRegex
-import at.hannibal2.skyhanni.utils.getLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLiving
@@ -583,17 +579,15 @@ class MobFinder {
private fun findGuardians() {
guardians.clear()
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if (entity is EntityGuardian) {
- //F3
- if (entity.hasMaxHealth(1_000_000) || entity.hasMaxHealth(1_200_000)) {
- guardians.add(entity)
- }
+ for (entity in EntityUtils.getAllEntities<EntityGuardian>()) {
+ //F3
+ if (entity.hasMaxHealth(1_000_000) || entity.hasMaxHealth(1_200_000)) {
+ guardians.add(entity)
+ }
- //M3
- if (entity.hasMaxHealth(120_000_000) || entity.hasMaxHealth(240_000_000)) {
- guardians.add(entity)
- }
+ //M3
+ if (entity.hasMaxHealth(120_000_000) || entity.hasMaxHealth(240_000_000)) {
+ guardians.add(entity)
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt
index 369d6e762..241d3d5b4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -36,8 +37,7 @@ object DungeonLividFinder {
val dyeColor = blockLocation.getBlockStateAt().getValue(BlockStainedGlass.COLOR)
val chatColor = dyeColor.toLorenzColor()?.getChatColor() ?: return
- val world = Minecraft.getMinecraft().theWorld
- val lividEntity = world.loadedEntityList.filterIsInstance<EntityArmorStand>()
+ val lividEntity = EntityUtils.getAllEntities<EntityArmorStand>()
.firstOrNull { it.name.startsWith("${chatColor}﴾ ${chatColor}§lLivid") } ?: return
val aabb = with(lividEntity) {
@@ -50,6 +50,7 @@ object DungeonLividFinder {
posZ + 0.5
)
}
+ val world = Minecraft.getMinecraft().theWorld
livid = world.getEntitiesWithinAABB(EntityOtherPlayerMP::class.java, aabb)
.takeIf { it.size == 1 }?.firstOrNull() ?: return
livid?.let {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
index 95bf9c30a..3e88766c2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
@@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -60,8 +59,7 @@ class BarnFishingTimer {
}
}
- private fun countMobs() = Minecraft.getMinecraft().theWorld.loadedEntityList
- .filterIsInstance<EntityArmorStand>()
+ private fun countMobs() = EntityUtils.getAllEntities<EntityArmorStand>()
.map { it.name }
.count { it.endsWith("§c❤") }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt
index 1e72f0c4f..8f98d54ca 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt
@@ -1,16 +1,12 @@
package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LocationUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import com.google.common.cache.CacheBuilder
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityItem
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -48,7 +44,7 @@ class ShowFishingItemName {
fun onRenderWorld(event: RenderWorldLastEvent) {
if (!isEnabled()) return
if (hasRodInHand) {
- for (entityItem in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityItem>()) {
+ for (entityItem in EntityUtils.getAllEntities<EntityItem>()) {
val location = event.exactLocation(entityItem).add(0.0, 0.8, 0.0)
if (location.distance(LocationUtils.playerLocation()) > 15) continue
val itemStack = entityItem.entityItem
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 8d325bbf9..3bd53b846 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -600,20 +600,17 @@ class GardenVisitorFeatures {
}
private fun findEntity(nameTag: EntityArmorStand, visitor: Visitor) {
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if (entity is EntityArmorStand) continue
+ for (entity in EntityUtils.getAllEntities<EntityArmorStand>()) {
if (entity.getLorenzVec().distanceIgnoreY(nameTag.getLorenzVec()) != 0.0) continue
- visitor.entityId = entity?.entityId ?: 0
+ visitor.entityId = entity.entityId
visitor.nameTagEntityId = nameTag.entityId
}
}
private fun findNametag(visitorName: String): EntityArmorStand? {
val foundVisitorNameTags = mutableListOf<EntityArmorStand>()
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if (entity !is EntityArmorStand) continue
-
+ for (entity in EntityUtils.getAllEntities<EntityArmorStand>()) {
if (entity.name.removeColor() == visitorName) {
foundVisitorNameTags.add(entity)
}
@@ -624,8 +621,7 @@ class GardenVisitorFeatures {
if (foundVisitorNameTags.size != 2) return null
for (tag in foundVisitorNameTags.toMutableList()) {
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if (entity !is EntityArmorStand) continue
+ for (entity in EntityUtils.getAllEntities<EntityArmorStand>()) {
if (entity in foundVisitorNameTags) continue
val distance = entity.getLorenzVec().distance(tag.getLorenzVec())
if (distance < 1.5 && entity.name == "§bSam") {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt
index 42c796c5a..45614b3dc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt
@@ -7,10 +7,10 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
-import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.monster.EntityEndermite
import net.minecraft.entity.monster.EntityIronGolem
@@ -48,7 +48,7 @@ class HighlightMiningCommissionMobs {
if (!isEnabled()) return
if (!event.isMod(40)) return
- val entities = Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityLivingBase>()
+ val entities = EntityUtils.getAllEntities<EntityLivingBase>()
for ((type, entity) in active.flatMap { type -> entities.map { type to it } }) {
if (type.isMob(entity)) {
RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.YELLOW.toColor().withAlpha(127))
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt
index 3e7547660..688649905 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.RenderMobColoredEvent
import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.client.Minecraft
@@ -46,14 +47,12 @@ class MarkedPlayerManager {
}
private fun findPlayers() {
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if (entity is EntityOtherPlayerMP) {
- if (entity in markedPlayers.values) continue
-
- val name = entity.name.lowercase()
- if (name in playerNamesToMark) {
- markedPlayers[name] = entity
- }
+ for (entity in EntityUtils.getAllEntities<EntityOtherPlayerMP>()) {
+ if (entity in markedPlayers.values) continue
+
+ val name = entity.name.lowercase()
+ if (name in playerNamesToMark) {
+ markedPlayers[name] = entity
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt
index ca12ceea3..b91865aa3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt
@@ -3,9 +3,9 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonData
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.entity.projectile.EntitySmallFireball
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -36,8 +36,7 @@ class ParticleHider {
if (SkyHanniMod.feature.misc.hideFireballParticles) {
if (type == EnumParticleTypes.SMOKE_NORMAL || type == EnumParticleTypes.SMOKE_LARGE) {
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList.toMutableList()) {
- if (entity !is EntitySmallFireball) continue
+ for (entity in EntityUtils.getAllEntities<EntitySmallFireball>()) {
val distance = entity.getLorenzVec().distance(event.location)
if (distance < 5) {
event.isCanceled = true
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt
index 11d0e350d..81a20c679 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt
@@ -2,15 +2,11 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
-import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
-import at.hannibal2.skyhanni.utils.SpecialColour
-import at.hannibal2.skyhanni.utils.getLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.init.Blocks
import net.minecraftforge.client.event.RenderWorldLastEvent
@@ -29,9 +25,10 @@ class ThunderSparksHighlight {
fun onTick(event: TickEvent.ClientTickEvent) {
if (!isEnabled()) return
- Minecraft.getMinecraft().theWorld.loadedEntityList.filter {
- it is EntityArmorStand && it !in sparks && it.hasSkullTexture(texture)
- }.forEach { sparks.add(it as EntityArmorStand) }
+
+ EntityUtils.getAllEntities<EntityArmorStand>().filter {
+ it !in sparks && it.hasSkullTexture(texture)
+ }.forEach { sparks.add(it) }
}
@SubscribeEvent
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 1588d2c22..d0363480b 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
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.misc.trevor
import at.hannibal2.skyhanni.data.TitleUtils
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
@@ -44,8 +45,8 @@ object TrevorSolver {
fun findMob() {
var canSee = false
- val world = Minecraft.getMinecraft().theWorld ?: return
- for (entity in world.getLoadedEntityList()) {
+ val entities = EntityUtils.getAllEntitiesOrNull() ?: return
+ for (entity in entities) {
if (entity is EntityOtherPlayerMP) continue
val name = entity.name
val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth else 0
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
index 4e9382d8f..074fc191b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
@@ -7,10 +7,10 @@ import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsWith
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityBlaze
@@ -37,7 +37,7 @@ class AshfangBlazes {
}
if (nearAshfang) {
- for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityBlaze>()
+ for (entity in EntityUtils.getAllEntities<EntityBlaze>()
.filter { it !in blazeColor.keys }) {
val list = entity.getAllNameTagsWith(2, "Ashfang")
if (list.size == 1) {
@@ -70,8 +70,7 @@ class AshfangBlazes {
}
private fun checkNearAshfang() {
- nearAshfang = Minecraft.getMinecraft().theWorld.loadedEntityList
- .any { it is EntityArmorStand && it.name.contains("Ashfang") }
+ nearAshfang = EntityUtils.getAllEntities<EntityArmorStand>().any { it.name.contains("Ashfang") }
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt
index 5649cc481..b9ecf3200 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt
@@ -4,13 +4,9 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
-import at.hannibal2.skyhanni.utils.LocationUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
-import at.hannibal2.skyhanni.utils.SpecialColour
-import at.hannibal2.skyhanni.utils.getLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.event.world.WorldEvent
@@ -28,9 +24,9 @@ class AshfangBlazingSouls {
fun onTick(event: TickEvent.ClientTickEvent) {
if (!isEnabled()) return
- Minecraft.getMinecraft().theWorld.loadedEntityList.filter {
- it is EntityArmorStand && it !in souls && it.hasSkullTexture(texture)
- }.forEach { souls.add(it as EntityArmorStand) }
+ EntityUtils.getAllEntities<EntityArmorStand>()
+ .filter { it !in souls && it.hasSkullTexture(texture)
+ }.forEach { souls.add(it) }
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt
index be68a1583..da9d134e6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.event.world.WorldEvent
@@ -24,10 +23,9 @@ class AshfangGravityOrbs {
fun onTick(event: TickEvent.ClientTickEvent) {
if (!isEnabled()) return
- Minecraft.getMinecraft().theWorld.loadedEntityList
- .filter {
- it is EntityArmorStand && it !in orbs && it.hasSkullTexture(texture)
- }.forEach { orbs.add(it as EntityArmorStand) }
+ EntityUtils.getAllEntities<EntityArmorStand>()
+ .filter { it !in orbs && it.hasSkullTexture(texture) }
+ .forEach { orbs.add(it) }
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt
index 73bebe98e..e21e23f07 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt
@@ -4,11 +4,11 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,9 +22,8 @@ class AshfangNextResetCooldown {
fun renderOverlay(event: ClientTickEvent) {
if (!isEnabled()) return
- if (Minecraft.getMinecraft().theWorld.loadedEntityList.any {
- it is EntityArmorStand && it.posY > 145 &&
- (it.name.contains("§c§9Ashfang Acolyte§r") || it.name.contains("§c§cAshfang Underling§r"))
+ if (EntityUtils.getAllEntities<EntityArmorStand>().any {
+ it.posY > 145 && (it.name.contains("§c§9Ashfang Acolyte§r") || it.name.contains("§c§cAshfang Underling§r"))
}) {
spawnTime = System.currentTimeMillis()
}
@@ -38,7 +37,10 @@ class AshfangNextResetCooldown {
val remainingTime = spawnTime + 46_100 - System.currentTimeMillis()
if (remainingTime > 0) {
val format = TimeUtils.formatDuration(remainingTime, TimeUnit.SECOND, showMilliSeconds = true)
- SkyHanniMod.feature.ashfang.nextResetCooldownPos.renderString("§cAshfang next reset in: §a$format", posLabel = "Ashfang Reset Cooldown")
+ SkyHanniMod.feature.ashfang.nextResetCooldownPos.renderString(
+ "§cAshfang next reset in: §a$format",
+ posLabel = "Ashfang Reset Cooldown"
+ )
} else {
spawnTime = -1
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt
index 7b83e1487..4f23ce53e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/VampireSlayerFeatures.kt
@@ -9,16 +9,12 @@ 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.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsInRadiusWith
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
-import at.hannibal2.skyhanni.utils.LocationUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor
-import at.hannibal2.skyhanni.utils.getLorenzVec
-import at.hannibal2.skyhanni.utils.toLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.EntityLivingBase
@@ -46,7 +42,7 @@ class VampireSlayerFeatures {
if (!event.isMod(5)) return
val start = LocationUtils.playerLocation()
if (config.ownBoss.highlight || config.othersBoss.highlight || config.coopsBossHighlight.highlight) {
- Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityOtherPlayerMP>().forEach {
+ EntityUtils.getAllEntities<EntityOtherPlayerMP>().forEach {
val vec = it.position.toLorenzVec()
val distance = start.distance(vec)
if (distance <= 15)
@@ -54,7 +50,7 @@ class VampireSlayerFeatures {
}
}
if (config.bloodIchor.highlight || config.killerSpring.highlight) {
- Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>().forEach { stand ->
+ EntityUtils.getAllEntities<EntityArmorStand>().forEach { stand ->
val vec = stand.position.toLorenzVec()
val distance = start.distance(vec)
val isIchor = stand.hasSkullTexture(bloodIchorTexture)
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 164faa446..2ee01875d 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,11 +4,11 @@ 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.hasSkullTexture
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -35,9 +35,8 @@ class RiftLarva {
}
private fun findLarvas() {
-
- val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return
- for (stand in list.filterIsInstance<EntityArmorStand>()) {
+ val list = EntityUtils.getEntitiesOrNull<EntityArmorStand>() ?: return
+ for (stand in list) {
if (stand.hasSkullTexture(larvaSkullTexture)) {
RenderLivingEntityHelper.setEntityColor(
stand,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt
index 8c8debba1..62f515045 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt
@@ -5,14 +5,9 @@ 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.LocationUtils
-import at.hannibal2.skyhanni.utils.LocationUtils.canSee
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.getLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -28,7 +23,7 @@ class BlobbercystsHighlight {
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
if (!event.isMod(5)) return
- Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityOtherPlayerMP>().forEach {
+ EntityUtils.getAllEntities<EntityOtherPlayerMP>().forEach {
if (it.name == blobberName) {
RenderLivingEntityHelper.setEntityColor(it, Color.RED.withAlpha(80)) { isEnabled() }
RenderLivingEntityHelper.setNoHurtTime(it) { isEnabled() }
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 2e8bd9c0d..a54e8f7da 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,14 +3,11 @@ 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.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
@@ -47,9 +44,8 @@ class VoltHighlighter {
@SubscribeEvent
fun onRender(event: RenderWorldLastEvent) {
if (!RiftAPI.inRift() || !(config.voltRange || config.voltMoodMeter)) return
- val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return
+ val list = EntityUtils.getEntitiesOrNull<EntityLivingBase>() ?: return
for (entity in list) {
- if (entity !is EntityLivingBase) continue
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 8d0e93594..e2a2ebf55 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,11 +4,11 @@ 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.hasSkullTexture
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -35,9 +35,8 @@ class RiftOdonata {
}
private fun findOdonatas() {
-
- val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return
- for (stand in list.filterIsInstance<EntityArmorStand>()) {
+ val list = EntityUtils.getEntitiesOrNull<EntityArmorStand>() ?: return
+ for (stand in list) {
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 7641cc6b7..da34eeda4 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
@@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.rift.area.wyldwoods
import at.hannibal2.skyhanni.data.TitleUtils
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
-import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ShyCruxWarnings {
@@ -20,7 +20,7 @@ class ShyCruxWarnings {
}
private fun checkForShy() {
- val list = Minecraft.getMinecraft().theWorld?.getLoadedEntityList() ?: return
+ val list = EntityUtils.getAllEntitiesOrNull() ?: return
if (list.any { it.name in shyNames && it.distanceToPlayer() < 8 }) {
TitleUtils.sendTitle("§eLook away!", 150)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt
index 10e64ebd8..62a1428c8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.slayer
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.SlayerAPI
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
@@ -10,7 +11,6 @@ import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import com.google.common.cache.CacheBuilder
-import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityItem
import net.minecraft.init.Items
import net.minecraftforge.client.event.RenderWorldLastEvent
@@ -31,7 +31,7 @@ class SlayerItemsOnGround {
if (!SlayerAPI.isInSlayerArea) return
if (!SlayerAPI.hasActiveSlayerQuest()) return
- for (entityItem in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityItem>()) {
+ for (entityItem in EntityUtils.getAllEntities<EntityItem>()) {
val location = event.exactLocation(entityItem).add(0.0, 0.8, 0.0)
if (location.distance(LocationUtils.playerLocation()) > 15) continue
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..e958dac8c 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.getAllEntities<EntityEnderman>().map { it.getLorenzVec() }
}
@SubscribeEvent
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 }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
index 5161005a4..661436c5e 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
@@ -1,16 +1,13 @@
package at.hannibal2.skyhanni.test.command
+import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand
import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LocationUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
-import at.hannibal2.skyhanni.utils.OSUtils
-import at.hannibal2.skyhanni.utils.toLorenzVec
-import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
@@ -28,14 +25,12 @@ object CopyNearbyEntitiesCommand {
searchRadius = args[0].toInt()
}
- val minecraft = Minecraft.getMinecraft()
val start = LocationUtils.playerLocation()
- val world = minecraft.theWorld
val resultList = mutableListOf<String>()
var counter = 0
- for (entity in world.loadedEntityList) {
+ for (entity in EntityUtils.getEntities()) {
val position = entity.position
val vec = position.toLorenzVec()
val distance = start.distance(vec)
@@ -96,7 +91,7 @@ object CopyNearbyEntitiesCommand {
is EntityEnderman -> {
resultList.add("EntityEnderman:")
- val heldBlockState = entity.heldBlockState
+ val heldBlockState = entity.getBlockInHand()
resultList.add("- heldBlockState: $heldBlockState")
if (heldBlockState != null) {
val block = heldBlockState.block
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index fcdfb5cc4..59f3f26b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
+import net.minecraft.block.state.IBlockState
import net.minecraft.client.Minecraft
import net.minecraft.client.multiplayer.WorldClient
import net.minecraft.entity.Entity
@@ -131,7 +132,7 @@ object EntityUtils {
getEntitiesNearby(LocationUtils.playerLocation(), radius)
inline fun <reified T : Entity> getEntitiesNearby(location: LorenzVec, radius: Double): List<T> =
- getLoadedEntityList().filterIsInstance<T>().filter { it.distanceTo(location) < radius }
+ getEntities().filterIsInstance<T>().filter { it.distanceTo(location) < radius }
fun EntityLivingBase.isAtFullHealth() = baseMaxHealth == health.toInt()
@@ -155,9 +156,13 @@ object EntityUtils {
fun EntityLivingBase.getArmorInventory(): Array<ItemStack?>? =
if (this is EntityPlayer) inventory.armorInventory else null
- fun EntityEnderman.getBlockInHand() = heldBlockState
+ fun EntityEnderman.getBlockInHand(): IBlockState? = heldBlockState
- inline fun <reified R: Entity> getEntities(): List<R> = getLoadedEntityList().filterIsInstance<R>()
+ inline fun <reified R: Entity> getAllEntities(): List<R> = getEntities().filterIsInstance<R>()
- fun getLoadedEntityList(): List<Entity> = Minecraft.getMinecraft().theWorld.getLoadedEntityList()
+ inline fun <reified R: Entity> getEntitiesOrNull(): List<R>? = getAllEntitiesOrNull()?.filterIsInstance<R>()
+
+ fun getEntities(): List<Entity> = getAllEntitiesOrNull() ?: error("minecraft.world.loadedEntityList is null.")
+
+ fun getAllEntitiesOrNull(): List<Entity>? = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.toMutableList()
} \ No newline at end of file